jagomart
digital resources
picture1_Prolog08ml2r2


 149x       Filetype PDF       File size 0.21 MB       Source: www.cl.cam.ac.uk


File: Prolog08ml2r2
prolog lecture 2 rules lists arithmetic last call optimisation backtracking generate and test rules have a head which is true if the body is true our prolog databases have contained ...

icon picture PDF Filetype PDF | Posted on 03 Feb 2023 | 2 years ago
Partial capture of text on file.
                   Prolog Lecture 2
                     ● Rules
                     ● Lists
                     ● Arithmetic
                     ● Last-call optimisation
                     ● Backtracking
                     ● Generate and Test
         Rules have a head which is true if 
                         the body is true
       Our Prolog databases have contained only facts
        – e.g. lecturer(prolog,dave).
       Most programs require more complex rules (p8)
        – Not just “this is true”, but “this is true if that is true”
            rule(X,Y) :- part1(X), part2(X,Y).
                head                         body
       You can read this as: “rule(X,Y) is true if part1(X) 
       is true and part2(X,Y) is true”
        – Note: X and Y also need to be unified appropriately
                                                                          2
        Variables can be internal to a rule
      The variable Z is not present in the clause head:
           rule2(X) :- thing(X,Z), thang(Z).
      Read this as “rule2(X) is true if there is a Z such 
      that thing(X,Z) is true and thang(Z) is true”
                                                             3
               Prolog and first order logic
      The :- symbol is an ASCII-art arrow pointing left
        – The “neck” (it's between the clause head and body!)
      The arrow represents logical implication
        – Mathematically we'd usually write clause➔head
        – It's not as clean as a graphical arrow ...
        – In practice Prolog is not as clean as logic either!
      Note that quantifiers ( and ) are not explicitly 
      expressed in Prolog
                                                                      4
The words contained in this file might help you see if this file matches what you are looking for:

...Prolog lecture rules lists arithmetic last call optimisation backtracking generate and test have a head which is true if the body our databases contained only facts e g lecturer dave most programs require more complex p not just this but that rule x y part you can read as note also need to be unified appropriately variables internal variable z present in clause thing thang there such first order logic symbol an ascii art arrow pointing left neck it s between represents logical implication mathematically we d usually write clausehead clean graphical practice either quantifiers are explicitly expressed...

no reviews yet
Please Login to review.