int test_pp_main(void) { yices_init(); test_pp(build_term()); yices_exit(); return 0; }
int main(void) { yices_init(); test1(); test2(); yices_exit(); return 0; }
int main(void) { uint32_t i; yices_init(); for (i=0; i<NUM_CODES; i++) { test_error(all_codes[i], all_names[i]); } yices_exit(); return 0; }
int main(void) { param_t *p1, *p2; yices_init(); p1 = yices_new_param_record(); printf("Allocated param record %p\n", p1); show_params(p1); p2 = yices_new_param_record(); printf("Allocated param record %p\n", p2); show_params(p2); test_set_params(p2); yices_free_param_record(p2); yices_free_param_record(p1); yices_exit(); return 0; }
int main(void) { ctx_config_t *c1, *c2; yices_init(); c1 = yices_new_config(); printf("Allocated config %p\n", c1); show_config(c1); c2 = yices_new_config(); printf("Allocated config %p\n", c2); show_config(c2); test_logic_configs(c1); test_set_configs(c2); yices_free_config(c2); yices_free_config(c1); yices_exit(); printf("All tests succeeded\n"); return 0; }
int example2_main(void) { type_t real; term_t t, a; int32_t code; context_t *ctx; model_t *mdl; /* * Global initialization: this must called first. */ yices_init(); /* * Create an uninterpreted term of type real and call it "x" */ real = yices_real_type(); t = yices_new_uninterpreted_term(real); code = yices_set_term_name(t, "x"); /* * If code is negative, something went wrong */ if (code < 0) { printf("Error in yices_set_term\n"); yices_print_error(stdout); fflush(stdout); goto done; } /* * Create the atom (x > 0) */ a = yices_arith_gt0_atom(t); /* * Print the atom: */ printf("Atom: "); yices_pp_term(stdout, a, 120, 2, 6); /* * Check that (x > 0) is satisfiable and get a model * - create a context * - assert atom 'a' in this context * - check that the context is satisfiable */ ctx = yices_new_context(NULL); // NULL means use the default configuration code = yices_assert_formula(ctx, a); if (code < 0) { printf("Assert failed: "); yices_print_error(stdout); fflush(stdout); goto done; } switch (yices_check_context(ctx, NULL)) { // NULL means default heuristics case STATUS_SAT: // build the model and print it printf("Satisfiable\n"); mdl = yices_get_model(ctx, true); code = yices_pp_model(stdout, mdl, 120, 100, 0); if (code < 0) { printf("Print model failed: "); yices_print_error(stdout); fflush(stdout); goto done; } // cleanup: delete the model yices_free_model(mdl); break; case STATUS_UNSAT: printf("Unsatisfiable\n"); break; case STATUS_UNKNOWN: printf("Status is unknown\n"); break; case STATUS_IDLE: case STATUS_SEARCHING: case STATUS_INTERRUPTED: case STATUS_ERROR: // these codes should not be returned printf("Bug: unexpected status returned\n"); break; } /* * Delete the context: this is optional since yices_exit * would do it anyway. */ yices_free_context(ctx); done: /* * Global cleanup: free all memory used by Yices */ yices_exit(); return 0; }
int main(int argc, char *argv[]) { char *filename; int32_t code; double time, mem_used; if (argc > 2) { fprintf(stderr, "Usage: %s <filename>\n", argv[0]); exit(YICES_EXIT_USAGE); } if (argc == 2) { // read from file interactive = false; filename = argv[1]; if (init_smt2_file_lexer(&lexer, filename) < 0) { perror(filename); exit(YICES_EXIT_FILE_NOT_FOUND); } } else { // read from stdin interactive = true; init_smt2_stdin_lexer(&lexer); } yices_init(); init_smt2(true, 0, interactive); init_smt2_tstack(&stack); init_parser(&parser, &lexer, &stack); // disable SMT2_CHECK_SAT/PUSH/POP/GET_VALUE tstack_add_op(&stack, SMT2_CHECK_SAT, false, eval_smt2_skip, check_smt2_skip); tstack_add_op(&stack, SMT2_PUSH, false, eval_smt2_skip, check_smt2_skip); tstack_add_op(&stack, SMT2_POP, false, eval_smt2_skip, check_smt2_skip); tstack_add_op(&stack, SMT2_GET_VALUE, false, eval_smt2_skip, check_smt2_skip); // smt2_set_verbosity(100); while (smt2_active()) { if (interactive) { fputs("smt2> ", stdout); fflush(stdout); } code = parse_smt2_command(&parser); if (code < 0) { // syntax error if (interactive) { flush_lexer(&lexer); } else { break; // exit } } fflush(stdout); } // statistics time = get_cpu_time(); mem_used = mem_size() / (1024 * 1024); printf("\nRun time: %.4f s\n", time); printf("Memory used: %.2f MB\n\n", mem_used); fflush(stdout); delete_parser(&parser); close_lexer(&lexer); delete_tstack(&stack); delete_smt2(); yices_exit(); return YICES_EXIT_SUCCESS; }
int main(int argc, char *argv[]) { char *filename; int32_t code; FILE *dump; double time, mem_used; if (argc > 2) { fprintf(stderr, "Usage: %s <filename>\n", argv[0]); exit(YICES_EXIT_USAGE); } if (argc == 2) { // read from file filename = argv[1]; if (init_smt_file_lexer(&lexer, filename) < 0) { perror(filename); exit(YICES_EXIT_FILE_NOT_FOUND); } } else { // read from stdin init_smt_stdin_lexer(&lexer); } yices_init(); init_smt_tstack(&stack); init_parser(&parser, &lexer, &stack); init_benchmark(&bench); code = parse_smt_benchmark(&parser, &bench); if (code == 0) { printf("No syntax error found\n"); } if (benchmark_reduced_to_false(&bench)) { printf("Reduced to false\n\nunsat\n"); fflush(stdout); } printf("\n"); time = get_cpu_time(); mem_used = mem_size() / (1024 * 1024); printf("Construction time: %.4f s\n", time); printf("Memory used: %.2f MB\n\n", mem_used); fflush(stdout); dump = fopen("yices2new.dmp", "w"); if (dump == NULL) { perror("yices2new.dmp"); } else { dump_benchmark(dump, &bench); fclose(dump); } delete_benchmark(&bench); delete_parser(&parser); close_lexer(&lexer); delete_tstack(&stack); yices_exit(); return YICES_EXIT_SUCCESS; }
int main(int argc, char *argv[]) { bool interactive; int32_t code; FILE *dump; double memused; process_command_line(argc, argv); yices_init(); init_tstack(&stack, NUM_BASE_OPCODES); interactive = false; if (input_filename == NULL) { init_yices_stdin_lexer(&lexer); interactive = true; } else { if (init_yices_file_lexer(&lexer, input_filename) < 0) { perror(input_filename); exit(YICES_EXIT_FILE_NOT_FOUND); } } init_parser(&parser, &lexer, &stack); while (current_token(&lexer) != TK_EOS) { if (interactive) { printf("yices> "); fflush(stdout); } code = parse_yices_command(&parser, stderr); if (code < 0) { flush_lexer(&lexer); } } delete_parser(&parser); close_lexer(&lexer); delete_tstack(&stack); memused = mem_size() / (1024 * 1024); if (memused > 0) { fprintf(stderr, "Memory used: %.2f MB\n", memused); } if (dump_requested) { if (dump_filename == NULL) { dump = stdout; } else { dump = fopen(dump_filename, "w"); if (dump == NULL) { perror(dump_filename); exit(YICES_EXIT_FILE_NOT_FOUND); } } fprintf(dump, "\n==== ALL TYPES ====\n"); print_type_table(dump, __yices_globals.types); fflush(dump); fprintf(dump, "\n==== ALL TERMS ====\n"); print_term_table(dump, __yices_globals.terms); fflush(dump); if (dump_filename != NULL) { if (fclose(dump) != 0) { fprintf(stderr, "Error while closing dump file: "); perror(dump_filename); } } } yices_exit(); return 0; }