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

Solver cannot deal with string literals #20

Open
seizethedave opened this issue Jan 23, 2018 · 2 comments
Open

Solver cannot deal with string literals #20

seizethedave opened this issue Jan 23, 2018 · 2 comments
Labels

Comments

@seizethedave
Copy link
Member

A query like this:

WordBag:
    state words : Set<String>

    query containsPassword()
        "password" in words

produces this error when run in synthesis mode:

.
.
.
  File "/Users/dgrant/Dev/cozy/cozy/cozy/solver.py", line 617, in visit_EBinOp
    v1 = self.visit(e.e1, env)
  File "/Users/dgrant/Dev/cozy/cozy/cozy/solver.py", line 824, in visit
    return super().visit(e, *args)
  File "/Users/dgrant/Dev/cozy/cozy/cozy/common.py", line 182, in visit
    return getattr(self, visit_func)(x, *args, **kwargs)
  File "/Users/dgrant/Dev/cozy/cozy/cozy/solver.py", line 431, in visit_EStr
    raise NotImplementedError("cannot encode string literal {}".format(repr(s.val)))
NotImplementedError: cannot encode string literal 'password'

...because Z3 doesn't (currently) deal with strings.

@Calvin-L
Copy link
Collaborator

Calvin-L commented Jan 24, 2018

An easy and correct (although perhaps suboptimal) fix would be for Cozy to automatically transform string literals into uninterpreted extern declarations before starting synthesis.

@mernst
Copy link
Member

mernst commented Oct 25, 2018

Another workaround is to use an extern declaration for a function that compares against a string literal, as in
extern is_issue_tracking(x : String) : Bool = "({x} == \"issue_tracking\")"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants