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; }
// // Side Effects : // /----------------------------------------------------------------------*/ void ProofStateInit(ProofState_p state, ProofControl_p control) { Clause_p handle, new; HCB_p tmphcb; PStack_p traverse; Eval_p cell; OUTPRINT(1, "# Initializing proof state\n"); assert(ClauseSetEmpty(state->processed_pos_rules)); assert(ClauseSetEmpty(state->processed_pos_eqns)); assert(ClauseSetEmpty(state->processed_neg_units)); assert(ClauseSetEmpty(state->processed_non_units)); tmphcb = GetHeuristic("Uniq", state, control, &(control->heuristic_parms)); assert(tmphcb); ClauseSetReweight(tmphcb, state->axioms); traverse = EvalTreeTraverseInit(PDArrayElementP(state->axioms->eval_indices,0),0); while((cell = EvalTreeTraverseNext(traverse, 0))) { handle = cell->object; new = ClauseCopy(handle, state->terms);