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

assertion violation in model generation #4848

Closed
joe-hauns opened this issue Dec 4, 2020 · 0 comments
Closed

assertion violation in model generation #4848

joe-hauns opened this issue Dec 4, 2020 · 0 comments

Comments

@joe-hauns
Copy link
Contributor

I experienced an assertion violation (Debug) /segfault (Release) when generating a model for uninterpreted sorts with using the c++ api.

TL;DR: Reproduce with

#include <iostream>
#include <z3++.h>

using namespace std;
using namespace z3;

int main() {
  context ctxt;
#if 1
  auto srt = ctxt.uninterpreted_sort(ctxt.int_symbol(1));
#else
  auto srt = ctxt.uninterpreted_sort("alpha");
#endif 
  solver slvr(ctxt);

  auto a = ctxt.constant("a", srt);
  auto b = ctxt.constant("b", srt);

  slvr.add(a == b);
  slvr.check();
  
  auto model = slvr.get_model(); // <- assertion violation here
                                 // File: /path/to/z3/src/util/symbol.h
                                 // Line: 97
                                 // !is_numerical()
  cout << "got model." << endl;
  cout << "serializing:" << endl;
  cout << model << endl;
}

The issue is that when generating new names for new domain elements for the uninterpreted sort it is assumed that sorts have string identifiers, in order to serialize the sort name. The c++ api allows for non-string identifiers though.

...
        /**
           \brief create an uninterpreted sort with the name given by the string or symbol.
         */
        sort uninterpreted_sort(char const* name);
        sort uninterpreted_sort(symbol const& name);
...

Tested this issue with master 6d427d9 in Debug build, and some older commit in Release mode.

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

No branches or pull requests

1 participant