Skip to content

Commit

Permalink
Merge pull request #13 from martinjonas/dev
Browse files Browse the repository at this point in the history
Merge Q3B 1.0
  • Loading branch information
martinjonas authored Feb 7, 2019
2 parents dc77ac2 + ef38338 commit 10b19ad
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace std;
using namespace z3;
using namespace antlr4;

const std::string version = "0.9 dev";
const std::string version = "1.0";

void print_usage()
{
Expand Down Expand Up @@ -180,6 +180,11 @@ int main(int argc, char* argv[])

std::ifstream stream;
stream.open(filename);
if (!stream.good())
{
std::cout << "(error \"failed to open file '" << filename << "'\")" << std::endl;
return 1;
}

ANTLRInputStream input(stream);
SMTLIBv2Lexer lexer(&input);
Expand Down
11 changes: 11 additions & 0 deletions lib/SMTLIBInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,17 @@ antlrcpp::Any SMTLIBInterpreter::visitCommand(SMTLIBv2Parser::CommandContext* co
}
std::cout << ")" << std::endl;
}
else if (command->cmd_getValue())
{
std::cout << "(" << std::endl;
for (const auto& t : command->term())
{
z3::expr termExpr = visitTerm(t);
z3::expr value = Solver::substituteModel(termExpr, model).simplify();
std::cout << " (" << termExpr << " " << value << ")" << std::endl;
}
std::cout << ")" << std::endl;
}
else if (command->cmd_defineFun())
{
visitFunction_def(command->function_def());
Expand Down
2 changes: 1 addition & 1 deletion lib/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ Result Solver::runWithOverApproximations(ExprToBDDTransformer &transformer)
return runWithApproximations(transformer, OVERAPPROXIMATION);
}

z3::expr Solver::substituteModel(z3::expr& e, const std::map<std::string, std::vector<bool>>& model) const
z3::expr Solver::substituteModel(z3::expr& e, const std::map<std::string, std::vector<bool>>& model)
{
auto &context = e.ctx();
z3::expr_vector consts(context);
Expand Down
4 changes: 2 additions & 2 deletions lib/Solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Solver

static std::mutex m_z3context;
static std::atomic<bool> resultComputed;

static z3::expr substituteModel(z3::expr&, const std::map<std::string, std::vector<bool>>&);
private:
Config config;

Expand All @@ -43,8 +45,6 @@ class Solver
static std::mutex m;
static std::mutex m_res;
static std::condition_variable doneCV;

z3::expr substituteModel(z3::expr&, const std::map<std::string, std::vector<bool>>&) const;
};

#endif // BDDSOLVER_H

0 comments on commit 10b19ad

Please sign in to comment.