Merge pull request #3871 from jix/smtbmc-sexpr-scan

smtbmc: Avoid quadratic behavior when scanning s-exprs
This commit is contained in:
Miodrag Milanović 2023-08-04 14:47:50 +02:00 committed by GitHub
commit 701b767736
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -245,6 +245,7 @@ class SmtIo:
self.logic_uf = False
self.unroll_idcnt = 0
self.unroll_buffer = ""
self.unroll_level = 0
self.unroll_sorts = set()
self.unroll_objs = set()
self.unroll_decls = dict()
@ -420,14 +421,16 @@ class SmtIo:
self.p_close()
if unroll and self.unroll:
s = re.sub(r"\|[^|]*\|", "", stmt)
self.unroll_level += s.count("(") - s.count(")")
if self.unroll_level > 0:
self.unroll_buffer += stmt
self.unroll_buffer += " "
return
else:
stmt = self.unroll_buffer + stmt
self.unroll_buffer = ""
s = re.sub(r"\|[^|]*\|", "", stmt)
if s.count("(") != s.count(")"):
self.unroll_buffer = stmt + " "
return
s = self.parse(stmt)
if self.recheck and s and s[0].startswith("get-"):