// The N Queens constraint satisfaction problem as a high-level Petri net.
// Generalised by Marko Mäkelä from Michael J. Sanders,
// "Constraint Programming with Object-Oriented Petri Nets", in
// "1998 IEEE International Conference on Systems, Man, and Cybernetics",
// pages 289--294, Figure 1 on page 290.

/// The queen data type.
typedef int (1..8) q_t;

/// The available queens.
place InColumn (0,#q_t) q_t: q_t q: q;

/// Solve the constraint satisfaction problem "N Queens".
/// The indexes of the variables .c represent row values.
/// The values bound to the variables .c represent column values.
/// The guard expression prohibits diagonal attacks.
/// Horizontal and vertical attacks are prohibited by the net structure.
trans solve
in { place InColumn: q_t q: .c; }
gate q_t q1 && q_t q2 (q2 != q1) &&
(is q_t .c q1 - is q_t .c q2 != q1 - q2 &&
 is q_t .c q1 - is q_t .c q2 != q2 - q1);
