diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-11-30 15:19:22 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-11-30 15:19:22 +0100 |
commit | fa58ab7b297d1df467ac3a4b77397b3ca05325e9 (patch) | |
tree | 4a00c1f3ca3e596341b67103f082b9ebb16b8a38 | |
parent | a6f9486208aba2008cb342090edb250856347ddd (diff) |
Limit the number of inferences for Prolog queries
-rw-r--r-- | prolog/engine.py | 5 |
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 |