Skip to content

Commit 4323bef

Browse files
committed
merge
1 parent 487e5f4 commit 4323bef

File tree

5 files changed

+12
-16
lines changed

5 files changed

+12
-16
lines changed

manticore/core/smtlib/expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ def select(self, index):
12591259
return ArraySelect(self, index)
12601260

12611261
# if a default is defined we need to check if the index was previously written
1262-
return BitVecITE(self.is_known(index), ArraySelect(self, index), self.cast_value(default))
1262+
return local_simplify(BitVecITE(self.is_known(index), ArraySelect(self, index), self.cast_value(default)))
12631263

12641264
def store(self, index, value):
12651265
casted = self.cast_index(index)

manticore/core/smtlib/solver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def __readline_and_count(self):
214214
assert self._proc.stdout
215215
buf = self._proc.stdout.readline() # No timeout enforced here
216216
# If debug is enabled check if the solver reports a syntax error
217-
# print (">",buf)
217+
#print (">",buf)
218218
if self._debug:
219219
if "(error" in buf:
220220
raise SolverException(f"Error in smtlib: {buf}")
@@ -227,7 +227,7 @@ def send(self, cmd: str) -> None:
227227
228228
:param cmd: a SMTLIBv2 command (ex. (check-sat))
229229
"""
230-
# print ("<",cmd)
230+
#print ("<",cmd)
231231
if self._debug:
232232
logger.debug(">%s", cmd)
233233
self._proc.stdout.flush() # type: ignore

manticore/core/smtlib/visitors.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -961,10 +961,11 @@ def visit_Operation(self, expression, *operands):
961961

962962
@property
963963
def result(self):
964-
return self.apply_bindings(self._stack[-1])
964+
return f"{self.apply_bindings(self._stack[-1])}"
965965

966966
def apply_bindings(self, main_smtlib_str):
967967
# Python program to print topological sorting of a DAG
968+
# Well-sortedness requirements
968969
from toposort import toposort_flatten as toposort
969970

970971
G = {}
@@ -977,25 +978,22 @@ def apply_bindings(self, main_smtlib_str):
977978
if not variables:
978979
G[name] = set()
979980

980-
output = ""
981981
# Build let statement
982+
output = main_smtlib_str
982983
for name in reversed(toposort(G)):
983984
if name not in self._bindings:
984985
continue
985986
expr, smtlib = self._bindings[name]
986987

988+
987989
# FIXME: too much string manipulation. Search occurrences in the Expression realm
988-
if main_smtlib_str.count(name) + output.count(name) == 1:
989-
main_smtlib_str = main_smtlib_str.replace(name, smtlib)
990+
if output.count(name) <= 1:
991+
#output = f"let (({name} {smtlib})) ({output})"
990992
output = output.replace(name, smtlib)
991993
else:
992-
output = f"({name} {smtlib}) {output}"
994+
output = f"(let (({name} {smtlib})) {output})"
993995

994-
if output:
995-
output = f"(let ({output}) {main_smtlib_str})"
996-
else:
997-
output = main_smtlib_str
998-
return output
996+
return f"{output}"
999997

1000998
def declarations(self):
1001999
result = ""

manticore/platforms/platform.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class Platform(Eventful):
5151

5252
_published_events = {"solve"}
5353

54-
5554
def __init__(self, *, state: Optional["StateBase"] = None, **kwargs):
5655
self._state = state
5756
super().__init__(**kwargs)

tests/other/test_smtlibv2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,15 +951,14 @@ def test_visitors(self):
951951

952952
self.assertEqual(get_depth(aux), 9)
953953
self.maxDiff = 5500
954-
print(translate_to_smtlib(aux))
955954
self.assertEqual(
956955
translate_to_smtlib(aux, use_bindings=False),
957956
"(select (store (store (store MEM #x00000000 #x61) #x00000001 #x62) #x00000003 (select (store (store MEM #x00000000 #x61) #x00000001 #x62) (bvadd VAR #x00000001))) (bvadd VAR ((_ zero_extend 24) (select (store (store (store MEM #x00000000 #x61) #x00000001 #x62) #x00000003 (select (store (store MEM #x00000000 #x61) #x00000001 #x62) (bvadd VAR #x00000001))) VAR))))",
958957
)
959958

960959
self.assertEqual(
961960
translate_to_smtlib(aux, use_bindings=True),
962-
"(let ((!a_2! (store (store MEM #x00000000 #x61) #x00000001 #x62)) (!a_4! (store !a_2! #x00000003 (select !a_2! (bvadd VAR #x00000001)))) ) (select !a_4! (bvadd VAR ((_ zero_extend 24) (select !a_4! VAR)))))",
961+
"(let ((!a_2! (store (store MEM #x00000000 #x61) #x00000001 #x62))) (let ((!a_4! (store !a_2! #x00000003 (select !a_2! (bvadd VAR #x00000001))))) (select !a_4! (bvadd VAR ((_ zero_extend 24) (select !a_4! VAR))))))"
963962
)
964963

965964
values = arr[0:2]

0 commit comments

Comments
 (0)