Thom Fr\"uhwirth presented a short, elegant and efficient Prolog program for the n queens problem. However the program may be seen as rather tricky and one may not be convinced about its correctness. This paper explains the program in a declarative way, and provides proofs of its correctness and completeness. The specification and the proofs are declarative, i.e. they abstract from any operational semantics. The specification is approximate, it is unnecessary to describe the program's semantics exactly. Despite the program works on non-ground terms, this work employs the standard semantics, based on logical consequence and Herbrand interpretations. Another purpose of the paper is to present an example of precise declarative reasoning about the semantics of a logic program. Under consideration in Theory and Practice of Logic Programming (TPLP).
翻译:Thom Fr\"uhwirth 为 n Q 问题提出了一个简短、优雅和高效的Prolog 程序。 但是, 程序可能被视为相当棘手, 人们可能不相信它的正确性。 本文以宣示方式解释程序, 并提供其正确性和完整性的证明。 规格和证明是宣示性的, 即它们从任何操作的语义学中抽象。 规格是近似的, 没有必要准确描述程序的语义。 尽管程序在非地面术语上进行了工作, 但根据逻辑后果和Herbrand解释, 这项工作使用标准语义。 本文的另一个目的是提供一个关于逻辑程序语义的精确宣示性推理的例子。 在逻辑编程理论和实践( TPLP) 中考虑 。