void MemFlushFreeList(void) { int f; void* handle; VERBOUT("MemFlushFreeList() called for cleanup or reorganization\n"); for(f = 0; f<MEM_ARR_SIZE; f++) { while(free_mem_list[f]) { handle = (void*)free_mem_list[f]; free_mem_list[f] = free_mem_list[f]->next; FREE(handle); } } }
OCB_p OrderFindOptimal(OrderParms_p mask, OrderEvaluationFun eval_fun, ProofState_p state, HeuristicParms_p parms) { OrderParmsCell local, store; OCB_p best_ocb, tmp_ocb; double best_eval, tmp_eval; VERBOUT("Starting search for optimal term ordering.\n"); local.ordertype = (mask->ordertype==NoOrdering)?KBO:mask->ordertype; local.to_weight_gen = (mask->to_weight_gen==WNoMethod)?WMinMethod:mask->to_weight_gen; local.to_prec_gen = (mask->to_prec_gen==PNoMethod)?PMinMethod:mask->to_prec_gen; local.to_const_weight = (mask->to_const_weight==WConstNoWeight)?1:mask->to_const_weight; store = local; best_ocb = TOCreateOrdering(state, &local,NULL, NULL); best_eval = eval_fun(best_ocb, state, parms); while(OrderNextOrdering(&local, mask)) { tmp_ocb = TOCreateOrdering(state, &local, NULL, NULL); tmp_eval = eval_fun(tmp_ocb, state, parms); if(tmp_eval < best_eval) { OCBFree(best_ocb); best_ocb = tmp_ocb; best_eval = tmp_eval; store = local; } else { OCBFree(tmp_ocb); } } VERBOSE(fprintf(stderr, "%s: Term Ordering found: (%s, %s, %s, %ld)\n", ProgName, TONames[store.ordertype], TOGetPrecGenName(store.to_prec_gen), TOGetWeightGenName(store.to_weight_gen), store.to_const_weight););
int main(int argc, char* argv[]) { int retval = NO_ERROR; CLState_p state; ProofState_p proofstate; ProofControl_p proofcontrol; Clause_p success = NULL, filter_success; bool out_of_clauses; char *finals_state = "exists", *sat_status = "Derivation"; long raw_clause_no, preproc_removed=0, neg_conjectures, parsed_ax_no, relevancy_pruned = 0; double preproc_time; assert(argv[0]); pid = getpid(); InitIO(NAME); #ifdef STACK_SIZE IncreaseMaxStackSize(argv, STACK_SIZE); #endif ESignalSetup(SIGXCPU); h_parms = HeuristicParmsAlloc(); fvi_parms = FVIndexParmsAlloc(); wfcb_definitions = PStackAlloc(); hcb_definitions = PStackAlloc(); state = process_options(argc, argv); OpenGlobalOut(outname); print_info(); if(state->argc == 0) { CLStateInsertArg(state, "-"); } proofstate = parse_spec(state, parse_format, error_on_empty, free_symb_prop, &parsed_ax_no); relevancy_pruned += ProofStateSinE(proofstate, sine); relevancy_pruned += ProofStatePreprocess(proofstate, relevance_prune_level); if(strategy_scheduling) { ExecuteSchedule(StratSchedule, h_parms, print_rusage); } FormulaSetDocInital(GlobalOut, OutputLevel, proofstate->f_axioms); ClauseSetDocInital(GlobalOut, OutputLevel, proofstate->axioms); if(prune_only) { fprintf(GlobalOut, "\n# Pruning successful!\n"); TSTPOUT(GlobalOut, "Unknown"); goto cleanup1; } if(relevancy_pruned || incomplete) { proofstate->state_is_complete = false; } if(BuildProofObject) { FormulaSetArchive(proofstate->f_axioms, proofstate->f_ax_archive); } if((neg_conjectures = FormulaSetPreprocConjectures(proofstate->f_axioms, proofstate->f_ax_archive, answer_limit>0, conjectures_are_questions))) { VERBOUT("Negated conjectures.\n"); } if(FormulaSetCNF(proofstate->f_axioms, proofstate->f_ax_archive, proofstate->axioms, proofstate->original_terms, proofstate->freshvars, proofstate->gc_original_terms)) { VERBOUT("CNFization done\n"); } ProofStateInitWatchlist(proofstate, watchlist_filename, parse_format); raw_clause_no = proofstate->axioms->members; if(!no_preproc) { if(BuildProofObject) { ClauseSetArchive(proofstate->ax_archive, proofstate->axioms); if(proofstate->watchlist) { ClauseSetArchive(proofstate->ax_archive, proofstate->watchlist); } } preproc_removed = ClauseSetPreprocess(proofstate->axioms, proofstate->watchlist, proofstate->archive, proofstate->tmp_terms, eqdef_incrlimit, eqdef_maxclauses); } proofcontrol = ProofControlAlloc(); ProofControlInit(proofstate, proofcontrol, h_parms, fvi_parms, wfcb_definitions, hcb_definitions); PCLFullTerms = pcl_full_terms; /* Preprocessing always uses full terms, so we set the flag for the main proof search only now! */ ProofStateInit(proofstate, proofcontrol); VERBOUT2("Prover state initialized\n"); preproc_time = GetTotalCPUTime(); if(print_rusage) { fprintf(GlobalOut, "# Preprocessing time : %.3f s\n", preproc_time); } if(proofcontrol->heuristic_parms.presat_interreduction) { LiteralSelectionFun sel_strat = proofcontrol->heuristic_parms.selection_strategy; proofcontrol->heuristic_parms.selection_strategy = SelectNoGeneration; success = Saturate(proofstate, proofcontrol, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX); fprintf(GlobalOut, "# Presaturation interreduction done\n"); proofcontrol->heuristic_parms.selection_strategy = sel_strat; if(!success) { ProofStateResetProcessed(proofstate, proofcontrol); } } PERF_CTR_ENTRY(SatTimer); if(!success) { success = Saturate(proofstate, proofcontrol, step_limit, proc_limit, unproc_limit, total_limit, answer_limit); } PERF_CTR_EXIT(SatTimer); out_of_clauses = ClauseSetEmpty(proofstate->unprocessed); if(filter_sat) { filter_success = ProofStateFilterUnprocessed(proofstate, proofcontrol, filterdesc); if(filter_success) { success = filter_success; PStackPushP(proofstate->extract_roots, success); } } if(success||proofstate->answer_count) { assert(!PStackEmpty(proofstate->extract_roots)); if(success) { DocClauseQuoteDefault(2, success, "proof"); } fprintf(GlobalOut, "\n# Proof found!\n"); if(!proofstate->status_reported) { TSTPOUT(GlobalOut, neg_conjectures?"Theorem":"Unsatisfiable"); proofstate->status_reported = true; retval = PROOF_FOUND; } if(BuildProofObject) { DerivationComputeAndPrint(GlobalOut, proofstate->extract_roots, proofstate->signature, proof_graph); } } else if(proofstate->watchlist && ClauseSetEmpty(proofstate->watchlist)) { ProofStatePropDocQuote(GlobalOut, OutputLevel, CPSubsumesWatch, proofstate, "final_subsumes_wl"); fprintf(GlobalOut, "\n# Watchlist is empty!\n"); TSTPOUT(GlobalOut, "ResourceOut"); retval = RESOURCE_OUT; } else { if(out_of_clauses&& proofstate->state_is_complete&& (inf_sys_complete || assume_inf_sys_complete)) { finals_state = "final"; } ProofStatePropDocQuote(GlobalOut, OutputLevel, CPIgnoreProps, proofstate, finals_state); if(cnf_only) { fprintf(GlobalOut, "\n# CNFization successful!\n"); TSTPOUT(GlobalOut, "Unknown"); } else if(out_of_clauses) { if(!(inf_sys_complete || assume_inf_sys_complete)) { fprintf(GlobalOut, "\n# Clause set closed under " "restricted calculus!\n"); if(!SilentTimeOut) { TSTPOUT(GlobalOut, "GaveUp"); } retval = INCOMPLETE_PROOFSTATE; } else if(proofstate->state_is_complete && inf_sys_complete) { fprintf(GlobalOut, "\n# No proof found!\n"); TSTPOUT(GlobalOut, neg_conjectures?"CounterSatisfiable":"Satisfiable"); sat_status = "Saturation"; retval = SATISFIABLE; } else { fprintf(GlobalOut, "\n# Failure: Out of unprocessed clauses!\n"); if(!SilentTimeOut) { TSTPOUT(GlobalOut, "GaveUp"); } retval = INCOMPLETE_PROOFSTATE; } } else { fprintf(GlobalOut, "\n# Failure: User resource limit exceeded!\n"); if(!SilentTimeOut) { TSTPOUT(GlobalOut, "ResourceOut"); } retval = RESOURCE_OUT; } if(BuildProofObject && (retval!=INCOMPLETE_PROOFSTATE)&& (retval!=RESOURCE_OUT)) { ClauseSetPushClauses(proofstate->extract_roots, proofstate->processed_pos_rules); ClauseSetPushClauses(proofstate->extract_roots, proofstate->processed_pos_eqns); ClauseSetPushClauses(proofstate->extract_roots, proofstate->processed_neg_units); ClauseSetPushClauses(proofstate->extract_roots, proofstate->processed_non_units); if(cnf_only) { ClauseSetPushClauses(proofstate->extract_roots, proofstate->unprocessed); print_sat = false; } DerivationComputeAndPrint(GlobalOut, proofstate->extract_roots, proofstate->signature, proof_graph); } } /* ClauseSetDerivationStackStatistics(proofstate->unprocessed); */ if(print_sat) { if(proofstate->non_redundant_deleted) { fprintf(GlobalOut, "\n# Saturated system is incomplete!\n"); } if(success) { fprintf(GlobalOut, "# Saturated system contains the empty clause:\n"); ClausePrint(GlobalOut, success, true); fputc('\n',GlobalOut); fputc('\n',GlobalOut); } ProofStatePrintSelective(GlobalOut, proofstate, outdesc, outinfo); fprintf(GlobalOut, "\n"); } if(success) { ClauseFree(success); } fflush(GlobalOut); print_proof_stats(proofstate, parsed_ax_no, relevancy_pruned, raw_clause_no, preproc_removed); #ifndef FAST_EXIT #ifdef FULL_MEM_STATS fprintf(GlobalOut, "# sizeof TermCell : %ld\n" "# sizeof EqnCell : %ld\n" "# sizeof ClauseCell : %ld\n" "# sizeof PTreeCell : %ld\n" "# sizeof PDTNodeCell : %ld\n" "# sizeof EvalCell : %ld\n" "# sizeof ClausePosCell: %ld\n" "# sizeof PDArrayCell : %ld\n", sizeof(TermCell), sizeof(EqnCell), sizeof(ClauseCell), sizeof(PTreeCell), sizeof(PDTNodeCell), sizeof(EvalCell), sizeof(ClausePosCell), sizeof(PDArrayCell)); fprintf(GlobalOut, "# Estimated memory usage: %ld\n", ProofStateStorage(proofstate)); MemFreeListPrint(GlobalOut); #endif ProofControlFree(proofcontrol); #endif cleanup1: #ifndef FAST_EXIT ProofStateFree(proofstate); CLStateFree(state); PStackFree(hcb_definitions); PStackFree(wfcb_definitions); FVIndexParmsFree(fvi_parms); HeuristicParmsFree(h_parms); #ifdef FULL_MEM_STATS MemFreeListPrint(GlobalOut); #endif #endif if(print_rusage && !SilentTimeOut) { PrintRusage(GlobalOut); } #ifdef CLB_MEMORY_DEBUG RegMemCleanUp(); MemFlushFreeList(); MemDebugPrintStats(stdout); #endif OutClose(GlobalOut); return retval; }
int main(int argc, char* argv[]) { TB_p terms; GCAdmin_p collector; VarBank_p freshvars; Sig_p sig; ClauseSet_p clauses; FormulaSet_p formulas, f_ax_archive; Scanner_p in; int i; CLState_p state; StrTree_p skip_includes = NULL; ClauseSet_p demodulators[1]; OCB_p ocb; assert(argv[0]); InitIO(NAME); #ifdef STACK_SIZE IncreaseMaxStackSize(argv, STACK_SIZE); #endif ESignalSetup(SIGXCPU); state = process_options(argc, argv); OpenGlobalOut(outname); if(state->argc == 0) { CLStateInsertArg(state, "-"); } sig = SigAlloc(); SigInsertInternalCodes(sig); terms = TBAlloc(sig); collector = GCAdminAlloc(terms); clauses = ClauseSetAlloc(); formulas = FormulaSetAlloc(); f_ax_archive = FormulaSetAlloc(); GCRegisterClauseSet(collector, clauses); GCRegisterFormulaSet(collector, formulas); GCRegisterFormulaSet(collector, f_ax_archive); for(i=0; state->argv[i]; i++) { in = CreateScanner(StreamTypeFile, state->argv[i], true, NULL); ScannerSetFormat(in, parse_format); /* ClauseSetParseList(in, clauses, terms); */ FormulaAndClauseSetParse(in,clauses, formulas, terms, NULL, &skip_includes); CheckInpTok(in, NoToken); DestroyScanner(in); } CLStateFree(state); if(FormulaSetPreprocConjectures(formulas, f_ax_archive, false, false)) { VERBOUT("Negated conjectures.\n"); } freshvars = VarBankAlloc(); if(FormulaSetCNF(formulas, f_ax_archive, clauses, terms, freshvars, collector)) { VERBOUT("CNFization done\n"); } VarBankFree(freshvars); GCDeregisterFormulaSet(collector, formulas); FormulaSetFree(formulas); GCDeregisterFormulaSet(collector, f_ax_archive); FormulaSetFree(f_ax_archive); demodulators[0] = ClauseSetAlloc(); demodulators[0]->demod_index = PDTreeAlloc(); GCRegisterClauseSet(collector, demodulators[0]); build_rw_system(demodulators[0], clauses); GCDeregisterClauseSet(collector, clauses); ClauseSetFree(clauses); VERBOUT("# Demodulators\n"); VERBOSE(ClauseSetPrint(stderr, demodulators[0], true););