Oops! My drawing of the chessboard had an error. Here’s the correct version: From: Costello, Roger L. Hi Folks, As you know, Schematron can be used to express powerful data relationships. We saw an example of this with the N-Queens problem.
The Schematron document for the N-Queens problem can be used to validate XML instance documents, to check that they contain a valid solution to the N-Queens problem. Great! But, but, but, … Finding a valid solution to the N-Queens problem can be difficult, particularly for large chessboards. It would be useful if we could auto-generate valid solutions directly from the Schematron document. I am not aware of any tool that can auto-generate XML instances from Schematron.
With Alloy, you can express the same powerful data relationships that you can express with Schematron. Plus, the Alloy Analyzer can auto-generate solutions. In fact, the Analyzer can auto-generate
a comprehensive set of solutions. For example, at the bottom of this message is an Alloy model of the N-Queens problem. I instructed the Alloy Analyzer to generate solutions for a 5 x 5 chessboard. The Analyzer generated a complete
set of solutions. Here are two of the solutions that it auto-generated: Fantastic! /Roger
Alloy Model (thanks Loïc Gammaitoni) sig Queen { fact Queens_Not_On_Same_Row_Or_Column { fact Queens_Not_On_Diagonal { … |