DIMACS CNF
All formats · Reader spec · Cases and output
dimacs-cnf.iris reads a p cnf header and the declared
number of zero-terminated clauses. It skips c comments and stops at %
for SATLIB-style tails. Data contains vars, clauses, and the ragged
clause array; terminating zeros are consumed without being stored.
The format source is DIMACS, Satisfiability: Suggested Format, §2.1. The reader spec is copied from Gecode’s sat.cpp.
- three-variables has three variables and three clauses of different lengths.
- literal-out-of-range declares three
variables but uses literal
4. The reference reportsE-EXPECTED-VALUEat input line 2, column 3.
These are hand-made samples under the repository’s MIT license. See the library README for case layout, validation, and Gecode notices.
Reader spec
From Gecode commit 5e7bbd5c26b0702c6fd652356b2289da0710ac3c. Source notices.
Cases and output
Run the commands from the repository root. Successful reads show dzn, JSON, and a summary. Rejected inputs show the CLI's diagnostic and caret, with the stable error code beside it.
literal-out-of-range
Literal exceeds the declared variable count
E-EXPECTED-VALUE
expected an int in -3..3, found '4'
iris read formats/dimacs-cnf/dimacs-cnf.iris formats/dimacs-cnf/cases/literal-out-of-range/input.txt --dznformats/dimacs-cnf/cases/literal-out-of-range/input.txt:2:3: expected an int in -3..3, found '4'
2 | 1 4 0
| ^
while reading: repeat [1 of 1] > clause
spec: formats/dimacs-cnf/dimacs-cnf.iris:7
Input rejected
three-variables
Three variables and three clauses
dzn
iris read formats/dimacs-cnf/dimacs-cnf.iris formats/dimacs-cnf/cases/three-variables/input.txt --dznJSON
iris read formats/dimacs-cnf/dimacs-cnf.iris formats/dimacs-cnf/cases/three-variables/input.txt --jsonSummary
iris read formats/dimacs-cnf/dimacs-cnf.iris formats/dimacs-cnf/cases/three-variables/input.txt --summary