繁体   English   中英

如何从Z3 smtlib2公式获取声明?

[英]How to get the declaration from a Z3 smtlib2 formula?

我想使用C ++ API使用Z3进行增量求解。

2012年已经有一些关于此的旧问题:

Z3 4.0 Z3_parse_smtlib2_string

Z3 4.0:获取完整的模型

Z3 4.3.1 C-API parse_smtlib2_string:从哪里获取声明?

我想知道新的Z3版本4.4.2是否有解决方案。

基本上我想做的是这样的:

char *decl = "(declare-const p0 Bool)";
char *assert = "(assert(= p0 true))";

Z3_ast ast = Z3_parse_smtlib2_string(ctx, (Z3_string)decl, 0, 0, 0, 0, 0, 0);
z3::expr eq1(ctx, ast);
solver.add(eq1);

//extract declarations from the solver, ctx or ast
...

//Parse the assert with the previous declarations
Z3_ast ast = Z3_parse_smtlib2_string(ctx, (Z3_string)assert, 0, 0, 0, num_decls, symbols, decl_list);
z3::expr eq2(ctx, ast);
solver.add(eq2);
solver.check();

但是我不知道如何获取声明。 我尝试使用Z3_get_smtlib_num_decls,但它仅与smtlib1一起使用,而不与smtlib2一起使用。

有没有办法检索声明? 将来会实现Z3_get_smtlib2_num_decls函数吗?

感谢您的时间。

就像Nikolaj在Z3 4.3.1中所说的那样, C-API parse_smtlib2_string:从哪里获取声明? ,则必须遍历表达式(断言)以收集声明。 tptp示例的链接已断开,但该文件随附Z3作为examples/tptp/tptp5.cpp (请参见collect_decls函数)。

另请参阅: 显示从SMT-LIB2文件解析的声明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM