SlideShare a Scribd company logo
1 of 32
Predicate Logic
• Terms represent specific objects in the
world and can be constants, variables or
functions.
• Predicate Symbols refer to a particular
relation among objects.
• Sentences represent facts, and are made of
of terms, quantifiers and predicate symbols.
Predicate Logic
• Functions allow us to refer to objects
indirectly (via some relationship).
• Quantifiers and variables allow us to refer
to a collection of objects without explicitly
naming each object.
Some Examples
• Predicates: Brother, Sister, Mother , Father
• Objects: Bill, Hillary, Chelsea, Roger
• Facts expressed as atomic sentences a.k.a.
literals:
Father(Bill,Chelsea)
Mother(Hillary,Chelsea)
Brother(Bill,Roger)
 Father(Bill,Chelsea)
Variables and Universal
Quantification
• Universal Quantification allows us to make
a statement about a collection of objects:
x Cat(x)  Mammel(x)
All cats are mammels
 x Father(Bill,x)  Mother(Hillary,x)
All of Bill’s kids are also Hillary’s kids.
Variables and Existential
Quantification
• Existential Quantification allows us to state
that an object does exist (without naming it):
x Cat(x)  Mean(x)
There is a mean cat.
 x Father(Bill,x)  Mother(Hillary,x)
There is a kid whose father is Bill and whose
mother is Hillary
Nested Quantification
 x,y Parent(x,y)  Child(y,x)
 x  y Loves(x,y)
 x [Passtest(x)  ( x ShootDave(x))]
Functions
• Functions are terms - they refer to a specific
object.
• We can use functions to symbolically refer
to objects without naming them.
• Examples:
fatherof(x) age(x) times(x,y) succ(x)
Using functions
 x Equal(x,x)
Equal(factorial(0),1)
 x Equal(factorial(s(x)),
times(s(x),factorial(x)))
Representing facts with Predicate Logic - Example
• Marcus was a man
• Marcus was a Pompeian
• All Pompeians were Romans
• Caesar was a ruler.
• All Romans were either loyal to Caesar or hated him.
• Everyone is loyal to someone.
• Men only try to assassinate rulers they are not loyal to.
• Marcus tried to assassinate Caesar
Predicate Logic Knowledgebase
Man(Marcus)
Pompeian(Marcus)
 x Pompeian(x)  Roman(x)
Ruler(Caesar)
 x Romans(x)  Loyalto(x,Caesar)  Hate(x,Caesar)
 x  y Loyalto(x,y)
 x  y Man(x)  Ruler(y)  Tryassassinate(x,y) 
Loyalto(x,y)
Tryassassinate(Marcus,Caesar)
Questions (Goals)
Was Marcus a Roman?
Was Marcus loyal to Caesar?
Who was Marcus loyal to?
Was Marcus a ruler?
Will the test be easy?
Isa and Instance relationships
• The example uses inheritance without
explicitly having isa or instance predicates.
• We could rewrite the facts using isa and
instance explicitly:
instance(Marcus,man)
instance(Marcus,Pompeian)
isa(Pompeian,Roman)
Quiz
Using the predicates:
Father(x,y) Mother(x,y) Brother(x,y) Sister(x,y)
Construct predicate logic facts that establish
the following relationships:
– GrandParent
– GrandFather
– GrandMother
– Uncle
– Cousin
Proof procedure for Predicate
Logic
• Same idea, but a few added complexities:
– conversion to CNF is much more complex.
– Matching of literals requires providing a matching
of variables, constants and/or functions.
 Skates(x)  LikesHockey(x)
 LikesHockey(y)
We can resolve these only if we assume x and y refer
to the same object.
Predicate Logic and CNF
• Converting to CNF is harder - we need to worry
about variables and quantifiers.
1. Eliminate all implications 
2. Reduce the scope of all  to single term. *
3. Make all variable names unique
4. Move Quantifiers Left *
5. Eliminate Existential Quantifiers *
6. Eliminate Universal Quantifiers *
7. Convert to conjunction of disjuncts
8. Create separate clause for each conjunct.
Eliminate Existential Quantifiers
• Any variable that is existentially quantified
means we are saying there is some value for
that variable that makes the expression true.
• To eliminate the quantifier, we can replace
the variable with a function.
• We don’t know what the function is, we just
know it exists.
Skolem functions
 y President(y)
We replace y with a new function func:
President(func())
func is called a skolem function.
In general the function must have the same number
of arguments as the number of universal
quantifiers in the current scope.
Skolemization Example
x y Father(y,x)
create a new function named foo and replace y with
the function.
 x Father(foo(x),x)
Predicate Logic Resolution
• We have to worry about the arguments to
predicates, so it is harder to know when 2
literals match and can be used by resolution.
• For example, does the literal
Father(Bill,Chelsea) match Father(x,y) ?
• The answer depends on how we substitute
values for variables.
Unification
• The process of finding a substitution for
predicate parameters is called unification.
• We need to know:
– that 2 literals can be matched.
– the substitution is that makes the literals identical.
• There is a simple algorithm called the
unification algorithm that does this.
The Unification Algorithm
1. Initial predicate symbols must match.
2. For each pair of predicate arguments:
– different constants cannot match.
– a variable may be replaced by a constant.
– a variable may be replaced by another variable.
– a variable may be replaced by a function as long as the
function does not contain an instance of the variable.
Unification Algorithm
• When attempting to match 2 literals, all
substitutions must be made to the entire
literal.
• There may be many substitutions that unify
2 literals, the most general unifier is always
desired.
Unification Example
• P(x) and P(y): substitution = (x/y)
• P(x,x) and P(y,z): (z/y)(y/x)
• P(x,f(y)) and P(Joe,z): (Joe/x, f(y)/z)
• P(f(x)) and P(x): can’t do it!
• P(x)  Q(Jane) and P(Bill)  Q(y):
(Bill/x, Jane/y)
Unification & Resolution
Examples
Father(Bill,Chelsea)  Father(Bill,x)Mother(Hillary,x)
Man(Marcus)  Man(x)  Mortal(x)
Loves(father(a),a)  Loves(x,y)  Loves(y,x)
This is a function
Predicate Logic Resolution
Algorithm
• While no empty clause exists and there are
clauses that can be resolved:
– select 2 clauses that can be resolved.
– resolve the clauses (after unification), apply the
unification substitution to the result and store in
the knowledge base.
Example:
 Smart(x)   LikesHockey(x)  RPI(x)
 Canadian(y)  LikesHockey(y)
 Skates(z)  LikesHockey(z)
Smart(Joe)
Skates(Joe)
Goal is to find out if RPI(Joe) is true.
• Man(Marcus)
• Pompeian(Marcus)
•  Pompeian(x1)  Roman(x1)
• Ruler(Caesar)
•  Romans(x2)  Loyalto(x2,Caesar)  Hate(x2,Caesar)
• Loyalto(x3 , f(x3))
•  Man(x4)   Ruler(y1)   Tryassassinate(x4,y1) 
Loyalto(x4,y1)
• PROVE: Tryassassinate(Marcus,Caesar)
Answering Questions
• We can also use the proof procedure to
answer questions such as “who tried to
assassinate Caesar” by proving:
– Tryassassinate(y,Caesar).
– Once the proof is complete we need to find out
what was substitution was made for y.
Computation
Equal(y,y)
Equal(factorial(s(x)),times(s(x),factorial(x)))
…assume s(_) and times(_,_) can compute.
We can ask for 10!:
Equal(factorial(10),z)
Test Type Question
• The members of a bridge club are Joe, Sally, Bill and Ellen.
• Joe is married to Sally.
• Bill is Ellen’s Brother.
• The spouse of every married person in the club is also in the
club.
• The last meeting of the club was at Joe’s house
• Was the last meeting at Sally’s house?
• Is Ellen married?
Logic Programming - Prolog
• Prolog is a declarative programming
language based on logic.
• A Prolog program is a list of facts.
• There are various predicates and functions
supplied to support I/O, graphics, etc.
• Instead of CNF, prolog uses an implicative
normal form: A  B  ...  C D
Prolog Example - Towers of Hanoi
hanoi(N) :- move(N,left,middle,right).
move(1,A,_,C) :- inform(A,C),!.
move(N,A,B,C) :-
N1=N-1, move(N1,A,C,B),
inform(A,C), move(N1,B,A,C).
inform(Loc1,Loc2) :-
write(“Move disk from”,Loc1,” to”, Loc2).
hanoi(3)

More Related Content

What's hot

Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prologHarry Potter
 
PROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologPROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologDataminingTools Inc
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : BasicsMitul Desai
 
ProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) IntroductionProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) Introductionwahab khan
 
PROLOG: Fact Roles And Queries In Prolog
PROLOG: Fact Roles And Queries In PrologPROLOG: Fact Roles And Queries In Prolog
PROLOG: Fact Roles And Queries In PrologPROLOG CONTENT
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog LanguageREHMAT ULLAH
 
Introduction to logic and prolog - Part 1
Introduction to logic and prolog - Part 1Introduction to logic and prolog - Part 1
Introduction to logic and prolog - Part 1Sabu Francis
 
Prolog Programming Language
Prolog Programming  LanguageProlog Programming  Language
Prolog Programming LanguageReham AlBlehid
 

What's hot (18)

Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
PROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologPROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In Prolog
 
prolog ppt
prolog pptprolog ppt
prolog ppt
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : Basics
 
Prolog 7-Languages
Prolog 7-LanguagesProlog 7-Languages
Prolog 7-Languages
 
ProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) IntroductionProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) Introduction
 
PROLOG: Fact Roles And Queries In Prolog
PROLOG: Fact Roles And Queries In PrologPROLOG: Fact Roles And Queries In Prolog
PROLOG: Fact Roles And Queries In Prolog
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
 
Prolog
PrologProlog
Prolog
 
Introduction to logic and prolog - Part 1
Introduction to logic and prolog - Part 1Introduction to logic and prolog - Part 1
Introduction to logic and prolog - Part 1
 
Introduction to Prolog
Introduction to PrologIntroduction to Prolog
Introduction to Prolog
 
Prolog Programming Language
Prolog Programming  LanguageProlog Programming  Language
Prolog Programming Language
 
Logic Programming and ILP
Logic Programming and ILPLogic Programming and ILP
Logic Programming and ILP
 
First order logic
First order logicFirst order logic
First order logic
 
First order logic
First order logicFirst order logic
First order logic
 
Fol
FolFol
Fol
 
Inteligencia artificial
Inteligencia artificialInteligencia artificial
Inteligencia artificial
 
Semantics
SemanticsSemantics
Semantics
 

Similar to Predlogic

Similar to Predlogic (20)

knowledge representation.pptx
knowledge representation.pptxknowledge representation.pptx
knowledge representation.pptx
 
Knowledge Representation and Reasoning.pptx
Knowledge Representation and Reasoning.pptxKnowledge Representation and Reasoning.pptx
Knowledge Representation and Reasoning.pptx
 
AIML 7th semester VTU
AIML 7th semester VTUAIML 7th semester VTU
AIML 7th semester VTU
 
Chapter 4 (final)
Chapter 4 (final)Chapter 4 (final)
Chapter 4 (final)
 
artficial intelligence
artficial intelligenceartficial intelligence
artficial intelligence
 
Module_5_1.pptx
Module_5_1.pptxModule_5_1.pptx
Module_5_1.pptx
 
First order logic.ppt
First order logic.pptFirst order logic.ppt
First order logic.ppt
 
X02PredCalculus.ppt
X02PredCalculus.pptX02PredCalculus.ppt
X02PredCalculus.ppt
 
PredicateLogic (1).ppt
PredicateLogic (1).pptPredicateLogic (1).ppt
PredicateLogic (1).ppt
 
PredicateLogic.pptx
PredicateLogic.pptxPredicateLogic.pptx
PredicateLogic.pptx
 
Lec 3.pdf
Lec 3.pdfLec 3.pdf
Lec 3.pdf
 
01bkb04p.ppt
01bkb04p.ppt01bkb04p.ppt
01bkb04p.ppt
 
Discrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdfDiscrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdf
 
Predicate logic
 Predicate logic Predicate logic
Predicate logic
 
Theory of first order logic
Theory of first order logicTheory of first order logic
Theory of first order logic
 
Chapter10
Chapter10Chapter10
Chapter10
 
Knowledge representation using predicate logic
Knowledge representation using predicate logicKnowledge representation using predicate logic
Knowledge representation using predicate logic
 
ppt
pptppt
ppt
 
ppt
pptppt
ppt
 
Probability statistics assignment help
Probability statistics assignment helpProbability statistics assignment help
Probability statistics assignment help
 

Recently uploaded

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 

Recently uploaded (20)

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 

Predlogic

  • 1. Predicate Logic • Terms represent specific objects in the world and can be constants, variables or functions. • Predicate Symbols refer to a particular relation among objects. • Sentences represent facts, and are made of of terms, quantifiers and predicate symbols.
  • 2. Predicate Logic • Functions allow us to refer to objects indirectly (via some relationship). • Quantifiers and variables allow us to refer to a collection of objects without explicitly naming each object.
  • 3. Some Examples • Predicates: Brother, Sister, Mother , Father • Objects: Bill, Hillary, Chelsea, Roger • Facts expressed as atomic sentences a.k.a. literals: Father(Bill,Chelsea) Mother(Hillary,Chelsea) Brother(Bill,Roger)  Father(Bill,Chelsea)
  • 4. Variables and Universal Quantification • Universal Quantification allows us to make a statement about a collection of objects: x Cat(x)  Mammel(x) All cats are mammels  x Father(Bill,x)  Mother(Hillary,x) All of Bill’s kids are also Hillary’s kids.
  • 5. Variables and Existential Quantification • Existential Quantification allows us to state that an object does exist (without naming it): x Cat(x)  Mean(x) There is a mean cat.  x Father(Bill,x)  Mother(Hillary,x) There is a kid whose father is Bill and whose mother is Hillary
  • 6. Nested Quantification  x,y Parent(x,y)  Child(y,x)  x  y Loves(x,y)  x [Passtest(x)  ( x ShootDave(x))]
  • 7. Functions • Functions are terms - they refer to a specific object. • We can use functions to symbolically refer to objects without naming them. • Examples: fatherof(x) age(x) times(x,y) succ(x)
  • 8. Using functions  x Equal(x,x) Equal(factorial(0),1)  x Equal(factorial(s(x)), times(s(x),factorial(x)))
  • 9. Representing facts with Predicate Logic - Example • Marcus was a man • Marcus was a Pompeian • All Pompeians were Romans • Caesar was a ruler. • All Romans were either loyal to Caesar or hated him. • Everyone is loyal to someone. • Men only try to assassinate rulers they are not loyal to. • Marcus tried to assassinate Caesar
  • 10. Predicate Logic Knowledgebase Man(Marcus) Pompeian(Marcus)  x Pompeian(x)  Roman(x) Ruler(Caesar)  x Romans(x)  Loyalto(x,Caesar)  Hate(x,Caesar)  x  y Loyalto(x,y)  x  y Man(x)  Ruler(y)  Tryassassinate(x,y)  Loyalto(x,y) Tryassassinate(Marcus,Caesar)
  • 11. Questions (Goals) Was Marcus a Roman? Was Marcus loyal to Caesar? Who was Marcus loyal to? Was Marcus a ruler? Will the test be easy?
  • 12. Isa and Instance relationships • The example uses inheritance without explicitly having isa or instance predicates. • We could rewrite the facts using isa and instance explicitly: instance(Marcus,man) instance(Marcus,Pompeian) isa(Pompeian,Roman)
  • 13. Quiz Using the predicates: Father(x,y) Mother(x,y) Brother(x,y) Sister(x,y) Construct predicate logic facts that establish the following relationships: – GrandParent – GrandFather – GrandMother – Uncle – Cousin
  • 14. Proof procedure for Predicate Logic • Same idea, but a few added complexities: – conversion to CNF is much more complex. – Matching of literals requires providing a matching of variables, constants and/or functions.  Skates(x)  LikesHockey(x)  LikesHockey(y) We can resolve these only if we assume x and y refer to the same object.
  • 15. Predicate Logic and CNF • Converting to CNF is harder - we need to worry about variables and quantifiers. 1. Eliminate all implications  2. Reduce the scope of all  to single term. * 3. Make all variable names unique 4. Move Quantifiers Left * 5. Eliminate Existential Quantifiers * 6. Eliminate Universal Quantifiers * 7. Convert to conjunction of disjuncts 8. Create separate clause for each conjunct.
  • 16. Eliminate Existential Quantifiers • Any variable that is existentially quantified means we are saying there is some value for that variable that makes the expression true. • To eliminate the quantifier, we can replace the variable with a function. • We don’t know what the function is, we just know it exists.
  • 17. Skolem functions  y President(y) We replace y with a new function func: President(func()) func is called a skolem function. In general the function must have the same number of arguments as the number of universal quantifiers in the current scope.
  • 18. Skolemization Example x y Father(y,x) create a new function named foo and replace y with the function.  x Father(foo(x),x)
  • 19. Predicate Logic Resolution • We have to worry about the arguments to predicates, so it is harder to know when 2 literals match and can be used by resolution. • For example, does the literal Father(Bill,Chelsea) match Father(x,y) ? • The answer depends on how we substitute values for variables.
  • 20. Unification • The process of finding a substitution for predicate parameters is called unification. • We need to know: – that 2 literals can be matched. – the substitution is that makes the literals identical. • There is a simple algorithm called the unification algorithm that does this.
  • 21. The Unification Algorithm 1. Initial predicate symbols must match. 2. For each pair of predicate arguments: – different constants cannot match. – a variable may be replaced by a constant. – a variable may be replaced by another variable. – a variable may be replaced by a function as long as the function does not contain an instance of the variable.
  • 22. Unification Algorithm • When attempting to match 2 literals, all substitutions must be made to the entire literal. • There may be many substitutions that unify 2 literals, the most general unifier is always desired.
  • 23. Unification Example • P(x) and P(y): substitution = (x/y) • P(x,x) and P(y,z): (z/y)(y/x) • P(x,f(y)) and P(Joe,z): (Joe/x, f(y)/z) • P(f(x)) and P(x): can’t do it! • P(x)  Q(Jane) and P(Bill)  Q(y): (Bill/x, Jane/y)
  • 24. Unification & Resolution Examples Father(Bill,Chelsea)  Father(Bill,x)Mother(Hillary,x) Man(Marcus)  Man(x)  Mortal(x) Loves(father(a),a)  Loves(x,y)  Loves(y,x) This is a function
  • 25. Predicate Logic Resolution Algorithm • While no empty clause exists and there are clauses that can be resolved: – select 2 clauses that can be resolved. – resolve the clauses (after unification), apply the unification substitution to the result and store in the knowledge base.
  • 26. Example:  Smart(x)   LikesHockey(x)  RPI(x)  Canadian(y)  LikesHockey(y)  Skates(z)  LikesHockey(z) Smart(Joe) Skates(Joe) Goal is to find out if RPI(Joe) is true.
  • 27. • Man(Marcus) • Pompeian(Marcus) •  Pompeian(x1)  Roman(x1) • Ruler(Caesar) •  Romans(x2)  Loyalto(x2,Caesar)  Hate(x2,Caesar) • Loyalto(x3 , f(x3)) •  Man(x4)   Ruler(y1)   Tryassassinate(x4,y1)  Loyalto(x4,y1) • PROVE: Tryassassinate(Marcus,Caesar)
  • 28. Answering Questions • We can also use the proof procedure to answer questions such as “who tried to assassinate Caesar” by proving: – Tryassassinate(y,Caesar). – Once the proof is complete we need to find out what was substitution was made for y.
  • 29. Computation Equal(y,y) Equal(factorial(s(x)),times(s(x),factorial(x))) …assume s(_) and times(_,_) can compute. We can ask for 10!: Equal(factorial(10),z)
  • 30. Test Type Question • The members of a bridge club are Joe, Sally, Bill and Ellen. • Joe is married to Sally. • Bill is Ellen’s Brother. • The spouse of every married person in the club is also in the club. • The last meeting of the club was at Joe’s house • Was the last meeting at Sally’s house? • Is Ellen married?
  • 31. Logic Programming - Prolog • Prolog is a declarative programming language based on logic. • A Prolog program is a list of facts. • There are various predicates and functions supplied to support I/O, graphics, etc. • Instead of CNF, prolog uses an implicative normal form: A  B  ...  C D
  • 32. Prolog Example - Towers of Hanoi hanoi(N) :- move(N,left,middle,right). move(1,A,_,C) :- inform(A,C),!. move(N,A,B,C) :- N1=N-1, move(N1,A,C,B), inform(A,C), move(N1,B,A,C). inform(Loc1,Loc2) :- write(“Move disk from”,Loc1,” to”, Loc2). hanoi(3)