本文整理汇总了C++中Polynomial::toZ3expr方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::toZ3expr方法的具体用法?C++ Polynomial::toZ3expr怎么用?C++ Polynomial::toZ3expr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::toZ3expr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: multiImply
bool Polynomial::multiImply(const Polynomial* e1, int e1_num, const Polynomial& e2) {
#if (linux || __MACH__)
#ifdef __PRT_QUERY
std::cout << "-------------Multi-Imply solving-------------\n";
#endif
z3::config cfg;
cfg.set("auto_config", true);
z3::context c(cfg);
z3::expr hypo = e1[0].toZ3expr(NULL, c);
for (int i = 1; i < e1_num; i++) {
hypo = hypo && e1[i].toZ3expr(NULL, c);;
}
z3::expr conc = e2.toZ3expr(NULL, c);
//std::cout << "hypo: " << hypo << std::endl;
//std::cout << "conc: " << conc << std::endl;
z3::expr query = implies(hypo, conc);
#ifdef __PRT_QUERY
std::cout << "Query : " << query << std::endl;
std::cout << "Answer: ";
#endif
z3::solver s(c);
s.add(!query);
z3::check_result ret = s.check();
if (ret == unsat) {
#ifdef __PRT_QUERY
std::cout << "True" << std::endl;
#endif
return true;
}
else {
#ifdef __PRT_QUERY
std::cout << "False" << std::endl;
#endif
return false;
}
#endif
return false;
}
示例2: uniImply
bool Polynomial::uniImply(const Polynomial& e2) {
#if (linux || __MACH__)
#ifdef __PRT_QUERY
std::cout << BLUE << "-------------uni-Imply solving-------------\n" << NORMAL;
std::cout << RED << *this << " ==> " << e2 << std::endl << NORMAL;
#endif
z3::config cfg;
cfg.set("auto_config", true);
z3::context c(cfg);
z3::expr hypo = this->toZ3expr(NULL, c);
z3::expr conc = e2.toZ3expr(NULL, c);
z3::expr query = implies(hypo, conc);
#ifdef __PRT_QUERY
std::cout << "\nhypo: " << hypo << std::endl;
std::cout << "conc: " << conc << std::endl;
std::cout << BLUE << "Query : " << query << std::endl << NORMAL;
#endif
z3::solver s(c);
s.add(!query);
z3::check_result ret = s.check();
if (ret == unsat) {
#ifdef __PRT_QUERY
std::cout << "Answer: UNSAT\n";
#endif
return true;
}
#ifdef __PRT_QUERY
std::cout << "Answer: SAT\n";
#endif
#endif
return false;
}