summaryrefslogtreecommitdiff
path: root/prolog
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-11-30 15:19:22 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-11-30 15:19:22 +0100
commitfa58ab7b297d1df467ac3a4b77397b3ca05325e9 (patch)
tree4a00c1f3ca3e596341b67103f082b9ebb16b8a38 /prolog
parenta6f9486208aba2008cb342090edb250856347ddd (diff)
Limit the number of inferences for Prolog queries
Diffstat (limited to 'prolog')
-rw-r--r--prolog/engine.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/prolog/engine.py b/prolog/engine.py
index bd1fb1d..d61c43b 100644
--- a/prolog/engine.py
+++ b/prolog/engine.py
@@ -132,8 +132,11 @@ def check_answers(engine, query, answers, timeout=10):
start = time.monotonic()
try:
+ # Limit inferences for each solution to curb unbounded recursion.
+ limited = '''(call_with_inference_limit(({}), 100000, _ILR),
+ _ILR \= inference_limit_exceeded)'''.format(query)
# Run the query.
- reply, output = ask(engine, query, timeout)
+ reply, output = ask(engine, limited, timeout)
answer, error, more = process_answer(reply)
if not check_answer(answer):
return False