JIP - Java Internet Prolog - By Ugosoft

Quick Prolog Guide

BLUE_THIN_LINE.gif (1434 bytes)

| Home | Presentation | Built-In | JIP Console | How to... | Contacts |

BLUE_THIN_LINE.gif (1434 bytes)

Prolog Resources

prev.gif (8311 bytes)


Arithmetic Expression:

An arithmetic expression can be an integer or float number or one of following functions:

 

+/2 sum 3 + 5
-/2 subtraction 3 - 5
//2 quotient 3 / 5
*/2 multiplication 3 * 5
-/1 minus - 2
sin/1 sin sin(3.14)
cos/1 cosin cos(2)
asin arcsin arcsin(2)
acos arccosin arccos(3)
tan tangent tan(2.4)
atan arctangent arctan(1.5)
log natural logarithm loge log(100)
exp exponential ex exp(3)
abs absolute value abs(- 4.3).
sqrt square root sqrt(9)
int integer value nearer to  int(2.6)
pow power xy pow(3, 4)
mod modulus (rest) mod(3,4)
min minimum value min(2,6)
max maximun value max(6,7)

prev.gif (8311 bytes)


Directives

A directive is a Prolog term of the form:

  :- goal1, …, goalN

where goali is a call term (i.e. goal). A command is executed automatically when it is encountered during a consult. In JIP the directives would be inserted at the top of the file before predicate definitions.

Es.
:-module(mymodule).
:-export(mypredicate).
:- write('hello world'),nl.

 /* predicates  */

prev.gif (8311 bytes)


The standard ordering of terms

variables are less than:
  integers and floats which are less than:
    atoms which are less than:
      strings which are less than:
        lists which are less than:
          compound terms which are less than:
             true conjunctions which are less than:
               true disjunctions

prev.gif (8311 bytes)


Grammar Rules:

A Prolog program may contain one or more grammar rules. These grammar rules may be used to define the syntax of a language and to define a parser for that language.
A grammar rule takes the form:

grammar_head --> grammar_body.

Where grammar_head is a non-terminal symbol optionally followed by a terminal symbol. The body of the grammar rule is a sequence of terminals, non-terminals or grammar conditions, each separated by commas.
A grammar condition is a sequence of Prolog call terms surrounded by curly brackets ('{' and '}').
For a detailed description of the Prolog grammar rules please see the chapter on 'Grammar Rules'.

sentence --> noun_ph, verb_ph.
verb_ph --> verb, noun_ph.
verb --> [likes].
verb --> [hates].
noun_ph --> determiner, noun.
determiner --> [the].
noun --> [boy].
noun --> [dog].

prev.gif (8311 bytes)

BLUE_THIN_LINE.gif (1434 bytes)

| Home | Presentation | Built-In | JIP Console | How to... | Contacts |

BLUE_THIN_LINE.gif (1434 bytes)

Copyright © Ugo Chirico

This page hosted by Get your own Free Home Page