Did you know ... | Search Documentation: |

Pack cosmos -- docs/guide4.txt |

x=double(1) y=x print(y)

In the logic paradigm, or logic programming (LP), which we follow to the letter, as our language *is* in fact a logic programming language, this is simply a set of statements.

- The double of 1 is x.
- The variable of y equals x.
- The value of y is written on the screen.
It's easy to see by looking at the program that this applies. We may simply look at the program and see that x equals the result of a function
*double*, y is x, and the value is written (which we know the statement*print*does).We only have to take a moment to conclude that 2 will be written if we run the program, and it is.

2

If a paradigm is a way to look at a given program, the procedural paradigm looks at it *imperatively.* A program is a recipe, or list of instructions to be executed by the computer.

This paradigm follows the computer program closely. It's the closest to how the computer actually acts.

The following instructions would be executed.

- A procedure or command
*double*computes the double of 1. - This value is given to x. A variable in the procedural paradigm is like a slot. In fact, it's a slot of
*computer memory*and occupies a space in the computer. - The value in x is then assigned to the slot y.
- The command to write the statement on the screen,
*print*, is given. The difference so far is subtle, and you could take it as a procedural program as-is. In fact, our language highly resembles procedural languages in syntax.This is on purpose, the language is made so that it can be reasoned or written in this style to some extent.

Though you may often simply see the program as a series of statements in the logic paradigm, it's sometimes needed to know how the computer executes them.

After all, the program runs in a computer.

We'll call this the "Logic-Procedural" paradigm (though it's a made-up term we invented). The Logic-Procedural interpretation of a program is given by how our procedural logic engine executes the logic program.

Often, the only reason we need to know this is so our program has good performance. An efficient program will run as quickly as it can and not consume many *memory slots*.

Most important for our language is the notion of a pure logic program.

Logic programs allow us to effectively write logical statements and have the language work them out correctly.

- Any relation made of pure relations and operators is pure.
- =, and, or, not, if and regular arithmetic are pure.
Knowing you have written a pure relation is quite simple.
All you have to do is use pure relations! Then, your relation is also pure.