1
/* Copyright (C) 2006, 2007 William McCune
3
This file is part of the LADR Deduction Library.
5
The LADR Deduction Library is free software; you can redistribute it
6
and/or modify it under the terms of the GNU General Public License,
9
The LADR Deduction Library is distributed in the hope that it will be
10
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with the LADR Deduction Library; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
#include "../ladr/top_input.h"
21
#define PROGRAM_NAME "tptp_to_ladr"
22
#include "../VERSION_DATE.h"
31
void read_tptp_input(FILE *fin, FILE *fout, FILE *ferr,
32
Plist *assumps, Plist *goals)
34
Term t = read_term(fin, fout);
38
if (is_term(t, "include", 1) || is_term(t, "include", 2)) {
39
char *fname = new_str_copy(sn_to_str(SYMNUM(ARG(t,0))));
43
if (*fname2 == '\'' || *fname2 == '"') {
44
fname2[strlen(fname2)-1] = '\0';
47
fin2 = fopen(fname2, "r");
50
sprintf(s, "read_tptp_input, file %s not found", fname2);
53
fprintf(fout, "\n%% Including file %s\n\n", fname2);
54
read_tptp_input(fin2, fout, ferr, assumps, goals);
57
else if (is_term(t, "cnf", 3) || is_term(t, "cnf", 4) ||
58
is_term(t, "fof", 3) || is_term(t, "fof", 4) ||
59
is_term(t, "input_clause", 3)) {
60
Formula form = tptp_input_to_ladr_formula(t);
61
if (is_term(ARG(t,1), "conjecture", 0))
62
*goals = plist_append(*goals, form);
64
*assumps = plist_append(*assumps, form);
68
fatal_error("read_tptp_input: unknown term");
71
t = read_term(fin, fout);
73
} /* read_tptp_input */
75
int main(int argc, char **argv)
82
i = register_attribute("label", STRING_ATTRIBUTE);
84
clear_parse_type_for_all_symbols();
85
declare_tptp_parse_types();
86
set_quote_char('\''); /* TPTP uses single quotes for strings. */
88
read_tptp_input(stdin, stdout, stderr, &assumps, &goals);
90
clear_parse_type_for_all_symbols();
91
declare_standard_parse_types(); /* defaults for LADR */
93
printf("set(prolog_style_variables).\n");
94
fwrite_formula_list(stdout, assumps, "assumptions");
95
fwrite_formula_list(stdout, goals, "goals");