Logic programming language KL1 has concurrency (possibility to perform parallel execution) in any level. In other words, a program written in KL1 necessarily runs in parallel if we have infinite number of processors and infinite memory space. Of course such situations are impossible. The number of processors is limited in our real world. Sequentially, the concurrency will appear in a real world computer as numbers of spawned processes in a single processor.
The memory space is also limited in real world. There is no way to directly manage memory in KL1. Program would stop if sufficient memory is not available. Therefore, we have to find a pragmatic solution against limitation of resources.
In KL1, pragma is provided for that. pragma is a kind of
meta-level operand, by which program execution is controlled. Memory
consumption problem is typically revealed in generator-consumer model
[Tanenbaum, 1987]. If a process generates excess data which can not
be consumed by other process(es), segmentation fault may occur. In
this case, generally speaking, the consumer has to have higher
priority than the generator. By using pragma, for example, the
priority can be set as follows:
goal :- generator@lower_priority(X),consumer@lower_priority(0).
where X is a positive integer.
However, in complicated programs, some adjustment of priorities is often needed. There are some tips to set priorities from my experience.
recursive_goal :- some_predicate@lower_priority(X), /* X > 0 */ recursive_goal@lower_priority(0).
recursive_goal :- some_predicate@lower_priority(X), /* X >> 0 */ another_predicate@lower_priority(Y), /* Y is nearly equal 0 or equal 0*/ recursive_goal@lower_priority(0).