@@ -1019,6 +1019,12 @@ def smt_state(step):
1019
1019
smt .write ("(declare-fun s%d () |%s_s|)" % (step , topmod ))
1020
1020
states .append ("s%d" % step )
1021
1021
1022
+ def smt_assert (expr ):
1023
+ if expr == "true" :
1024
+ return
1025
+
1026
+ smt .write ("(assert %s)" % expr )
1027
+
1022
1028
def smt_assert_antecedent (expr ):
1023
1029
if expr == "true" :
1024
1030
return
@@ -1158,12 +1164,12 @@ def smt_check_sat():
1158
1164
smt_assert_consequent (get_constr_expr (constr_assumes , step ))
1159
1165
1160
1166
if step == num_steps :
1161
- smt_assert_consequent ("(not (and (|%s_a| s%d) %s))" % (topmod , step , get_constr_expr (constr_asserts , step )))
1167
+ smt_assert ("(not (and (|%s_a| s%d) %s))" % (topmod , step , get_constr_expr (constr_asserts , step )))
1162
1168
1163
1169
else :
1164
1170
smt_assert_antecedent ("(|%s_t| s%d s%d)" % (topmod , step , step + 1 ))
1165
- smt_assert_consequent ("(|%s_a| s%d)" % (topmod , step ))
1166
- smt_assert_consequent (get_constr_expr (constr_asserts , step ))
1171
+ smt_assert ("(|%s_a| s%d)" % (topmod , step ))
1172
+ smt_assert (get_constr_expr (constr_asserts , step ))
1167
1173
1168
1174
if step > num_steps - skip_steps :
1169
1175
print_msg ("Skipping induction in step %d.." % (step ))
@@ -1234,7 +1240,7 @@ def smt_check_sat():
1234
1240
while "1" in cover_mask :
1235
1241
print_msg ("Checking cover reachability in step %d.." % (step ))
1236
1242
smt_push ()
1237
- smt_assert_antecedent ("(distinct (covers_%d s%d) #b%s)" % (coveridx , step , "0" * len (cover_desc )))
1243
+ smt_assert ("(distinct (covers_%d s%d) #b%s)" % (coveridx , step , "0" * len (cover_desc )))
1238
1244
1239
1245
if smt_check_sat () == "unsat" :
1240
1246
smt_pop ()
@@ -1317,8 +1323,8 @@ def smt_check_sat():
1317
1323
if step < skip_steps :
1318
1324
if assume_skipped is not None and step >= assume_skipped :
1319
1325
print_msg ("Skipping step %d (and assuming pass).." % (step ))
1320
- smt_assert_consequent ("(|%s_a| s%d)" % (topmod , step ))
1321
- smt_assert_consequent (get_constr_expr (constr_asserts , step ))
1326
+ smt_assert ("(|%s_a| s%d)" % (topmod , step ))
1327
+ smt_assert (get_constr_expr (constr_asserts , step ))
1322
1328
else :
1323
1329
print_msg ("Skipping step %d.." % (step ))
1324
1330
step += 1
@@ -1354,7 +1360,7 @@ def smt_check_sat():
1354
1360
print_msg ("Checking assertions in steps %d to %d.." % (step , last_check_step ))
1355
1361
smt_push ()
1356
1362
1357
- smt_assert_consequent ("(not (and %s))" % " " .join (["(|%s_a| s%d)" % (topmod , i ) for i in range (step , last_check_step + 1 )] +
1363
+ smt_assert ("(not (and %s))" % " " .join (["(|%s_a| s%d)" % (topmod , i ) for i in range (step , last_check_step + 1 )] +
1358
1364
[get_constr_expr (constr_asserts , i ) for i in range (step , last_check_step + 1 )]))
1359
1365
1360
1366
if smt_check_sat () == "sat" :
@@ -1380,8 +1386,8 @@ def smt_check_sat():
1380
1386
1381
1387
if (constr_final_start is not None ) or (last_check_step + 1 != num_steps ):
1382
1388
for i in range (step , last_check_step + 1 ):
1383
- smt_assert_consequent ("(|%s_a| s%d)" % (topmod , i ))
1384
- smt_assert_consequent (get_constr_expr (constr_asserts , i ))
1389
+ smt_assert ("(|%s_a| s%d)" % (topmod , i ))
1390
+ smt_assert (get_constr_expr (constr_asserts , i ))
1385
1391
1386
1392
if constr_final_start is not None :
1387
1393
for i in range (step , last_check_step + 1 ):
@@ -1392,7 +1398,7 @@ def smt_check_sat():
1392
1398
smt_push ()
1393
1399
1394
1400
smt_assert_consequent (get_constr_expr (constr_assumes , i , final = True ))
1395
- smt_assert_consequent ("(not %s)" % get_constr_expr (constr_asserts , i , final = True ))
1401
+ smt_assert ("(not %s)" % get_constr_expr (constr_asserts , i , final = True ))
1396
1402
1397
1403
if smt_check_sat () == "sat" :
1398
1404
print ("%s BMC failed!" % smt .timestamp ())
@@ -1408,8 +1414,8 @@ def smt_check_sat():
1408
1414
1409
1415
else : # gentrace
1410
1416
for i in range (step , last_check_step + 1 ):
1411
- smt_assert_consequent ("(|%s_a| s%d)" % (topmod , i ))
1412
- smt_assert_consequent (get_constr_expr (constr_asserts , i ))
1417
+ smt_assert ("(|%s_a| s%d)" % (topmod , i ))
1418
+ smt_assert (get_constr_expr (constr_asserts , i ))
1413
1419
1414
1420
print_msg ("Solving for step %d.." % (last_check_step ))
1415
1421
if smt_check_sat () != "sat" :
0 commit comments