Пример #1
0
 Z3_sort Z3_API Z3_mk_real_sort(Z3_context c) {
     Z3_TRY;
     LOG_Z3_mk_real_sort(c);
     RESET_ERROR_CODE();
     Z3_sort r = of_sort(mk_c(c)->m().mk_sort(mk_c(c)->get_arith_fid(), REAL_SORT));
     RETURN_Z3(r);
     Z3_CATCH_RETURN(nullptr);
 }
Пример #2
0
 Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, unsigned __int64 size) {
     Z3_TRY;
     LOG_Z3_mk_finite_domain_sort(c, name, size);
     RESET_ERROR_CODE();
     sort* s = mk_c(c)->datalog_util().mk_sort(to_symbol(name), size);
     mk_c(c)->save_ast_trail(s);
     RETURN_Z3(of_sort(s));
     Z3_CATCH_RETURN(0);
 }
Пример #3
0
 Z3_sort Z3_API Z3_mk_string_sort(Z3_context c) {
     Z3_TRY;
     LOG_Z3_mk_string_sort(c);
     RESET_ERROR_CODE();
     sort* ty = mk_c(c)->sutil().str.mk_string_sort();
     mk_c(c)->save_ast_trail(ty);
     RETURN_Z3(of_sort(ty));
     Z3_CATCH_RETURN(0);
 }
Пример #4
0
 Z3_sort Z3_API Z3_mk_re_sort(Z3_context c, Z3_sort domain) {
     Z3_TRY;
     LOG_Z3_mk_re_sort(c, domain);
     RESET_ERROR_CODE();
     sort * ty =  mk_c(c)->sutil().re.mk_re(to_sort(domain));
     mk_c(c)->save_ast_trail(ty);
     RETURN_Z3(of_sort(ty));
     Z3_CATCH_RETURN(0);
 }
Пример #5
0
 Z3_sort Z3_API Z3_mk_array_sort(Z3_context c, Z3_sort domain, Z3_sort range) {
     Z3_TRY;
     LOG_Z3_mk_array_sort(c, domain, range);
     RESET_ERROR_CODE();  
     parameter params[2]  = { parameter(to_sort(domain)), parameter(to_sort(range)) };
     sort * ty =  mk_c(c)->m().mk_sort(mk_c(c)->get_array_fid(), ARRAY_SORT, 2, params);
     mk_c(c)->save_ast_trail(ty);
     RETURN_Z3(of_sort(ty));
     Z3_CATCH_RETURN(0);
 }
Пример #6
0
 Z3_sort Z3_API Z3_mk_fpa_rounding_mode_sort(Z3_context c) {
     Z3_TRY;
     LOG_Z3_mk_fpa_rounding_mode_sort(c);
     RESET_ERROR_CODE();
     api::context * ctx = mk_c(c);
     sort * s = ctx->fpautil().mk_rm_sort();
     mk_c(c)->save_ast_trail(s);
     RETURN_Z3(of_sort(s));
     Z3_CATCH_RETURN(nullptr);
 }
Пример #7
0
 Z3_sort Z3_API Z3_model_get_sort(Z3_context c, Z3_model m, unsigned i) {
     Z3_TRY;
     LOG_Z3_model_get_sort(c, m, i);
     RESET_ERROR_CODE();
     if (i >= to_model_ref(m)->get_num_uninterpreted_sorts()) {
         SET_ERROR_CODE(Z3_IOB, nullptr);
         RETURN_Z3(nullptr);
     }
     sort * s = to_model_ref(m)->get_uninterpreted_sort(i);
     RETURN_Z3(of_sort(s));
     Z3_CATCH_RETURN(nullptr);
 }
Пример #8
0
 Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits) {
     Z3_TRY;
     LOG_Z3_mk_fpa_sort(c, ebits, sbits);
     RESET_ERROR_CODE();
     if (ebits < 2 || sbits < 3) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
     }
     api::context * ctx = mk_c(c);
     sort * s = ctx->fpautil().mk_float_sort(ebits, sbits);
     ctx->save_ast_trail(s);
     RETURN_Z3(of_sort(s));
     Z3_CATCH_RETURN(nullptr);
 }
Пример #9
0
 Z3_sort Z3_API Z3_get_quantifier_bound_sort(Z3_context c, Z3_ast a, unsigned i) {
     Z3_TRY;
     LOG_Z3_get_quantifier_bound_sort(c, a, i);
     RESET_ERROR_CODE();
     ast * _a = to_ast(a);
     if (_a->get_kind() == AST_QUANTIFIER) {
         Z3_sort r = of_sort(to_quantifier(_a)->get_decl_sort(i));
         RETURN_Z3(r);
     }
     else {
         SET_ERROR_CODE(Z3_SORT_ERROR);
         RETURN_Z3(0);
     }
     Z3_CATCH_RETURN(0);
 }
 Z3_sort Z3_API Z3_get_smtlib_sort(Z3_context c, unsigned i) {
     Z3_TRY;
     LOG_Z3_get_smtlib_sort(c, i);
     RESET_ERROR_CODE(); 
     if (mk_c(c)->m_smtlib_parser) {
         mk_c(c)->extract_smtlib_parser_decls();
         if (i < mk_c(c)->m_smtlib_parser_sorts.size()) {
             sort* s = mk_c(c)->m_smtlib_parser_sorts[i];
             mk_c(c)->save_ast_trail(s);
             RETURN_Z3(of_sort(s));
         }
         else {
             SET_ERROR_CODE(Z3_IOB);
         }
     }
     else {
         SET_ERROR_CODE(Z3_NO_PARSER);
     }
     RETURN_Z3(0);
     Z3_CATCH_RETURN(0);
 }
Пример #11
0
 Z3_sort Z3_API Z3_get_relation_column(Z3_context c, Z3_sort s, unsigned col) {
     Z3_TRY;
     LOG_Z3_get_relation_column(c, s, col);
     RESET_ERROR_CODE();
     sort * r = to_sort(s);
     if (Z3_get_sort_kind(c, s) != Z3_RELATION_SORT) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(0);
     }
     if (col >= r->get_num_parameters()) {
         SET_ERROR_CODE(Z3_IOB);
         RETURN_Z3(0);
     }
     parameter const& p = r->get_parameter(col);
     if (!p.is_ast() || !is_sort(p.get_ast())) {
         UNREACHABLE();
         warning_msg("Sort parameter expected at %d", col);
         SET_ERROR_CODE(Z3_INTERNAL_FATAL);
         RETURN_Z3(0);
     }
     Z3_sort res = of_sort(to_sort(p.get_ast()));
     RETURN_Z3(res);
     Z3_CATCH_RETURN(0);
 }
Пример #12
0
    Z3_ast Z3_API Z3_mk_quantifier_const_ex(Z3_context c, 
                                            Z3_bool is_forall,
                                            unsigned weight,
                                            Z3_symbol quantifier_id,
                                            Z3_symbol skolem_id,
                                            unsigned num_bound,
                                            Z3_app const bound[],
                                            unsigned num_patterns,
                                            Z3_pattern const patterns[],
                                            unsigned num_no_patterns,
                                            Z3_ast const no_patterns[],
                                            Z3_ast body) {
        Z3_TRY;
        LOG_Z3_mk_quantifier_const_ex(c, is_forall, weight, quantifier_id, skolem_id, num_bound, bound, num_patterns, patterns,
                                      num_no_patterns, no_patterns, body);
        RESET_ERROR_CODE();
        svector<Z3_symbol> names;
        svector<Z3_sort> types;
        ptr_vector<expr> bound_asts;
        if (num_patterns > 0 && num_no_patterns > 0) {
            SET_ERROR_CODE(Z3_INVALID_USAGE);
            RETURN_Z3(0);
        }
        if (num_bound == 0) {
            SET_ERROR_CODE(Z3_INVALID_USAGE);
            RETURN_Z3(0);            
        }
        for (unsigned i = 0; i < num_bound; ++i) {
            app* a = to_app(bound[i]);
            if (a->get_kind() != AST_APP) {
                SET_ERROR_CODE(Z3_INVALID_ARG);
                RETURN_Z3(0);
            }
            symbol s(to_app(a)->get_decl()->get_name());
            names.push_back(of_symbol(s));
            types.push_back(of_sort(mk_c(c)->m().get_sort(a)));
            bound_asts.push_back(a);
            if (a->get_family_id() != null_family_id || a->get_num_args() != 0) {
                SET_ERROR_CODE(Z3_INVALID_ARG);
                RETURN_Z3(0);
            }
        }
        // Abstract patterns
        svector<Z3_pattern> _patterns;
        expr_ref_vector pinned(mk_c(c)->m());
        for (unsigned i = 0; i < num_patterns; ++i) {
            expr_ref result(mk_c(c)->m());
            app* pat = to_pattern(patterns[i]);
            SASSERT(mk_c(c)->m().is_pattern(pat));
            expr_abstract(mk_c(c)->m(), 0, num_bound, bound_asts.c_ptr(), pat, result);
            SASSERT(result.get()->get_kind() == AST_APP);        
            pinned.push_back(result.get());
            SASSERT(mk_c(c)->m().is_pattern(result.get()));
            _patterns.push_back(of_pattern(result.get()));
        }
        svector<Z3_ast> _no_patterns;
        for (unsigned i = 0; i < num_no_patterns; ++i) {
            expr_ref result(mk_c(c)->m());
            if (!is_app(to_expr(no_patterns[i]))) {
                SET_ERROR_CODE(Z3_INVALID_ARG);
                RETURN_Z3(0);
            }
            app* pat = to_app(to_expr(no_patterns[i]));
            expr_abstract(mk_c(c)->m(), 0, num_bound, bound_asts.c_ptr(), pat, result);
            SASSERT(result.get()->get_kind() == AST_APP);        
            pinned.push_back(result.get());
            _no_patterns.push_back(of_ast(result.get()));
        }
        expr_ref abs_body(mk_c(c)->m());
        expr_abstract(mk_c(c)->m(), 0, num_bound, bound_asts.c_ptr(), to_expr(body), abs_body);

        Z3_ast result = mk_quantifier_ex_core(c, is_forall, weight, 
                                              quantifier_id,
                                              skolem_id,
                                              num_patterns, _patterns.c_ptr(), 
                                              num_no_patterns, _no_patterns.c_ptr(),
                                              names.size(), types.c_ptr(), names.c_ptr(), 
                                              of_ast(abs_body.get()));
        RETURN_Z3(result);
        Z3_CATCH_RETURN(0);
    }