Your SlideShare is downloading. ×
0
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

PROLOG: Matching And Proof Search In Prolog

1,803

Published on

PROLOG: Matching And Proof Search In Prolog

PROLOG: Matching And Proof Search In Prolog

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,803
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Matching and Proof search in Prolog
  • 2. OVERVIEW
    Matching
    Occurs check
    Programming with matching
    Proof search
    Examples
  • 3. MATCHING
    The basic idea for a Two terms match is:
    The two terms are equal or if they contain variables that can be instantiated in such a way that the resulting terms are equal.
    If term1 and term2 are constants, then term1 and term2 match if and only if they are the same atom, or the same number.
  • 4. MATCHING
    If term1 is a variable and term2 is any type of term, then term1 and term2 match and term1 is instantiated to term2.
    Similarly, if term2 is a variable and term1 is any type of term, then term1 and term2 match, and term2 is instantiated to term1.
    If term1 and term2 are complex terms, then they match if and only if:
    • a. They have the same functor and arity.
    • 5. b. All their corresponding arguments match
    • 6. c. and the variable instantiations are compatible.
    Two terms match if and only if it follows from the previous three clauses that they match.
  • 7. The occurs check
    Consider the following query:
    father(X) = X.
    • A standard unification algorithm would say: No, these don't match.
    Pick any term and instantiate X to the term you picked.
    For ex:
    if you instantiate X to father(father(butch)), the left hand side becomes father(father(father(butch))), and the right hand side becomes father(father(butch)). Obviously these don't match.
    SICStus Prolog or SWI returns the answer like:
    X = father(father(father(father(father(father(...))))))))))
    The dots are indicating that there is an infinite nesting of father functors.
  • 8. Programming with matching
    Matching plays a key role in Prolog proof search and this alone makes it vital.
    Matching can then be used to pull out the information you want.
    Ex: The following two line knowledge base
    defines two predicates, namely vertical/2 and horizontal/2,
    which specify what it means for a line to be vertical or
    horizontal respectively.
    vertical(line(point(X,Y),point(X,Z))).
    horizontal(line(point(X,Y),point(Z,Y))).
  • 9. The definition of vertical/1 simply says that a line that goes between two points that have the same x-coordinate is vertical.
    The definition of vertical/1 simply says that a line that goes between two points that have the same x-coordinate is vertical.
    Ex:
    vertical(line(point(1,1),point(1,3))).
    yes
    vertical(line(point(1,1),point(3,2))).
    no
  • 10. Proof search
    Consider the following Knowledge Base:
    f(a).
    f(b).
    g(a).
    g(b).
    h(b).
    k(X) :- f(X),g(X),h(X).
    On posing the query k(X).
     Prolog returns k(b)
  • 11. Proof search
    Prolog reads the knowledge base, and tries to match k(X) with either a fact, or the head of a rule.
    It searches the knowledge base top to bottom, and carries out the matching, if it can, at the first place possible.
    Here there is only one possibility, it must match k(X) to the head of the rule:
    k(X) :- f(X),g(X),h(X).
  • 12. Examples:
    the original query now reads k(_G348) and Prolog knows that is:
    k(_G348) :- f(_G348),g(_G348),h(_G348).
    The query says: `I want to find an individual that has property k'.
    The rule says,`an individual has property k if it has properties f, g, and h'.
    So if Prolog can
    find an individual with properties f, g, and h, it will have satisfied the original query. So Prolog
    replaces the original query with the following list of goals:
    f(_G348),g(_G348),h(_G348).
  • 13. Graphical representation
    X= _G348
    K(x)
    f(_G348), g(_G348), h(_G348)
  • 14. Visit more self help tutorials
    Pick a tutorial of your choice and browse through it at your own pace.
    The tutorials section is free, self-guiding and will not involve any additional support.
    Visit us at www.dataminingtools.net

×