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; }
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; }
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; }
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; }