/*----------------------------------------------------------------------- File : e_ltb_runner.c Author: Stephan Schulz Contents Hack for the LTB category of CASC-2010 - parse a LTB spec file, and run E on the various problems. Copyright 2010 by the author. This code is released under the GNU General Public Licence and the GNU Lesser General Public License. See the file COPYING in the main E directory for details.. Run "eprover -h" for contact information. Changes <1> Mon Jun 28 02:15:05 CEST 2010 New -----------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include #include /*---------------------------------------------------------------------*/ /* Data types */ /*---------------------------------------------------------------------*/ #define NAME "e_ltb_runner" typedef enum { OPT_NOOPT=0, OPT_HELP, OPT_VERSION, OPT_VERBOSE, OPT_OUTPUT, OPT_PRINT_STATISTICS, OPT_SILENT, OPT_OUTPUTLEVEL, OPT_DUMMY }OptionCodes; /*---------------------------------------------------------------------*/ /* Global Variables */ /*---------------------------------------------------------------------*/ OptCell opts[] = { {OPT_HELP, 'h', "help", NoArg, NULL, "Print a short description of program usage and options."}, {OPT_VERSION, 'V', "version", NoArg, NULL, "Print the version number of the prover. Please include this" " with all bug reports (if any)."}, {OPT_VERBOSE, 'v', "verbose", OptArg, "1", "Verbose comments on the progress of the program. This differs " "from the output level (below) in that technical information is " "printed to stderr, while the output level determines which " "logical manipulations of the clauses are printed to stdout."}, {OPT_OUTPUT, 'o', "output-file", ReqArg, NULL, "Redirect output into the named file."}, {OPT_SILENT, 's', "silent", NoArg, NULL, "Equivalent to --output-level=0."}, {OPT_OUTPUTLEVEL, 'l', "output-level", ReqArg, NULL, "Select an output level, greater values imply more verbose " "output. Level 0 produces " "nearly no output, level 1 will output each clause as it is " "processed, level 2 will output generating inferences, " "level 3 will give a full protocol including rewrite steps and " "level 4 will include some internal clause renamings. Levels >= 2" " also imply PCL2 or TSTP formats (which can be post-processed" " with suitable tools)."}, {OPT_NOOPT, '\0', NULL, NoArg, NULL, NULL} }; char *outname = NULL; /*---------------------------------------------------------------------*/ /* Forward Declarations */ /*---------------------------------------------------------------------*/ CLState_p process_options(int argc, char* argv[]); void print_help(FILE* out); /*---------------------------------------------------------------------*/ /* Internal Functions */ /*---------------------------------------------------------------------*/ int main(int argc, char* argv[]) { CLState_p state; Scanner_p in; BatchSpec_p spec; StructFOFSpec_p ctrl; char *prover = "eprover"; char *xtract = "epclextract"; assert(argv[0]); InitIO(NAME); DocOutputFormat = tstp_format; OutputFormat = TSTPFormat; state = process_options(argc, argv); OpenGlobalOut(outname); if((state->argc < 1) || (state->argc > 3)) { Error("Usage: e_ltb_runner [ []] \n", USAGE_ERROR); } if(state->argc >= 2) { prover = state->argv[1]; } if(state->argc >= 3) { xtract = state->argv[2]; } in = CreateScanner(StreamTypeFile, state->argv[0], true, NULL); ScannerSetFormat(in, TSTPFormat); while(!TestInpTok(in, NoToken)) { spec = BatchSpecParse(in, prover, xtract, TSTPFormat); /* BatchSpecPrint(stdout, spec); */ ctrl = StructFOFSpecAlloc(); StructFOFSpecInit(spec, ctrl); BatchProcessProblems(spec, ctrl); StructFOFSpecFree(ctrl); BatchSpecFree(spec); fprintf(GlobalOut, "\n\n# =============== Batch done ===========\n\n"); } DestroyScanner(in); CLStateFree(state); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return 0; } /*----------------------------------------------------------------------- // // Function: process_options() // // Read and process the command line option, return (the pointer to) // a CLState object containing the remaining arguments. // // Global Variables: opts, Verbose, TBPrintInternalInfo // // Side Effects : Sets variables, may terminate with program // description if option -h or --help was present // /----------------------------------------------------------------------*/ CLState_p process_options(int argc, char* argv[]) { Opt_p handle; CLState_p state; char* arg; state = CLStateAlloc(argc,argv); while((handle = CLStateGetOpt(state, &arg, opts))) { switch(handle->option_code) { case OPT_VERBOSE: Verbose = CLStateGetIntArg(handle, arg); break; case OPT_HELP: print_help(stdout); exit(NO_ERROR); break; case OPT_VERSION: fprintf(stdout, NAME " " VERSION " " E_NICKNAME "\n"); exit(NO_ERROR); break; case OPT_OUTPUT: outname = arg; break; case OPT_SILENT: OutputLevel = 0; break; case OPT_OUTPUTLEVEL: OutputLevel = CLStateGetIntArg(handle, arg); break; default: assert(false && "Unknown option"); break; } } return state; } void print_help(FILE* out) { fprintf(out, "\n" NAME " " VERSION " \"" E_NICKNAME "\"\n\ \n\ Usage: " NAME " [options] [files]\n\ \n\ Read a CASC 23 LTB batch specification file and process it.\n\ \n"); PrintOptions(stdout, opts, "Options:\n\n"); fprintf(out, "\n\ "STS_COPYRIGHT", " STS_MAIL "\n\ \n\ You can find the latest version of E and additional information at\n" E_URL "\n\n" "This program is free software; you can redistribute it and/or modify\n\ it under the terms of the GNU General Public License as published by\n\ the Free Software Foundation; either version 2 of the License, or\n\ (at your option) any later version.\n\ \n\ This program is distributed in the hope that it will be useful,\n\ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ GNU General Public License for more details.\n\ \n\ You should have received a copy of the GNU General Public License\n\ along with this program (it should be contained in the top level\n\ directory of the distribution in the file COPYING); if not, write to\n\ the Free Software Foundation, Inc., 59 Temple Place, Suite 330,\n\ Boston, MA 02111-1307 USA\n" "\n\ The original copyright holder can be contacted as\n\ \n" STS_SNAIL "\n"); } /*---------------------------------------------------------------------*/ /* End of File */ /*---------------------------------------------------------------------*/