bool OpenAll() { BoxClass_CallOpen callopen; if (!mutabor::OutOpen()) return false; BoxListType & boxList = const_cast<BoxListType &>(BoxClass::GetBoxList()); std::for_each(boxList.begin(),boxList.end(),callopen); if (!callopen.ok) { BoxClass::CloseAll(); OutClose(); return false; } if (!InOpen() ) { BoxClass::CloseAll(); OutClose(); return false; } #if 0 if ( !ok ) { wxMessageBox(Fmeldung, _("Activation error"), wxOK | wxICON_ASTERISK ); return false; } #endif return true; }
//--------------------------------------------------------------------------- BOOL __fastcall CWave::OutWrite(const SHORT *pData) { if( m_pDLL ){ return m_pDLL->OutWrite(pData); } int Len = m_OutLen; int i; if( !m_OutOpen ){ m_Error = 1; return FALSE; } if( m_OutUnder ){ m_Error = 1; OutClose(); return FALSE; } // 送信バッファ空き待ち EnterCriticalSection(&m_OutCS); if( m_OutBC >= m_OutFifoSize ){ m_OutWait++; ::LeaveCriticalSection(&m_OutCS); if( ::WaitForSingleObject( m_OutEvent, WAVE_TIMEOUT_EVENT ) != WAIT_OBJECT_0 ){ m_Error = 2; OutAbort(); return FALSE; } } else { ::LeaveCriticalSection(&m_OutCS); } // データの変換 LPWAVEHDR hp = m_pOutBuff[m_OutWP]; SHORT *wp = (SHORT *)hp->lpData; if( m_OWFX.nChannels == 2 ){ for( i = 0; i < Len; i++ ){ *wp++ = *pData; *wp++ = *pData++; } } else { memcpy(wp, pData, sizeof(SHORT)*Len); } ::waveOutWrite(m_hout, hp, sizeof(WAVEHDR) ); ::EnterCriticalSection(&m_OutCS); // m_OutCS++が1命令では展開されない m_OutBC++; ::LeaveCriticalSection(&m_OutCS); if( m_OutFirst ){ if( (m_OutBC >= 8) || (m_OutBC >= (m_OutFifoSize-1)) ){ m_OutFirst = FALSE; ::waveOutRestart( m_hout ); } } m_OutWP++; if( m_OutWP >= m_OutFifoSize){ m_OutWP = 0; } return TRUE; }
static bool pcl_verify_otter(ClauseSet_p problem,char *executable, long time_limit) { bool res; DStr_p command = DStrAlloc(); char* name=TempFileName(); FILE* problemfile; if(!executable) { executable=OTTER_EXEC_DEFAULT; } problemfile = OutOpen(name); fprintf(problemfile, "set(prolog_style_variables).\n" "clear(print_kept).\n" "clear(print_new_demod).\n" "clear(print_back_demod).\n" "clear(print_back_sub).\n" "set(auto).\n" "set(input_sos_first).\n" /* "set(para_from_vars).\n" */ "assign(max_seconds, %ld).\n\n" "assign(max_mem, 100000).\n\n" "list(usable).\n\n" "equal(X,X).\n",time_limit); clause_set_print_otter(problemfile, problem); fprintf(problemfile, "end_of_list.\n"); OutClose(problemfile); DStrAppendStr(command, executable); DStrAppendStr(command, " < "); DStrAppendStr(command, name); DStrAppendStr(command, " 2> /dev/null"); res = pcl_run_prover(DStrView(command), "-------- PROOF --------"); if(!res) { fprintf(GlobalOut, "# ------------Problem begin--------------\n"); FilePrint(GlobalOut, name); fprintf(GlobalOut, "# ------------Problem end----------------\n"); } TempFileRemove(name); FREE(name); DStrFree(command); return res; }
char* TempFileCreate(FILE* source) { char* name; FILE* out; int c; name = TempFileName(); out = OutOpen(name); while((c = getc(source))!= EOF) { putc(c, out); } OutClose(out); return name; }
static bool pcl_verify_spass(ClauseSet_p problem,char *executable, long time_limit, Sig_p sig) { bool res; DStr_p command = DStrAlloc(); char* name=TempFileName(); FILE* problemfile; if(!executable) { executable=SPASS_EXEC_DEFAULT; } problemfile = OutOpen(name); fprintf(problemfile, "begin_problem(Unknown).\n"); sig_print_dfg(problemfile, problem, sig); fprintf(problemfile, "list_of_clauses(axioms,cnf).\n"); clause_set_print_dfg(problemfile, problem); fprintf(problemfile, "end_of_list.\n" "list_of_settings(SPASS).\n" "set_flag(TimeLimit, %ld).\n" "end_of_list.\n" "end_problem.\n", time_limit); OutClose(problemfile); DStrAppendStr(command, executable); DStrAppendStr(command, " "); DStrAppendStr(command, name); res = pcl_run_prover(DStrView(command), "Proof found."); if(!res) { fprintf(GlobalOut, "# ------------Problem begin--------------\n"); FilePrint(GlobalOut, name); fprintf(GlobalOut, "# ------------Problem end----------------\n"); } TempFileRemove(name); FREE(name); DStrFree(command); return res; }
static bool pcl_verify_eprover(ClauseSet_p problem,char *executable, long time_limit) { bool res; DStr_p command = DStrAlloc(); char* name=TempFileName(); FILE* problemfile; assert(OutputFormat == TPTPFormat); if(!executable) { executable=E_EXEC_DEFAULT; } problemfile = OutOpen(name); ClauseSetPrint(problemfile, problem, true); OutClose(problemfile); DStrAppendStr(command, executable); DStrAppendStr(command, " --tptp-in --prefer-initial-clauses --ac-handling=None" " --cpu-limit="); DStrAppendInt(command, time_limit); DStrAppendChar(command, ' '); DStrAppendStr(command, name); res = pcl_run_prover(DStrView(command),"# Proof found!"); if(!res) { fprintf(GlobalOut, "# ------------Problem begin--------------\n"); FilePrint(GlobalOut, name); fprintf(GlobalOut, "# ------------Problem end----------------\n"); } TempFileRemove(name); FREE(name); DStrFree(command); return res; }
int main(int argc, char* argv[]) { /* Scanner_p in; */ CLState_p state; Scanner_p in; PCLProt_p prot; long steps, proof_steps, neg_steps; int i; assert(argv[0]); InitIO(NAME); ESignalSetup(SIGTERM); ESignalSetup(SIGINT); /* We need consistent name->var mappings here because we potentially read the compressed input format. */ ClausesHaveLocalVariables = false; state = process_options(argc, argv); GlobalOut = OutOpen(outname); OpenGlobalOut(outname); prot = PCLProtAlloc(); if(state->argc == 0) { CLStateInsertArg(state, "-"); } steps = 0; for(i=0; state->argv[i]; i++) { in = CreateScanner(StreamTypeFile, state->argv[i], true, NULL); ScannerSetFormat(in, TPTPFormat); steps+=PCLProtParse(in, prot); CheckInpTok(in, NoToken); DestroyScanner(in); } VERBOUT2("PCL input read\n"); PCLProtStripFOF(prot); PCLProtResetTreeData(prot, false); PCLProtMarkProofClauses(prot); PCLProtProofDistance(prot); PCLProtUpdateGRefs(prot); proof_steps = PCLProtCountProp(prot, PCLIsProofStep); neg_steps = proof_steps?neg_proportion*proof_steps:neg_examples; PCLProtSelectExamples(prot, neg_steps); fprintf(GlobalOut, "# Axioms:\n"); PCLProtPrintPropClauses(GlobalOut, prot, PCLIsInitial, lop_format); fprintf(GlobalOut, ".\n\n# Examples:\n"); PCLProtPrintExamples(GlobalOut, prot); PCLProtFree(prot); CLStateFree(state); fflush(GlobalOut); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { ProofState_p fstate; Scanner_p in; int i; CLState_p state; SpecFeatureCell features; SpecLimits_p limits; StrTree_p skip_includes = NULL; assert(argv[0]); InitIO(NAME); limits = SpecLimitsAlloc(); state = process_options(argc, argv, limits); OpenGlobalOut(outname); if(state->argc == 0) { CLStateInsertArg(state, "-"); } if(parse_features) { if(raw_classify) { process_raw_feature_files(state->argv, limits); } else { process_feature_files(state->argv, limits); } } else { for(i=0; state->argv[i]; i++) { fstate = ProofStateAlloc(FPIgnoreProps); in = CreateScanner(StreamTypeFile, state->argv[i], true, NULL); ScannerSetFormat(in, parse_format); FormulaAndClauseSetParse(in, fstate->axioms, fstate->f_axioms, fstate->original_terms, NULL, & skip_includes); if(raw_classify) { do_raw_classification(state->argv[i], fstate, limits); } else { FormulaSetPreprocConjectures(fstate->f_axioms, fstate->f_ax_archive, false, false); FormulaSetCNF(fstate->f_axioms, fstate->f_ax_archive, fstate->axioms, fstate->original_terms, fstate->freshvars, fstate->gc_original_terms); if(!no_preproc) { ClauseSetPreprocess(fstate->axioms, fstate->watchlist, fstate->archive, fstate->tmp_terms, eqdef_incrlimit, eqdef_maxclauses); } SpecFeaturesCompute(&features, fstate->axioms, fstate->signature); SpecFeaturesAddEval(&features, limits); if(!tptp_header) { fprintf(GlobalOut, "%s : ", state->argv[i]); SpecFeaturesPrint(GlobalOut, &features); fprintf(GlobalOut, " : "); SpecTypePrint(GlobalOut, &features, mask); fprintf(GlobalOut, "\n"); } else { print_tptp_header(fstate, features); } DestroyScanner(in); ProofStateFree(fstate); } } } CLStateFree(state); SpecLimitsCellFree(limits); fflush(GlobalOut); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return 0; }
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[]) { CLState_p state; Scanner_p in; BatchSpec_p spec; StructFOFSpec_p ctrl; char *prover = "eprover"; char *category = NULL; char *train_dir = NULL; long now, start, res; assert(argv[0]); InitIO(NAME); DocOutputFormat = tstp_format; OutputFormat = TSTPFormat; state = process_options(argc, argv); OpenGlobalOut(outname); if((state->argc < 1) || (state->argc > 2)) { Error("Usage: e_ltb_runner <spec> [<path-to-eprover>] \n", USAGE_ERROR); } if(state->argc >= 2) { prover = state->argv[1]; } in = CreateScanner(StreamTypeFile, state->argv[0], true, NULL); ScannerSetFormat(in, TSTPFormat); AcceptDottedId(in, "division.category"); category = ParseDottedId(in); if(TestInpId(in, "division")) { AcceptDottedId(in, "division.category.training_directory"); train_dir = ParseContinous(in); } while(!TestInpTok(in, NoToken)) { start = GetSecTime(); spec = BatchSpecParse(in, prover, category, train_dir, TSTPFormat); /* BatchSpecPrint(GlobalOut, spec); */ if(total_wtc_limit && !spec->total_wtc_limit) { spec->total_wtc_limit = total_wtc_limit; } if(spec->per_prob_limit<=0 && total_wtc_limit<=0) { Error("Either the per-problem time limit or the global " "time limit must be set to a value > 0", USAGE_ERROR); } /* BatchSpecPrint(stdout, spec); */ ctrl = StructFOFSpecAlloc(); BatchStructFOFSpecInit(spec, ctrl); now = GetSecTime(); res = BatchProcessProblems(spec, ctrl, MAX(0,total_wtc_limit-(now-start))); now = GetSecTime(); fprintf(GlobalOut, "\n\n# == WCT: %4lds, Solved: %4ld/%4d ==\n", now-start, res, BatchSpecProblemNo(spec)); if(interactive) { BatchProcessInteractive(spec, ctrl, stdout); } StructFOFSpecFree(ctrl); BatchSpecFree(spec); fprintf(GlobalOut, "# =============== Batch done ===========\n\n"); } DestroyScanner(in); if(category) { FREE(category); } if(train_dir) { FREE(train_dir); } CLStateFree(state); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return 0; }
int main(int argc, char* argv[]) { CLState_p state; StructFOFSpec_p ctrl; PStack_p prob_names = PStackAlloc(); int i; AxFilterSet_p filters; Scanner_p in; DStr_p corename; char *tname; assert(argv[0]); InitIO(NAME); DocOutputFormat = tstp_format; OutputFormat = TSTPFormat; state = process_options(argc, argv); OpenGlobalOut(outname); if(filtername) { filters = AxFilterSetAlloc(); in = CreateScanner(StreamTypeFile, filtername, true, NULL); AxFilterSetParse(in, filters); DestroyScanner(in); } else { filters = AxFilterSetCreateInternal(AxFilterDefaultSet); } if(dumpfilter) { AxFilterSetPrint(GlobalOut, filters); } if(state->argc < 1) { Error("Usage: e_axfilter <problem> [<options>]\n", USAGE_ERROR); } for(i=0; state->argv[i]; i++) { PStackPushP(prob_names, state->argv[i]); } /* Base name is the stripped base of the first argument */ tname = FileNameStrip(state->argv[0]); corename = DStrAlloc(); DStrAppendStr(corename, tname); FREE(tname); ctrl = StructFOFSpecAlloc(); StructFOFSpecParseAxioms(ctrl, prob_names, parse_format); StructFOFSpecInitDistrib(ctrl); StructFOFSpecResetShared(ctrl); for(i=0; i<AxFilterSetElements(filters); i++) { /* SigPrint(stdout,ctrl->sig); */ filter_problem(ctrl, AxFilterSetGetFilter(filters,i), DStrView(corename)); } StructFOFSpecFree(ctrl); DStrFree(corename); AxFilterSetFree(filters); CLStateFree(state); PStackFree(prob_names); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return 0; }