15-317 Constructive Logic
Lecture 17: Modes, Termination, and Coverage
Twelf is an implementation of LF as a logic programming
language with a number of additional features. Besides the
strong type system, it can also check mode, termination, and
coverage properties of programs.
Modes specify the expected input/output behavior of predicates
(represented in Twelf as type families) and mode checking will
verify that the program satisfies a given input/output specification.
Termination checking verifies that a given predicate will always
terminate. If a predicate passes type, mode, and termination checking
we know that every well-typed, well-moded query will terminate either
with success (and a well-typed substitution for its free variables) or
fail. Certain predicates such as append, are intended to compute
total functions and should therefore never fail on any input. This
can be verified through coverage. All these checks together can
certify that programs are total in their inputs, always succeeding
and producing ground outputs.