Skip to content

Commit

Permalink
return string model from solve()
Browse files Browse the repository at this point in the history
  • Loading branch information
daejunpark committed Oct 9, 2024
1 parent 307bf84 commit ad5bd4c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/halmos/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,10 +975,6 @@ class GenModelArgs:
dump_dirname: str | None = None


def copy_model(model: ModelRef) -> dict:
return {decl: model[decl] for decl in model}


def parse_unsat_core(output) -> list | None:
# parsing example:
# unsat
Expand Down Expand Up @@ -1072,7 +1068,7 @@ def solve(
result = solver.check(*ids)
else:
result = solver.check()
model = copy_model(solver.model()) if result == sat else None
model = to_str_model(solver.model(), args.print_full_model) if result == sat else None
unsat_core = (
[str(core) for core in solver.unsat_core()]
if args.cache_solver and result == unsat
Expand Down Expand Up @@ -1171,7 +1167,6 @@ def package_result(
model = f"see {model}"
else:
is_valid = is_model_valid(model)
model = to_str_model(model, args.print_full_model)

return ModelWithContext(model, is_valid, idx, result, None)

Expand Down Expand Up @@ -1201,7 +1196,7 @@ def is_model_valid(model: AnyModel) -> bool:
def to_str_model(model: ModelRef, print_full_model: bool) -> StrModel:
def select(var):
name = str(var)
return name.startswith("p_") or name.startswith("halmos_")
return name.startswith("p_") or name.startswith("halmos_") or name.startswith("f_evm_")

select_model = filter(select, model) if not print_full_model else model
return {str(decl): stringify(str(decl), model[decl]) for decl in select_model}
Expand Down

0 comments on commit ad5bd4c

Please sign in to comment.