예제 #1
0
파일: zenna_02.c 프로젝트: clhuang/dreal3
// 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;
}
예제 #2
0
int main(int argc, char * argv[]) {
    // Creating context
    fprintf(stderr, "Creating context\n");
    opensmt_init();
    opensmt_context ctx = opensmt_mk_context(qf_nra);

    // Setting verbosity
    opensmt_set_verbosity(ctx, 4);

    // Creating integer variables
    fprintf(stderr, "Creating some integer variables\n");
    opensmt_expr x = opensmt_mk_int_var(ctx, "x" , -10, 10);
    opensmt_expr y = opensmt_mk_int_var(ctx, "y" , -10, 10);

    // numbers -- 2, 7, 10
    opensmt_expr num2  = opensmt_mk_num_from_string(ctx, "2");
    opensmt_expr num7  = opensmt_mk_num_from_string(ctx, "7");
    opensmt_expr num10 = opensmt_mk_num_from_string(ctx, "10");

    // t1 = x > 2
    opensmt_expr t1 = opensmt_mk_gt(ctx, x, num2);
    
    // t2 = y < 10
    opensmt_expr t2 = opensmt_mk_lt(ctx, y, num10);


    // t3 = 2 * y
    opensmt_expr subarray1[2] = {num2, y};
    opensmt_expr t3 = opensmt_mk_times(ctx, subarray1, 2);

    // t4 = x + t3 == 7
    opensmt_expr subarray2[2] = {x, t3};
    opensmt_expr t4 = opensmt_mk_eq(ctx, opensmt_mk_plus(ctx, subarray2, 2), num7);

    // t5 = t1 /\ t2 /\ t4
    opensmt_expr subarray3[3] = {t1, t2, t4};
    opensmt_expr t5 = opensmt_mk_and(ctx, subarray3, 3);

    opensmt_assert(ctx, t5);

    // Checking for consistency
    fprintf(stderr, "\nChecking for consistency: ");
    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);
    }

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

    return 0;
}