7.10.3 Restraint answer count
Finally, using “as max_answers(Count)
” or
the Prolog flag
max_answers_for_subgoal,
the number of answers in a table is restrained. In addition to the
tripwire actions this restraint supports the action bounded_rationality
171The
action complete_soundly
is supported as a synonym for XSB
compatibility. If the restraint is reached in the bounded
rationality mode the system takes the following actions:
- Ignore the answer that triggered the restraint.
- Prune the choice points of the tabled goal to avoid more answers.
- Add an new answer to the table that does not bind any variables, i.e., an empty answer substitution. This answer is conditional on answer_count_restraint/0.
- [undefined]answer_count_restraint
- This predicate is undefined in the sense of well founded
semantics (see section 7.6
and undefined/0).
Any answer that depends on this condition is undefined because the
max_answers
restraint on some table was violated.
The program and subsequent query below illustrate the behavior.
:- table p/2 as max_answers(3). p(M,N) :- between(1,M,N).
?- p(1 000 000, X). X = 3 ; X = 2 ; X = 1 ; % WFS residual program p(1000000, X) :- answer_count_restraint. p(1000000, X).