Example #1
0
int main(int argc, char * argv[]) {
    opensmt_init();
    opensmt_context ctx = opensmt_mk_context(qf_nra);
    opensmt_set_precision (ctx, 0.001);
    opensmt_expr x = opensmt_mk_real_var(ctx, "x" , -3.141592, 3.141592);
    opensmt_expr y = opensmt_mk_real_var(ctx, "y" , -3.141592, 3.141592);
    opensmt_expr eq1 = opensmt_mk_eq(ctx, opensmt_mk_sin(ctx, x), opensmt_mk_cos(ctx, y));
    opensmt_assert(ctx, eq1);
    opensmt_result res = opensmt_check(ctx);
    fprintf(stderr, "%s\n\n", res == l_false ? "unsat" : "sat");
    if (res == l_true) {
        double const x_lb = opensmt_get_lb(ctx, x);
        double const x_ub = opensmt_get_ub(ctx, x);
        fprintf(stderr, "x = [%f, %f]\n", x_lb, x_ub);
        double const y_lb = opensmt_get_lb(ctx, y);
        double const y_ub = opensmt_get_ub(ctx, y);
        fprintf(stderr, "y = [%f, %f]\n", y_lb, y_ub);
    }

    opensmt_expr eq2 = opensmt_mk_eq(ctx, opensmt_mk_tan(ctx, x), opensmt_mk_sin(ctx, y));
    opensmt_assert(ctx, eq2);
    res = opensmt_check(ctx);
    fprintf(stderr, "%s\n\n", res == l_false ? "unsat" : "sat");
    if (res == l_true) {
        double const x_lb = opensmt_get_lb(ctx, x);
        double const x_ub = opensmt_get_ub(ctx, x);
        fprintf(stderr, "x = [%f, %f]\n", x_lb, x_ub);
        double const y_lb = opensmt_get_lb(ctx, y);
        double const y_ub = opensmt_get_ub(ctx, y);
        fprintf(stderr, "y = [%f, %f]\n", y_lb, y_ub);
    }
    opensmt_del_context(ctx);
    return 0;
}
Example #2
0
// Test Memory Leaks
int main(int argc, char * argv[]) {
    int i = 0;
    opensmt_init();
    opensmt_context ctx = opensmt_mk_context(qf_nra);
    opensmt_set_precision (ctx, 0.0000001);
    opensmt_expr x = opensmt_mk_real_var(ctx, "a" , 0.0, 1.0);
    opensmt_expr point1 = opensmt_mk_num(ctx, 0.1);
    opensmt_expr point9 = opensmt_mk_num(ctx, 0.9);
    opensmt_expr leq = opensmt_mk_leq(ctx, x, point1);
    opensmt_expr geq = opensmt_mk_leq(ctx, x, point9);
    opensmt_expr list[2] = {geq, leq};
    opensmt_expr orr = opensmt_mk_or(ctx, list, 2);
    opensmt_push(ctx);
    opensmt_assert(ctx, orr);
    opensmt_result res = opensmt_check( ctx );
    /* printf( "%s\n\n", res == l_false ? "unsat" : "sat" ); */
    /* fprintf(stderr, "=============\nbefore pop 2\n============\n"); */
    opensmt_pop(ctx);
    /* fprintf(stderr, "=============\nafter  pop 2\n============\n"); */
    opensmt_expr andd = opensmt_mk_and(ctx, list, 2);
    opensmt_assert(ctx, andd);
    opensmt_result res2 = opensmt_check( ctx );
    /* fprintf( stderr, "6\n"); */
    /* printf( "%s\n\n", res2 == l_false ? "unsat" : "sat" ); */
    /* fprintf( stderr, "7\n"); */
    opensmt_del_context(ctx);
    return 0;
}
Example #3
0
int main(int argc, char * argv[]) {
    opensmt_init();
    opensmt_context ctx = opensmt_mk_context(qf_nra);
    opensmt_expr x = opensmt_mk_real_var(ctx, "x" , 0.0, 1.0);
    opensmt_expr y = opensmt_mk_real_var(ctx, "y" , 0.0, 1.0);
    opensmt_expr ite = opensmt_mk_ite(ctx, opensmt_mk_gt(ctx, x, opensmt_mk_num(ctx, 0.4)),
                                      opensmt_mk_num(ctx, 0.3),
                                      opensmt_mk_num(ctx, 0.4));
    opensmt_expr eq = opensmt_mk_eq(ctx, y, ite);
    opensmt_assert( ctx, eq);
    opensmt_result res = opensmt_check(ctx);
    fprintf(stderr, "%s\n\n", res == l_false ? "unsat" : "sat");
    if (res == l_true) {
        print_sol(ctx, x, y);
    }
    fprintf(stderr, "Deleting context\n");
    opensmt_del_context(ctx);
    return 0;
}
Example #4
0
int main() {
    opensmt_init();
    opensmt_context ctx = opensmt_mk_context(qf_nra);
    opensmt_set_precision (ctx, 0.001);

    // Creating Exist Real variables
    opensmt_expr x = opensmt_mk_real_var(ctx, "x" , 0, 8);
    // Creating Forall Real variables
    opensmt_expr y = opensmt_mk_forall_real_var(ctx, "y" , 0, 8.0);

    // constants
    opensmt_expr two = opensmt_mk_num(ctx, 2.0);
    opensmt_expr five = opensmt_mk_num(ctx, 5.0);
    opensmt_expr nine = opensmt_mk_num(ctx, 9.0);

    // circle1 := (x-2)^2 + (y-2)^2 <= 9
    opensmt_expr circle1 =
        opensmt_mk_leq(ctx,
                       opensmt_mk_plus_2(ctx,
                                         opensmt_mk_pow(ctx, opensmt_mk_minus(ctx, x, two), two),
                                         opensmt_mk_pow(ctx, opensmt_mk_minus(ctx, y, two), two)),
                       nine);
    // circle2 := (x-5)^2 + (y-5)^2 <= 9
    opensmt_expr circle2 =
        opensmt_mk_leq(ctx,
                       opensmt_mk_plus_2(ctx,
                                         opensmt_mk_pow(ctx, opensmt_mk_minus(ctx, x, five), two),
                                         opensmt_mk_pow(ctx, opensmt_mk_minus(ctx, y, five), two)),
                       nine);

    opensmt_expr vars[] = {y};
    opensmt_expr formula = opensmt_mk_forall(ctx, vars, 1,
                                             opensmt_mk_or_2(ctx, circle1, circle2));

    opensmt_assert(ctx, formula);
    opensmt_result res = opensmt_check(ctx);
    fprintf(stderr, "%s\n\n", res == l_false ? "unsat" : "sat");
    if (res == l_true) {
        print_sol(ctx, "x", x);
    }

    // Deleting context
    fprintf(stderr, "Deleting context\n");
    opensmt_del_context(ctx);

    return 0;
}