Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when constant = bool in diagram #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,13 @@ def _read_first_order_structure(struct: FirstOrderStructure) -> Tuple[
e = e if ans else syntax.Not(e)
rels[R].append(e)
for C, c in struct.const_interps.items():
e = syntax.Eq(syntax.Id(C.name), syntax.Id(c))
# There are two cases, c is either another Id or a constant
# Constants are produced as dicts of the form {(): bool(ans)}
# in translator.py:Z3Translator:_old_model_to_trace
if isinstance(c, dict) and () in c:
e = syntax.Eq(syntax.Id(C.name), syntax.Bool(c[()]))
else:
e = syntax.Eq(syntax.Id(C.name), syntax.Id(c))
consts[C] = e
for F, fl in struct.func_interps.items():
funcs[F] = []
Expand Down Expand Up @@ -435,8 +441,14 @@ def const_subst(self) -> Dict[syntax.Id, syntax.Id]:
ans = {}
for c, e in self.consts.items():
assert isinstance(e, syntax.BinaryExpr) and e.op == 'EQUAL' and \
isinstance(e.arg1, syntax.Id) and isinstance(e.arg2, syntax.Id)
ans[e.arg2] = e.arg1
isinstance(e.arg1, syntax.Id)
if isinstance(e.arg2, syntax.Id):
ans[e.arg2] = e.arg1
else:
# Sometimes we get a boolean on the RHS of the equality,
# and there is no need to substitute it.
# TODO: should we then do ans[e.arg1] = e.arg2?
pass
return ans

def conjuncts(self) -> Iterable[Tuple[_RelevantDecl, int, Expr]]:
Expand Down