Exemplo n.º 1
0
int main() {
/* (assert(= x_0 0)) */
/* (assert(= x_18 (sin x_1))) */
/* (assert(= x_21 (cos x_2))) */
/* (assert(= x_22 (+ x_21 x_18))) */
    opensmt_init();
    opensmt_context ctx = opensmt_mk_context(qf_nra);
    opensmt_set_verbosity(ctx, 10);

    opensmt_expr x_0  = opensmt_mk_unbounded_real_var(ctx, "x_0");
    opensmt_expr x_1  = opensmt_mk_unbounded_real_var(ctx, "x_1");
    opensmt_expr x_18 = opensmt_mk_unbounded_real_var(ctx, "x_18");
    opensmt_expr x_21 = opensmt_mk_unbounded_real_var(ctx, "x_21");
    opensmt_expr x_22 = opensmt_mk_unbounded_real_var(ctx, "x_22");
    opensmt_expr zero = opensmt_mk_num(ctx, 0.0);
    opensmt_expr assert_1 = opensmt_mk_eq(ctx,  x_0, zero);
    opensmt_expr assert_2 = opensmt_mk_eq(ctx, x_18, opensmt_mk_sin(ctx, x_1));
    opensmt_expr assert_3 = opensmt_mk_eq(ctx, x_21, opensmt_mk_cos(ctx, x_1));
    opensmt_expr assert_4 = opensmt_mk_eq(ctx, x_22, opensmt_mk_plus_2(ctx, x_21, x_18));
    opensmt_assert(ctx, assert_1);
    opensmt_assert(ctx, assert_2);
    opensmt_assert(ctx, assert_3);
    opensmt_assert(ctx, assert_4);
    opensmt_result res = opensmt_check( ctx );
    printf( "%s\n\n", res == l_false ? "unsat" : "sat" );
    opensmt_del_context(ctx);
    return 0;
}
Exemplo n.º 2
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;
}