|
|
# Semantics
|
|
|
# Constraint Programming model representation in NDL
|
|
|
*2018-10-12*
|
|
|
|
|
|
A Prolog-like knowledge base containing only binary and unary facts. The only allowed constants are integers.
|
|
|
|
|
|
# Syntax
|
|
|
## Features
|
|
|
|
|
|
Prolog expressed with s-expressions, e.g.
|
|
|
Every model consists of:
|
|
|
* variables indexed by tuples of integers (mimicking multidimensional arrays)
|
|
|
* constraints defined on the pairs of variables
|
|
|
* constants:
|
|
|
* integers: may be used as ranges boundaries
|
|
|
* ranges: may be used as domains or index sets for variables
|
|
|
|
|
|
```
|
|
|
(unary-fact 1)
|
|
|
(unary-fact 2)
|
|
|
(binary-fact 1 2)
|
|
|
(binary-fact 2 1)
|
|
|
```
|
|
|
## Limitations
|
|
|
|
|
|
* domains have to be ranges (no holes)
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
# Queries
|
|
|
The SWI-Prolog based prototype is available in the `noodle-prolog` directory.
|
|
|
There is one basic example available for now.
|
|
|
To run it, write from the `noodle-prolog` directory:
|
|
|
|
|
|
Similarly to Prolog, query is a conjunction of atoms:
|
|
|
```
|
|
|
((unary-fact X) (binary-fact 1 X))
|
|
|
./run_example.sh nqueens
|
|
|
```
|
|
|
As in Prolog, user can use both constants and variables.
|
|
|
The only difference from Prolog is that there should be two ways of executing the query:
|
|
|
* deterministic - the same as in Prolog; should be able to generate all the possible results to the query in a repeatable way
|
|
|
* indeterministic - generating one random result to the query |
|
|
\ No newline at end of file |
|
|
Then you can check `examples/nqueens.ndl` to see ndl model of the basic 8-queens problem.# |