| 1 | /**CFile*********************************************************************** |
|---|
| 2 | |
|---|
| 3 | FileName [main.c] |
|---|
| 4 | |
|---|
| 5 | PackageName [smt] |
|---|
| 6 | |
|---|
| 7 | Synopsis [Routines for main function.] |
|---|
| 8 | |
|---|
| 9 | Author [Hyondeuk Kim] |
|---|
| 10 | |
|---|
| 11 | Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado |
|---|
| 12 | |
|---|
| 13 | All rights reserved. |
|---|
| 14 | |
|---|
| 15 | Redistribution and use in source and binary forms, with or without |
|---|
| 16 | modification, are permitted provided that the following conditions |
|---|
| 17 | are met: |
|---|
| 18 | |
|---|
| 19 | Redistributions of source code must retain the above copyright |
|---|
| 20 | notice, this list of conditions and the following disclaimer. |
|---|
| 21 | |
|---|
| 22 | Redistributions in binary form must reproduce the above copyright |
|---|
| 23 | notice, this list of conditions and the following disclaimer in the |
|---|
| 24 | documentation and/or other materials provided with the distribution. |
|---|
| 25 | |
|---|
| 26 | Neither the name of the University of Colorado nor the names of its |
|---|
| 27 | contributors may be used to endorse or promote products derived from |
|---|
| 28 | this software without specific prior written permission. |
|---|
| 29 | |
|---|
| 30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|---|
| 31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|---|
| 33 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|---|
| 34 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|---|
| 35 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|---|
| 36 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|---|
| 37 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|---|
| 38 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|---|
| 39 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|---|
| 40 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|---|
| 41 | POSSIBILITY OF SUCH DAMAGE.] |
|---|
| 42 | |
|---|
| 43 | ******************************************************************************/ |
|---|
| 44 | |
|---|
| 45 | #ifdef HAVE_LIBGMP |
|---|
| 46 | |
|---|
| 47 | #include <setjmp.h> |
|---|
| 48 | #include <signal.h> |
|---|
| 49 | #include "smt.h" |
|---|
| 50 | |
|---|
| 51 | static char rcsid[] UNUSED = "$Id $"; |
|---|
| 52 | |
|---|
| 53 | int |
|---|
| 54 | main(int argc, char ** argv) |
|---|
| 55 | { |
|---|
| 56 | char *filename = 0; |
|---|
| 57 | int is_smt = 1, is_model = 0, timeout = -1; |
|---|
| 58 | int i; |
|---|
| 59 | satArray_t *sat_options; |
|---|
| 60 | |
|---|
| 61 | sat_options = sat_array_alloc(3); |
|---|
| 62 | for (i = 0; i < 3; i++) |
|---|
| 63 | sat_array_insert(sat_options, 0); |
|---|
| 64 | |
|---|
| 65 | fprintf(stdout, "c %s (compiled %s)\n", |
|---|
| 66 | CUR_VER, DateReadFromDateString(CUR_DATE)); |
|---|
| 67 | |
|---|
| 68 | if (argc <= 2) { |
|---|
| 69 | |
|---|
| 70 | if (argc < 2 || !strcmp (argv[1], "-h")) { |
|---|
| 71 | goto usage; |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | filename = strdup(argv[1]); |
|---|
| 75 | smt_main(filename, timeout, is_model); |
|---|
| 76 | |
|---|
| 77 | return 0; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | for (i = 1; i < argc; i++) { |
|---|
| 81 | |
|---|
| 82 | if (!strcmp (argv[i], "-smt")) { |
|---|
| 83 | |
|---|
| 84 | filename = strdup(argv[i+1]); |
|---|
| 85 | |
|---|
| 86 | } else if (!strcmp (argv[i], "-cnf")) { |
|---|
| 87 | |
|---|
| 88 | filename = strdup(argv[i+1]); |
|---|
| 89 | is_smt = 0; |
|---|
| 90 | |
|---|
| 91 | } else if (!strcmp (argv[i], "-t")) { |
|---|
| 92 | |
|---|
| 93 | timeout = atoi(argv[i+1]); |
|---|
| 94 | |
|---|
| 95 | } else if (!strcmp (argv[i], "-model")) { |
|---|
| 96 | |
|---|
| 97 | is_model = 1; |
|---|
| 98 | |
|---|
| 99 | } else if (!strcmp (argv[i], "-quiet")) { |
|---|
| 100 | |
|---|
| 101 | sat_options->space[0] = 1; |
|---|
| 102 | |
|---|
| 103 | } else if (!strcmp (argv[i], "-velim")) { |
|---|
| 104 | |
|---|
| 105 | sat_options->space[1] = 1; |
|---|
| 106 | |
|---|
| 107 | } else if (!strcmp (argv[i], "-distill")) { |
|---|
| 108 | |
|---|
| 109 | sat_options->space[2] = 1; |
|---|
| 110 | |
|---|
| 111 | } else if (i == 1) { |
|---|
| 112 | |
|---|
| 113 | filename = strdup(argv[i]); |
|---|
| 114 | |
|---|
| 115 | } |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | if (!filename) goto usage; |
|---|
| 119 | |
|---|
| 120 | if (is_smt) { |
|---|
| 121 | /* e.g. cusp -smt file */ |
|---|
| 122 | smt_main(filename, timeout, is_model); |
|---|
| 123 | |
|---|
| 124 | } else { |
|---|
| 125 | /* e.g. cusp -cnf file */ |
|---|
| 126 | sat_main(filename, timeout, sat_options); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | return 0; |
|---|
| 130 | |
|---|
| 131 | usage: |
|---|
| 132 | (void) fprintf(stderr, "USAGE: cusp [-h] [problem] <input-file> [problem-options] [-t <seconds>]\n\n"); |
|---|
| 133 | (void) fprintf(stderr, "-h print the command usage\n\n"); |
|---|
| 134 | (void) fprintf(stderr, "PROBLEM:\n\n"); |
|---|
| 135 | (void) fprintf(stderr, " -smt Satisfiability Modulo Theories (default) \n"); |
|---|
| 136 | (void) fprintf(stderr, " -cnf Propositional Satisfiability\n\n"); |
|---|
| 137 | (void) fprintf(stderr, "SMT-OPTIONS:\n\n"); |
|---|
| 138 | (void) fprintf(stderr, " -model print a SMT solution (default 0)\n"); |
|---|
| 139 | (void) fprintf(stderr, "CNF-OPTIONS:\n\n"); |
|---|
| 140 | (void) fprintf(stderr, " -quiet suppress printing solution (default 0)\n"); |
|---|
| 141 | (void) fprintf(stderr, " -velim preprocess based on variable elimination (default 0)\n"); |
|---|
| 142 | (void) fprintf(stderr, " -distill preprocess based on clause distillation (default 0)\n"); |
|---|
| 143 | (void) fprintf(stderr, "\n"); |
|---|
| 144 | |
|---|
| 145 | return 1; |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | #endif |
|---|
| 149 | |
|---|