Under consideration for publication in Theory and Practice of Logic Programming 1
A three-valued semantics for logic programmers
LEE NAISH
Department of Computer Science and Software Engineering
University of Melbourne
Melbourne 3010
Australia
(e-mail: lee@www.book118.com.au)
submitted 15 June 2004; revised 30 November 2004; accepted 30 June 2005
Abstract
This paper describes a simpler way for programmers to reason about the correctness of
their code. The study of semantics of logic programs has shown strong links between the
model theoretic semantics (truth and falsity of atoms in the programmer’s interpretation
of a program), procedural semantics (for example, SLD resolution) and ?xpoint semantics
(which is useful for program analysis and alternative execution mechanisms). Most of this
work assumes that intended interpretations are two-valued: a ground atom is true (and
should succeed according to the procedural semantics) or false (and should not succeed). In
reality, intended interpretations are less precise. Programmers consider that some atoms
“should not occur”or are “ill-typed”or “inadmissible”. Programmers don’t know and
don’t care whether such atoms succeed. In this paper we propose a three-valued semantics
for (essentially) pure Prolog programs with (ground) negation as failure which re?ects
this. The semantics of Fitting is similar but only associates the third truth value with non-
termination. We provide tools to reason about correctness of programs without the need
for unnatural precision or undue restrictions on programming style. As well as theoretical
results, we provide a programmer-oriented synopsis. This work has come out of work on
declarative debugging, where it has been recognised that inadmissible calls are important.
This paper has been accepted to appear in Theory and Practice of Logic Programming.
KEYWORDS: Models, immediate consequence operator, SLDNF resolution, negation,
veri?cation, declarative debugging, inadmissibility
1 Introduction
When programming, we often give too little attention to the meaning of our code.
For these sins of sloth and pride (“I can’t be bothered rechecking everything —I’m sure I got it right”) we are forced to do penance, in the form of debugging.
During the repetitive tedium we contemplate the relationships between our code,
its behaviour and our desires: the domain of programming language semantics. Thus
(in retrospect) it is natural for work on debugging to lead to work on semantics.
All too often, work on semantics seems to bear little relation to any stage of the
software life cycle. Here our aim is to provide theoretical support which can allow
programmers to reason about the correctness of their code more easily.
2 L. Naish
A-three-valued-semantics-for-logic-programmers.pdf
下载此电子书资料需要扣除0点,





