PROgramming LOGic

 The Logical Model Unification  Backtracking Programming

A logic programming language is

a notational system for writing logical statements together with specified algorithms for implementing inference rules.

  • What will be cover ?

  • What is Prolog?


    Basic syntax of Edinburgh Prolog (EBNF) 

    <prologprog> -> <clause> { <clause> }	
    <clause> -> <fact> | <rule>

    <fact> -> <pred> .
    <pred> -> <atom> { ( <arglist> ) }

    <rule> -> <head> :- <body> .
    <head> -> <pred>
    <body> -> <goal> { , <goal> }
    <goal> -> <pred> | !

    <query> -> <body>.

    <arglist> -> <arg> { , <arg> }
    <arg> -> <atom> | <var> | <list>

    <atom> -> <lcchar> { <anychar> }
    <atom> -> ' { <anychar> } '

    <var> -> <ucchar> { <anychar> }
    <var> -> _ { <anychar> }

    <list> -> [ ]
    <list> -> [ <arglist> ]

    More on Syntax and Prolog terminology

    binarytree(node(10,binarytree( node(5,empty, binarytree( node(8,empty,empty))))  ,empty)).
    Graphical representation of binary tree

    Running a program. 

    ?-  consult (likes.pl ).
    % likes.pl compiled 0.00 sec, 2408 bytes
    true.
    or
    ?- [likes].
    % likes compiled 0.00 sec, 2408 bytes
    true.
    Editing a program. 
    ?- emacs('likes.pl').
    The file must be in the current path and the file does not have to be loaded yet.


    Comments


    Sample execution: family.pl


    Spring, 2019

    On Functors {in different programming languages}

    Dot notation (cons) in Prolog

    Lists are special in Prolog