Prolog


Introduction

1 Presentation of Prolog
  1.1 What is a Prolog program
      1.1.1 The Program
      1.1.2 The Query

2 The Facts
  2.1 Simple facts
  2.2 Facts with arguments
  2.3 How to query

3 Variables and Unification
  3.1 Simple unifications
  3.2 Variables unification example

4 Rules
  4.1 Rules
  4.2 How to add a rule with a program
      4.2.1 The instructions
      4.2.2 Example

5 Backtracking
  5.1 Fail
  5.2 Cut
  5.3 Not

6 Recursion
  6.1 What is recursion
  6.2 Examples of Recursion
      6.2.1 Example of the ancestors
      6.2.2 Factorial

7 Lists
  7.1 What is a list in Prolog
  7.2 How to manipulate list

8 Others Elements of Prolog
  8.1 Operators
  8.2 Arithmetic

9 Input and Output
  9.1 Input Output commands
  9.2 Read and Write
  9.3 Examples
      9.3.1 Calculating the cube of an integer
      9.3.2 Treating the terms of a file
      9.3.3 ASCII characters
      9.3.4 Using Another Program

10 SWI-Prolog
  10.1 What is SWI-Prolog
  10.2 Author
  10.3 Platforms
  10.4 FTP Sites


Appendix

A Meta Logical Constructs

B Input and Output
  B.1 input
  B.2 Output

C Some Others usefull predicats
  C.1 True
  C.2 Repeat
  C.3 Call
  C.4 Setof
  C.5 Bagof

D Comparison Operators
  D.1 Arithmetic Comparison Operators
  D.2 Term Comparison


This Report in LaTeX
About us
Links

D   Comparison Operators

D.1   Arithmetic Comparison Operators

The arithmetic comparison operators are :<=<>>==:=/=
     X<Y
          True if X is less than Y.

     X=<Y
          True if X is less than or equal to Y.

     X>Y
          True if X is greater than Y.

     X>=
          True if X is greater than or equal to Y.

     X=:=Y
          True if X is equal to Y.

     X=/=Y
          True if the values of X and Y are not equal
Unlike unification theses operators cannot be used to give values to a variable. The can only be evaluated when every term on each side have been instantiated.

D.2   Term Comparison

comparison There is an order on the Prolog terms. The operators of comparison are :@<@=<@>@>=
     X@<Y
           The term X is less than Y

     Y@=<Y
           The term X is less than or equal to Y

     X@>Y
           The term X is greater than Y

     X@>=Y
           The term X is greater or equal to Y
The term order from the lowest to the highest is :
1. Variables.
2. Floating point numbers.
3. Integers.
4. atoms in the alphabetical order.



-
This Report in LaTeX -->