Skip to content

Commit d05abeb

Browse files
committed
edits
1 parent d599166 commit d05abeb

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

manthan.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def finish(status):
156156
cprint("c [manthan] negative unates", NegUnate)
157157

158158
Unates = PosUnate + NegUnate
159-
if Unates:
159+
if Unates and args.apply_unates == 1:
160160
qdimacs_list, unsat = _apply_unates_to_qdimacs(
161161
qdimacs_list, PosUnate, NegUnate)
162162
if unsat:
@@ -175,6 +175,9 @@ def finish(status):
175175
shutil.copyfile(qdimacs_path, keep_path)
176176
if getattr(args, "verbose", 0) >= 1:
177177
cprint("c [manthan] saved unate-substituted qdimacs:", keep_path)
178+
elif Unates and args.apply_unates == 0:
179+
if args.verbose:
180+
cprint("c [manthan] unates detected; substitution disabled (--apply-unates=0)")
178181

179182
else:
180183
Unates = []
@@ -333,7 +336,13 @@ def finish(status):
333336
shutil.copyfile(errorformula, last_errorformula_path)
334337
cprint("c [manthan] last successful error formula:", last_errorformula_path)
335338
if check == 0:
336-
cprint("c [manthan] error --- ABC network read fail")
339+
errorformula = temp_path(temp_stem + "_errorformula.v")
340+
if args.debug_keep and not os.path.isfile(errorformula):
341+
errorformula = os.path.abspath(temp_stem + "_errorformula.v")
342+
cprint("c [manthan] error --- file_generation_cex failed to read error formula")
343+
cprint("c [manthan] errorformula:", errorformula)
344+
if not args.verbose:
345+
cprint("c [manthan] hint: rerun with --verb=1 to see ABC stderr")
337346
status = "failed"
338347
break
339348
if ret == 0:
@@ -442,6 +451,15 @@ def finish(status):
442451
choices=[0, 1],
443452
help="enable preprocess: 1; disable: 0; default 1",
444453
)
454+
parser.add_argument(
455+
"--apply-unates",
456+
nargs="?",
457+
const=1,
458+
default=1,
459+
type=int,
460+
choices=[0, 1],
461+
help="substitute unates into the spec: 1; disable substitution: 0; default 1",
462+
)
445463
parser.add_argument(
446464
"--multiclass",
447465
nargs="?",

src/repair.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ def repair(repaircnf, ind, Xvar, Yvar, YvarOrder, UniqueVars, Unates, sigma, inp
433433
repaired.append(repairvar)
434434
if args.verbose:
435435
cprint("c [repair] gk formula is UNSAT; creating beta formula")
436+
if not any(abs(lit) == repairvar for lit in clisty):
437+
cprint("c [repair] repaired literal %s missing in core; returning early" % repairvar)
438+
return 0, repairfunctions
436439

437440
beta_terms = []
438441
for x_lit in clistx:
@@ -460,12 +463,7 @@ def repair(repaircnf, ind, Xvar, Yvar, YvarOrder, UniqueVars, Unates, sigma, inp
460463
if y_lit < 0:
461464
beta_terms.append("~o%s" % (y))
462465
else:
463-
beta_terms.append("o%s" % (y))
464-
465-
if not any(abs(lit) == repairvar for lit in clisty):
466-
if args.verbose:
467-
cprint("c [repair] repaired literal %s missing in core; proceeding with core-based repair" % repairvar)
468-
466+
beta_terms.append("o%s" % (y))
469467
if args.verbose >= 2:
470468
cprint("c [repair] Repair function for w%s: %s" % (repairvar, " & ".join(beta_terms)))
471469
repairfunctions[repairvar] = " & ".join(beta_terms) if beta_terms else "1'b1"

0 commit comments

Comments
 (0)