Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何确定z3_ast是否对应于子句?_Z3 - Fatal编程技术网

如何确定z3_ast是否对应于子句?

如何确定z3_ast是否对应于子句?,z3,Z3,我使用的是带有c api的Z3。是否有可能找出给定的Z3 ast变量是否对应于下面的或\u b1\u b2子句 Z3_ast or_b1_b2 = mk_binary_or(c,mk_bool_var(c,"b1"),mk_bool_var(c,"b2")); 谢谢是的,Z3API提供了几个用于检查/遍历AST的函数。 Z3API是最简单的,但它具有编写函数所必需的所有成分,例如:is_propositional_变量、is_literal、以及is_子句。以下是一个例子: // Return

我使用的是带有c api的Z3。是否有可能找出给定的
Z3 ast
变量是否对应于下面的
或\u b1\u b2
子句

Z3_ast or_b1_b2 = mk_binary_or(c,mk_bool_var(c,"b1"),mk_bool_var(c,"b2"));

谢谢

是的,Z3API提供了几个用于检查/遍历AST的函数。 Z3API是最简单的,但它具有编写函数所必需的所有成分,例如:
is_propositional_变量
is_literal
、以及
is_子句
。以下是一个例子:

// Return true if the given ast is an application of the given kind
int is_app_of(Z3_context c, Z3_ast a, Z3_decl_kind k) {
   if (Z3_get_ast_kind(c, a) != Z3_APP_AST) 
       return 0;
   return Z3_get_decl_kind(c, Z3_get_app_decl(c, Z3_to_app(c, a))) == k;
}

// Return true if the given ast is an OR.
int is_or(Z3_context c, Z3_ast a) {
    return is_app_of(c, a, Z3_OP_OR);
}

// Return true if the given ast is a NOT.
int is_not(Z3_context c, Z3_ast a) {
    return is_app_of(c, a, Z3_OP_NOT);
}

// Return true if the given ast is an application of an unintepreted symbol.
int is_uninterp(Z3_context c, Z3_ast a) {
    return is_app_of(c, a, Z3_OP_UNINTERPRETED);
}

// Return true if the given ast is a uninterpreted constant.
// That is, it is application (with zero arguments) of an uninterpreted symbol.
int is_uninterp_const(Z3_context c, Z3_ast a) {
    return is_uninterp(c, a) && Z3_get_app_num_args(c, Z3_to_app(c, a)) == 0;
}

// Return true if the given ast has Boolean sort (aka type).
int has_bool_sort(Z3_context c, Z3_ast a) {
    return Z3_get_sort_kind(c, Z3_get_sort(c, a)) == Z3_BOOL_SORT;
}

// Return true if the given ast is a "propositional variable".
// That is, it has Boolean sort and it is uninterpreted.
int is_propositional_var(Z3_context c, Z3_ast a) {
    return is_uninterp_const(c, a) && has_bool_sort(c, a);
}

// Return true if the given ast is a "literal".
// That is, it is a "propositional variable" or the negation of a propositional variable.
int is_literal(Z3_context c, Z3_ast a) {
    if (is_propositional_var(c, a))
        return 1;
    if (is_not(c, a))
        return is_propositional_var(c, Z3_get_app_arg(c, Z3_to_app(c, a), 0));
    return 0;
}

// Return true if the given ast is a "clause".
// That is, it is a literal, or a disjuction (OR) of literals.
int is_clause(Z3_context c, Z3_ast a) {
    if (is_literal(c, a)) {
        return 1; // unit clause
    }
    else if (is_or(c, a)) {
        unsigned num;
        unsigned i;
        num = Z3_get_app_num_args(c, Z3_to_app(c, a));
        for (i = 0; i < num; i++) {
            if (!is_literal(c, Z3_get_app_arg(c, Z3_to_app(c, a), i)))
                return 0;
        }
        return 1;
    }
    else {
        return 0;
    }
}
//如果给定ast是给定类型的应用程序,则返回true
int是(上下文c,上下文a,上下文k)的应用程序{
如果(Z3_get_ast_kind(c,a)!=Z3_APP_ast)
返回0;
返回Z3_get_decl_kind(c,Z3_get_app_decl(c,Z3_to_app(c,a))==k;
}
//如果给定的ast是OR,则返回true。
int是_或(Z3_上下文c,Z3_ast a){
返回值为(c、a、Z3或OP);
}
//如果给定的ast不是,则返回true。
int不是(Z3_上下文c,Z3_ast a){
返回值为(c,a,Z3,OP,NOT);
}
//如果给定的ast是一个非预测符号的应用程序,则返回true。
int是untrp(Z3\u上下文c,Z3\u ast a){
返回为(c、a、Z3)的应用(未解释);
}
//如果给定的ast是未解释的常量,则返回true。
//也就是说,它是一个未解释符号的应用程序(具有零参数)。
int是一个常数(Z3\u上下文c,Z3\u ast a){
返回值为_untrp(c,a)&&Z3_get_app_num_args(c,Z3_to_app(c,a))==0;
}
//如果给定ast具有布尔排序(aka类型),则返回true。
int具有布尔排序(Z3\u上下文c,Z3\u ast a){
返回Z3_get_sort_kind(c,Z3_get_sort(c,a))==Z3_BOOL_sort;
}
//如果给定的ast是“命题变量”,则返回true。
//也就是说,它有布尔排序,并且不令人惊讶。
int是命题变量(Z3,Z3,asta){
返回为常量(c,a)和排序(c,a);
}
//如果给定的ast是“文字”,则返回true。
//也就是说,它是一个“命题变量”或命题变量的否定。
int是文本(Z3\u上下文c,Z3\u ast a){
if(是命题变量(c,a))
返回1;
如果(不是(c,a))
返回值是命题变量(c,Z3,get,app,arg(c,Z3,to,app(c,a),0));
返回0;
}
//如果给定的ast是“子句”,则返回true。
//也就是说,它是一个文字,或文字的一个分离(或)。
int is_子句(Z3_上下文c,Z3_ast a){
如果(是字面的(c,a)){
return 1;//unit子句
}
否则如果(是_或(c,a)){
无符号数;
未签名的i;
num=Z3_get_app_num_args(c,Z3_to_app(c,a));
对于(i=0;i