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

1   Presentation of Prolog

1.1   What is a Prolog program

Programming in Prolog is very different from programming in a traditional proceduralprocedural language like Pascal. In Prolog you don't say how the program will work.
Prolog can be separated in two parts :

1.1.1   The Program

The program, sometimes called Database is a texte file (*.pl) that contain the facts and rules that will be used by the user of the program. It contains all the relations that make this program.

1.1.2   The Query

When you launch a program you are in query modequery mode. This mode is represented by the sign ? - at the begining of the line. In query mode you ask questions about relations described in the program.

1.2   Loading a program

loading First you have to launch your Prolog compiler, for this report we used the SWI-Prolog wich is a freeware (if you want to know more about SWI-Prolog go to this page). When Prolog is launched the ?- should appear meaning you are in query mode. The manier to launch a program depends of your compiler. For SWI-Prolog you can load a program by typing the cammand [file]. when the file of your program is file.pl. If you compiler is not SWI-Prolog you can also try the command reconsult(file). When you have done this you can use all the facts and rules that are contained in the program. Now let's begin to see what is a fact...


-
The Facts -->