Prolog - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Prolog

Description:

Likes(Bart, school) Likes(Bart, school) - Does(Bart, homework). Happy(Lisa) ... If A- B is true, and A is true, then B is true. ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 15
Provided by: chrisb2
Learn more at: https://www.cs.usfca.edu
Category:
Tags: and | bart | lisa | prolog

less

Transcript and Presenter's Notes

Title: Prolog


1
Prolog
  • Prolog Programming in Logic
  • Prolog programs consist of clauses and rules.
  • Declarative programming
  • Emphasis is on data and relations between
    objects.
  • No familiar procedural controls.
  • Built-in inference engine.

2
Where is declarative programming useful?
  • Data-driven programming tasks
  • Verification
  • Natural Language
  • Expert Systems
  • Relational Databases
  • Diagnostic Systems

3
Logical Operators
AND Conjunction
OR Disjunction
NOT Inversion
4
Logical Operators
Implication
Equivalence
A-gtB is equivalent to !AvB
Alt-gtB is equivalent to A-gtB B-gtA (A B) v
(!A !B)
5
Propositional Calculus
  • Represent facts as symbols.
  • Homer_likes_beer.
  • Lisa_likes_tofu.
  • !(Bart_likes_school)
  • Bart_likes_school -gt Bart_does_homework.
  • Lisa_likes_school Lisa_likes_music
  • Easy, but overly verbose.
  • No reuse.

6
Predicate Calculus
  • A predicate is a function that maps from zero or
    more objects to T,F.
  • Likes(Homer, beer)
  • !Likes(Bart, school)
  • Likes(Bart, school) -gt Does(Bart, homework).
  • Happy(Lisa).
  • Gives(Moe, Homer, beer) -gt Happy(Homer).
  • Predicates provides a syntactic shorthand for
    propositions.
  • No extra representational power.

7
Inference Rules
  • AND-elimination
  • If AB is true, then A is true.
  • likes(Homer,beer) likes(Homer,
    food)-gtlikes(Homer,beer)
  • OR-introduction
  • If A is true, then AvB is true.
  • likes(Homer,food)-gtlikes(Homer,food)v
    likes(Homer,work).
  • Modus Ponens
  • If A-gtB is true, and A is true, then B is true.
  • likes(Lisa,school)-gtdoes(Lisa,homework)
    likes(Lisa,school)
  • -gt Does(Lisa,homework)

8
Quantification
  • We would like to be able to express facts such
    as
  • Everyone who likes school does their homework.
  • No one who likes beef also likes tofu.
  • Someone likes beef.
  • This requires us to be able to quantify over
    variables in the domain.

9
First-Order Logic
  • First order logic allows quantification over
    objects.
  • Universal quantification For all x
  • ?x likes(x,school) -gt does(x, homework).
  • Everyone who likes school does their homework.
  • Existential quantification There exists an x
  • ?x likes(x,tofu).
  • There exists someone who likes tofu.

10
Computational Issues
  • Full FOL is too computationally difficult to work
    with.
  • Nested quantifiers are semi-decidable.
  • ?x?y?z likes(x,y) likes(y,z).
  • Everyone likes a person who likes everyone.
  • Implications with an AND in the consequent are
    exponentially hard.
  • ?x likes(x, school) -gt does(x,homework)
    attends(x,class)
  • Everyone who likes school does their homework
    and attends class.

11
Horn clauses
  • Horn clauses are implications of the form
  • x y z -gt a
  • Only a single term in the consequent.
  • Horn clause inference is computationally
    tractable.
  • Prolog uses Horn clauses.

12
Knowledge Representation in Prolog
  • Facts (unit clauses)
  • likes(homer, beer).
  • Constants are lower case.
  • Names of relations are lower case.
  • Conjunctions
  • likes(homer,beer).
  • likes(homer,food).
  • Statement is represented as separate Prolog
    clauses.

lt- ends with a period
13
Knowledge Representation in Prolog
  • Rules
  • does(lisa,homework) - likes(lisa,school).
  • Equivalent to
  • likes(lisa,school) -gtdoes(lisa,homework)
  • Read as Lisa does homework if she likes
    school. or
  • To prove that Lisa does homework, prove that she
    likes school.

14
Variables
  • Variables are all upper-case.
  • Universal quantification is achieved by using
    variables in rules.
  • does(X,homework) - likes(X,school).
  • Everyone who likes school does their homework.
  • To prove that someone does their homework, prove
    that they like school.
Write a Comment
User Comments (0)
About PowerShow.com