4.40 Debugging and declaring determinism
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Debugging and declaring determinism
          • det/1
          • $/0
          • $/1
    • Packages
Availability:built-in
Source[experimental,directive]det(+PredicateIndicators)
Declare a number of predicates as det, deterministic. As a result, both failure and success with a choicepoint is considered an error. The behaviour if the declaration is violated is controlled with the Prolog flag determinism_error. The default is to raise an exception (error). Consider the following program:
:- det(p/1).

p(1).
p(2).

Now, a call ?- p(1). behaves normally. However:

?- p(X).
ERROR: Deterministic procedure p/1 succeeded with a choicepoint
ERROR: In:
ERROR:   [10] p(1)

?- p(a).
ERROR: Deterministic procedure p/1 failed
ERROR: In:
ERROR:   [10] p(a)

Violations throw an error/2 exception determinism_error(Pred, Declared, Observed, property).