Connect++ 0.7.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
TPTPParser Class Reference

Wrap up everything the TPTP parser needs to do inside a single class. More...

#include <TPTPParser.hpp>

Collaboration diagram for TPTPParser:

Public Member Functions

 TPTPParser ()=delete
 You definitely don't want this constructor.
 
 TPTPParser (VariableIndex *, FunctionIndex *, TermIndex *, PredicateIndex *, Matrix *, TPTPRecords *)
 The only constructor that makes sense.
 
bool parse_tptp_from_file (const string &)
 Main method to parse from a TPTP file to the data structures needed by the prover.
 
void show_file_includes ()
 Show any includes present in the TPTP file.
 
void clear ()
 Clear everything associated with the TPTP parser.
 
vector< string > get_defined_items ()
 Get a copy of tptp_parser::all_defined.
 
vector< string > get_system_items ()
 Get a copy of tptp_parser::all_system.
 
bool equality_used ()
 Did equality turn up anywhere in the parse?
 
bool conjecture_present () const
 Did a conjecture turn up anywhere in the parse?
 
bool negated_conjecture_present () const
 Did a negated conjecture turn up anywhere in the parse?
 
bool no_conjecture_clause () const
 When you analysed the original problem, did you conclude that it has no conjecture clauses that can be used as a starting point?
 
size_t number_of_fof_formulas () const
 How many first-order formulas turned up in the parse?
 
string get_problem_status ()
 The parse tries to identify the problem status.
 
Predicateget_equals_predicate () const
 If equality turned up anywhere in the parse it will have been turned into an actual Predicate, so this will give you a pointer to it.
 
bool problem_is_cnf_only () const
 Self-explanatory.
 
bool fof_conjecture_is_true () const
 Self-explanatory.
 
bool fof_conjecture_is_false () const
 Self-explanatory.
 
bool fof_conjecture_is_missing () const
 Was there a conjecture clause in the problem file?
 
bool fof_negated_conjecture_removed () const
 Was there a conjecture clause that got simplified away?
 
bool simplified_fof_has_axioms () const
 Where there any axioms for an FOF problem after simplification?
 
bool fof_has_axioms () const
 Where there any axioms for an FOF problem before simplification?
 

Private Member Functions

void read_tptp_from_file (const string &)
 Read the file into a string, while stripping out and collecting comment blocks.
 
void check_timeout ()
 

Private Attributes

string file_contents
 Contents of the TPTP file, with comments removed.
 
vector< string > comment_blocks
 Each comment is stored here.
 
VariableIndexvip
 The class has pointers to all the relevant indices.
 
FunctionIndexfip
 The class has pointers to all the relevant indices.
 
TermIndextip
 The class has pointers to all the relevant indices.
 
PredicateIndexpip
 The class has pointers to all the relevant indices.
 
Matrixmatrix
 The class has a pointer to the matrix, and can therefore construct it as it parses.
 
TPTPRecordstptp_proof_output_p
 Used to build the complete TPTP description of the proof process that's completed by the parser.
 

Detailed Description

Wrap up everything the TPTP parser needs to do inside a single class.

This class needs access to the assorted indices employed by the prover because they are the only things anyone should be using to make Terms, Variables etc.

If you construct this properly and use parse_tptp_from_file, then after a successful parse the indices have everything ready to go.

Definition at line 661 of file TPTPParser.hpp.

Constructor & Destructor Documentation

◆ TPTPParser()

TPTPParser::TPTPParser ( VariableIndex * new_vip,
FunctionIndex * new_fip,
TermIndex * new_tip,
PredicateIndex * new_pip,
Matrix * new_matrix,
TPTPRecords * _records_p )

The only constructor that makes sense.

Definition at line 1421 of file TPTPParser.cpp.

1429:
1432vip(new_vip),
1433fip(new_fip),
1434tip(new_tip),
1435pip(new_pip),
1436matrix(new_matrix),
1437tptp_proof_output_p(_records_p) {
1438 // var_index_p is global in the tptp_parser namespace. It is
1439 // used by semantic actions.
1440 var_index_p = new_vip;
1441 // Similar for fun_index_p and so on...
1442 fun_index_p = new_fip;
1443 t_index_p = new_tip;
1444 p_index_p = new_pip;
1445 records_p = _records_p;
1446 FOF::set_recs_p(_records_p);
1447 // And remember that FOF also needs to use the indices.
1448 FOF::set_indexes(std::tuple<VariableIndex*, FunctionIndex*, PredicateIndex*, TermIndex*>
1449 (new_vip, new_fip, new_pip, new_tip));
1450 clear();
1451};
static void set_indexes(std::tuple< VariableIndex *, FunctionIndex *, PredicateIndex *, TermIndex * > is)
Set up pointer to the variable index etc.
Definition FOF.hpp:241
static void set_recs_p(TPTPRecords *_p)
Set up the pointer allowing TPTP outputs to be added.
Definition FOF.hpp:253
void clear()
Clear everything associated with the TPTP parser.
vector< string > comment_blocks
Each comment is stored here.
TermIndex * tip
The class has pointers to all the relevant indices.
TPTPRecords * tptp_proof_output_p
Used to build the complete TPTP description of the proof process that's completed by the parser.
FunctionIndex * fip
The class has pointers to all the relevant indices.
PredicateIndex * pip
The class has pointers to all the relevant indices.
Matrix * matrix
The class has a pointer to the matrix, and can therefore construct it as it parses.
string file_contents
Contents of the TPTP file, with comments removed.
VariableIndex * vip
The class has pointers to all the relevant indices.

Member Function Documentation

◆ check_timeout()

void TPTPParser::check_timeout ( )
inlineprivate

Periodically, we need to check whether we've exceeded the global timeout.

Definition at line 725 of file TPTPParser.hpp.

725 {
726 if (!params::timeout) {
727 return;
728 }
729 if (std::chrono::steady_clock::now() > params::global_timeout) {
730 cout << endl << "% SZS status Timeout for "
731 << params::problem_name
732 << " : terminated by global timeout." << endl;
733 exit(EXIT_FAILURE);
734 }
735 }

◆ clear()

void TPTPParser::clear ( )

Clear everything associated with the TPTP parser.

Note that this is slightly messy because it also clears all the supporting stuff that's global in the tptp_parser namespace. Yes, very ugly. What ya gonna do about it!!??

Definition at line 1912 of file TPTPParser.cpp.

1912 {
1913 equals_added = false;
1914 conjecture_found = false;
1915 negated_conjecture_found = false;
1916 conjecture_true = false;
1917 conjecture_false = false;
1918 found_true_axiom = false;
1919 found_false_axiom = false;
1920 negated_conjecture_exists = false;
1921 has_axioms = false;
1922 has_axioms_remaining = false;
1923 cnf_only = false;
1924 number_of_negated_conjecture_clauses = 0;
1925 number_of_simplified_negated_conjecture_clauses = 0;
1926 equals_p = nullptr;
1927 neg_lit = false;
1928 is_first_status = true;
1929 current_clause_name = "";
1930 current_clause_role = "";
1931 current_formula_role = "";
1932 current_formula_name = "";
1933 clause_roles.clear();
1934 clause_names.clear();
1935 fof_clause_names.clear();
1936 formula_roles.clear();
1937 formula_names.clear();
1938 file_contents.clear();
1939 comment_blocks.clear();
1940 status = "";
1941 all_defined.clear();
1942 all_system.clear();
1943 distinct_objects.clear();
1944 current_clause.clear();
1945 current_formula.clear();
1946 all_formulas.clear();
1947 all_clauses.clear();
1948 file_includes.clear();
1949 to_include.clear();
1950 include_this_item = true;
1951 include_file_path = fs::path();
1952 include_file_name = fs::path();
1953}
void clear()
Straightforward reset method.
Definition Clause.hpp:86
void clear()
Make an FOFType::Empty.
Definition FOF.hpp:276

◆ conjecture_present()

bool TPTPParser::conjecture_present ( ) const

Did a conjecture turn up anywhere in the parse?

Definition at line 2126 of file TPTPParser.cpp.

2126 {
2127 return conjecture_found;
2128}

◆ equality_used()

bool TPTPParser::equality_used ( )

Did equality turn up anywhere in the parse?

Definition at line 1963 of file TPTPParser.cpp.

1963 {
1964 return equals_added;
1965}

◆ fof_conjecture_is_false()

bool TPTPParser::fof_conjecture_is_false ( ) const

Self-explanatory.

Definition at line 2149 of file TPTPParser.cpp.

2149 {
2150 return conjecture_false;
2151}

◆ fof_conjecture_is_missing()

bool TPTPParser::fof_conjecture_is_missing ( ) const

Was there a conjecture clause in the problem file?

Definition at line 2153 of file TPTPParser.cpp.

2153 {
2154 return !conjecture_found;
2155}

◆ fof_conjecture_is_true()

bool TPTPParser::fof_conjecture_is_true ( ) const

Self-explanatory.

Definition at line 2144 of file TPTPParser.cpp.

2144 {
2145 return conjecture_true;
2146}

◆ fof_has_axioms()

bool TPTPParser::fof_has_axioms ( ) const

Where there any axioms for an FOF problem before simplification?

Definition at line 2165 of file TPTPParser.cpp.

2165 {
2166 return has_axioms;
2167}

◆ fof_negated_conjecture_removed()

bool TPTPParser::fof_negated_conjecture_removed ( ) const

Was there a conjecture clause that got simplified away?

Definition at line 2157 of file TPTPParser.cpp.

2157 {
2158 return conjecture_found && (number_of_simplified_negated_conjecture_clauses == 0);
2159}

◆ get_defined_items()

vector< string > TPTPParser::get_defined_items ( )

Get a copy of tptp_parser::all_defined.

These are gathered during the parse and may be useful.

Definition at line 1955 of file TPTPParser.cpp.

1955 {
1956 return all_defined;
1957}

◆ get_equals_predicate()

Predicate * TPTPParser::get_equals_predicate ( ) const

If equality turned up anywhere in the parse it will have been turned into an actual Predicate, so this will give you a pointer to it.

Definition at line 1975 of file TPTPParser.cpp.

1975 {
1976 if (equals_added)
1977 return equals_p;
1978 else
1979 return nullptr;
1980}

◆ get_problem_status()

string TPTPParser::get_problem_status ( )

The parse tries to identify the problem status.

Definition at line 1971 of file TPTPParser.cpp.

1971 {
1972 return status;
1973}

◆ get_system_items()

vector< string > TPTPParser::get_system_items ( )

Get a copy of tptp_parser::all_system.

These are gathered during the parse and may be useful.

Definition at line 1959 of file TPTPParser.cpp.

1959 {
1960 return all_system;
1961}

◆ negated_conjecture_present()

bool TPTPParser::negated_conjecture_present ( ) const

Did a negated conjecture turn up anywhere in the parse?

Definition at line 2130 of file TPTPParser.cpp.

2130 {
2131 return negated_conjecture_found;
2132}

◆ no_conjecture_clause()

bool TPTPParser::no_conjecture_clause ( ) const

When you analysed the original problem, did you conclude that it has no conjecture clauses that can be used as a starting point?

Definition at line 2134 of file TPTPParser.cpp.

2134 {
2135 return ((all_formulas.size() > 0 && !conjecture_found) ||
2136 (all_formulas.size() > 0 && (conjecture_true || conjecture_false)) ||
2137 (all_formulas.size() == 0 && !negated_conjecture_found) ||
2138 (all_formulas.size() == 0 && !negated_conjecture_exists));
2139}

◆ number_of_fof_formulas()

size_t TPTPParser::number_of_fof_formulas ( ) const

How many first-order formulas turned up in the parse?

Definition at line 1967 of file TPTPParser.cpp.

1967 {
1968 return all_formulas.size();
1969}

◆ parse_tptp_from_file()

bool TPTPParser::parse_tptp_from_file ( const string & file_name)

Main method to parse from a TPTP file to the data structures needed by the prover.

This first uses read_tptp_from_file to strip out comments. It then uses TPTP_file_grammar with qi::phrase_parse to parse the file.

As a side effect of that, a bunch of things such as all_clauses and clause_roles, which are global in the tptp_parser namespace, get set up. These are then used to populate the matrix etc.

Parameters
file_nameReference to string containing the file name.

Definition at line 1497 of file TPTPParser.cpp.

1497 {
1498 /*
1499 * Let the parser do the heavy-lifting: get stuff from the
1500 * TPTP file and parse it.
1501 */
1502 read_tptp_from_file(file_name);
1503
1504 Iter start = file_contents.begin();
1505 Iter end = file_contents.end();
1506
1507 include_file_path = params::full_problem_path;
1508 fs::path f(file_name);
1509 include_file_name = f.filename().string();
1510
1511 TPTP_file_grammar<Iter> g;
1512 bool result = qi::phrase_parse(start, end, g, ascii::space);
1513
1514 if (start != end || !result)
1515 throw (file_parse_exception(file_name));
1516 /*
1517 * If you get to here, then the parser has read everything and set
1518 * up a whole bunch of stuff for you. In particular, all_clauses and
1519 * all_formulas have the juicy stuff.
1520 *
1521 * However, what follows gets stupidly complicated because you
1522 * have to deal with a lot of rare special cases. :-(
1523 */
1524 if (pip->true_false_added() && params::verbosity > 1)
1525 cout << "Found true/false." << endl;
1526 /*
1527 * First, deal with cnf(...). entries. There's not much to
1528 * do as simplification can happen later.
1529 */
1530 if (negated_conjecture_found && params::verbosity > 1)
1531 cout << "Found negated conjecture." << endl;
1532 /*
1533 * Now do clause conversion for the fof(...). entries.
1534 *
1535 * Remember: negate the conjecture if necessary.
1536 */
1537 if (conjecture_found && params::verbosity > 1 && params::first_parse)
1538 cout << "Found conjecture." << endl;
1539 /*
1540 * Were there any first_order items, or is it just CNF?
1541 */
1542 cnf_only = (all_formulas.size() == 0);
1543 if (cnf_only && params::verbosity > 1)
1544 cout << "The problem is CNF only." << endl;
1545 /*
1546 * First do a check for general oddness.
1547 */
1548 if (negated_conjecture_found && conjecture_found) {
1549 cout << "% SZS status Error for "
1550 << params::problem_name
1551 << " : conjecture and negated conjecture found in the same problem." << endl;
1552 exit(EXIT_FAILURE);
1553 }
1554 if (!negated_conjecture_found && !conjecture_found && params::verbosity > 1) {
1555 cout << "No conjecture or negated conjecture found." << endl;
1556 }
1557 if (negated_conjecture_found && all_formulas.size() > 0 && params::verbosity > 1) {
1558 cout << "% SZS status Error for "
1559 << params::problem_name
1560 << " : negated conjecture found in FOF problem." << endl;
1561 exit(EXIT_FAILURE);
1562 }
1563 /*
1564 * Now we can convert some formulas to clauses.
1565 *
1566 * Remember: different things need to happen here depending on the state
1567 * of params::no_definitional and params::all_definitional.
1568 */
1569 if (params::no_definitional && params::all_definitional) {
1570 cout << "% SZS status Error for "
1571 << params::problem_name
1572 << " : --all-definitional and --no-definitional have both been set." << endl;
1573 exit(EXIT_FAILURE);
1574 }
1575 /*
1576 * Later on I'll need to know whether the original (FOF) problem
1577 * actually had axioms.
1578 */
1579 has_axioms = (all_clauses.size() > 0);
1580 if (!has_axioms) {
1581 for (const string& s : formula_roles) {
1582 if (s != "conjecture") {
1583 has_axioms = true;
1584 break;
1585 }
1586 }
1587 }
1588 /*
1589 * Do the conversion to clauses and store the results.
1590 * Don't simplify yet.
1591 */
1592 vector<vector<Clause>> all_fof_clauses;
1593 bool found_one_conjecture = false;
1594 vector<bool> definitional_conversion;
1595 size_t i = 0;
1596 size_t conjecture_index = 0;
1597 records_p->reset_indices();
1598 records_p->set_current_name("f");
1599 for (FOF f : all_formulas) {
1600 records_p->next_index_1();
1601 records_p->reset_index_2();
1602 records_p->set_current_source(records_p->find_fof_name(i + 1));
1603 records_p->reset_last_f();
1604 check_timeout();
1605 if (params::verbosity > 2) {
1606 cout << "Converting formula: " << std::to_string(i) << endl;
1607 }
1608 vector<Clause> vc;
1609 vector<string> cnf_names;
1610 if (formula_roles[i] == string("conjecture")) {
1611 conjecture_index = i;
1612 if (found_one_conjecture) {
1613 cout << "% SZS status Error for "
1614 << params::problem_name
1615 << " : more than one conjecture in the input file." << endl;
1616 exit(EXIT_FAILURE);
1617 }
1618 else {
1619 found_one_conjecture = true;
1620 }
1621 // This is rather important!
1622 f.negate();
1623 formula_roles[i] = "negated_conjecture";
1624
1625 records_p->set_current_role("negated_conjecture");
1626 records_p->add_fof_inference_record("negate,[status(cth)]",
1627 f.to_tptp_string());
1628 if (!params::no_definitional) {
1629 f.definitional_convert_to_cnf_clauses(vc, cnf_names, formula_roles[i]);
1630 definitional_conversion.push_back(true);
1631 }
1632 else {
1633 f.convert_to_cnf_clauses(vc, cnf_names, formula_roles[i]);
1634 definitional_conversion.push_back(false);
1635 }
1636 number_of_negated_conjecture_clauses = vc.size();
1637 }
1638 else {
1639 records_p->set_current_role("plain");
1640 if (params::all_definitional || !conjecture_found) {
1641 f.definitional_convert_to_cnf_clauses(vc, cnf_names, formula_roles[i]);
1642 definitional_conversion.push_back(true);
1643 }
1644 else {
1645 f.convert_to_cnf_clauses(vc, cnf_names, formula_roles[i]);
1646 definitional_conversion.push_back(false);
1647 }
1648 }
1649 all_fof_clauses.push_back(vc);
1650 fof_clause_names.push_back(cnf_names);
1651 i++;
1652 }
1653 /*
1654 * Now all_fof_clauses has unsimplified clauses, as
1655 * does all_clauses. We also know where any conjecture
1656 * is.
1657 *
1658 * Before doing anything else, it might be that all we
1659 * want is to see the clause conversion.
1660 */
1661 i = 0;
1662 if (params::show_clauses) {
1663 for (vector<Clause>& vc : all_fof_clauses) {
1664 cout << "---------------------" << endl;
1665 cout << "Formula: " << formula_names[i] << ", "
1666 << formula_roles[i] << endl;
1667 cout << all_formulas[i] << endl;
1668 cout << "Clauses:";
1669 if (definitional_conversion[i]) {
1670 cout << " (definitional conversion)";
1671 }
1672 cout << endl;
1674 for (const Clause& c : vc) {
1675 cout << c << endl;
1676 }
1677 i++;
1678 }
1679 exit(EXIT_SUCCESS);
1680 }
1681 /*
1682 * OK - so we've got more to do. Now simplify everything,
1683 * but keep track of any strange cases.
1684 *
1685 * Start with the case when the problem is CNF only.
1686 */
1687 SimplificationResult cnf_result = FOF::simplify_cnf(all_clauses, clause_roles, clause_names);
1688 check_timeout();
1689 /*
1690 * Did we somehow manage to delete all the negated conjectures?
1691 */
1692 for (const string& s : clause_roles) {
1693 if (s == string("negated_conjecture")) {
1694 negated_conjecture_exists = true;
1695 break;
1696 }
1697 }
1698 string output_string;
1699 vector<Clause> simplified_fof_clauses;
1700 vector<string> simplified_fof_roles;
1701 vector<string> simplified_fof_names;
1702 /*
1703 * Note that we can draw the following conclusions regardless of whether
1704 * or not any equality axioms have been added.
1705 */
1706 if (all_formulas.size() == 0) {
1707 if (cnf_result == SimplificationResult::Tautology) {
1708 output_string = "Satisfiable";
1709 }
1710 if (cnf_result == SimplificationResult::Contradiction) {
1711 output_string = "Unsatisfiable";
1712 }
1713 if (output_string != "") {
1714 cout << "% SZS status " << output_string << " for "
1715 << params::problem_name
1716 << " : established by clause simplification." << endl;
1717 if (params::generate_tptp_proof) {
1718 cout << "% SZS output start Proof for " << params::problem_name << endl;
1719 unordered_set<string> names;
1720 cout << records_p->to_tptp_string(names) << endl;
1721 cout << "% SZS output end Proof for " << params::problem_name << endl;
1722 }
1723 std::exit(EXIT_SUCCESS);
1724 }
1725 }
1726 // Here, we know it's a problem with FOF stuff in it.
1727 else {
1728 i = 0;
1729 for (vector<Clause> cs : all_fof_clauses) {
1730 check_timeout();
1731 vector<string> temporary_clause_roles(cs.size(), formula_roles[i]);
1732 vector<string> temporary_clause_names = fof_clause_names[i];
1733
1734 SimplificationResult fof_result = FOF::simplify_cnf(cs,
1735 temporary_clause_roles,
1736 temporary_clause_names);
1737
1738 if (i == conjecture_index && conjecture_found) {
1739 number_of_simplified_negated_conjecture_clauses = cs.size();
1740 }
1741
1742 if (fof_result == SimplificationResult::Tautology) {
1743 if (i == conjecture_index && conjecture_found) {
1744 conjecture_false = true;
1745 if (params::verbosity > 1) {
1746 cout << "The conjecture is equivalent to $false." << endl;
1747 }
1748 }
1749 else {
1750 found_true_axiom = true;
1751 if (params::verbosity > 1) {
1752 cout << "Axiom is equivalent to $true." << endl;
1753 }
1754 }
1755 i++;
1756 continue;
1757 }
1758 else if (fof_result == SimplificationResult::Contradiction) {
1759 if (i == conjecture_index && conjecture_found) {
1760 conjecture_true = true;
1761 if (params::verbosity > 1) {
1762 cout << "The conjecture is equivalent to $true." << endl;
1763 }
1764 }
1765 else {
1766 found_false_axiom = true;
1767 if (params::verbosity > 1) {
1768 cout << "Axiom is equivalent to $false." << endl;
1769 }
1770 }
1771 i++;
1772 continue;
1773 }
1774 else {
1775 size_t j = 0;
1776 for (const Clause& c : cs) {
1777 simplified_fof_clauses.push_back(c);
1778 simplified_fof_roles.push_back(temporary_clause_roles[j]);
1779 simplified_fof_names.push_back(temporary_clause_names[j]);
1780 j++;
1781 }
1782 i++;
1783 }
1784 }
1785 }
1786 /*
1787 * Remember: this actually does some setup work, so don't do it
1788 * until *everything* else is in place. In particular, definitional
1789 * clause conversion can introduce new predicates, so this has to
1790 * happen later.
1791 */
1793
1794 i = 0;
1795 for (Clause& c : all_clauses) {
1796 matrix->add_clause(c, clause_roles[i], clause_names[i]);
1797 i++;
1798 }
1799 /*
1800 * If it's a CNF only problem we're done! However, if there are FOF
1801 * clauses then we have to deal with all the silly possibilities.
1802 */
1803 if (all_formulas.size() > 0) {
1804 /*
1805 * Now I know about all odd instances where a part of the problem
1806 * gave rise to clauses that were equivalent to $true or $false.
1807 *
1808 * Does this allow me to stop?
1809 */
1810 string output_string;
1811 if (cnf_result == SimplificationResult::Contradiction || found_false_axiom) {
1812 if (conjecture_true) {
1813 output_string = "TautologousConclusionContradictoryAxioms";
1814 }
1815 else if (conjecture_false) {
1816 output_string = "UnsatisfiableConclusionContradictoryAxioms";
1817 }
1818 else if (!conjecture_found) {
1819 output_string = "Unsatisfiable";
1820 }
1821 else {
1822 output_string = "ContradictoryAxioms";
1823 }
1824 }
1825 else {
1826 /*
1827 * The case of something in the axioms being $true just shrinks the
1828 * set of axioms. So you need to handle the situation where there
1829 * are no axioms remaining!
1830 */
1831 has_axioms_remaining = (all_clauses.size() > 0);
1832 if (!has_axioms_remaining) {
1833 for (const string& s : simplified_fof_roles) {
1834 if (s != "conjecture") {
1835 has_axioms_remaining = true;
1836 break;
1837 }
1838 }
1839 }
1840 if (has_axioms_remaining) {
1841 /*
1842 * So: assuming you have some axioms, what happens if the conjecture
1843 * was $true or $false?
1844 *
1845 * If the conjecture is $false then, as you have axioms, the outcome
1846 * still needs to be determined in case the axioms are contradictory.
1847 */
1848 if (conjecture_true) {
1849 output_string = "Theorem";
1850 }
1851 /*
1852 * We now have just axioms, or axioms with a false conjecture, so
1853 * keep going and sort it out later --
1854 */
1855 }
1856 /*
1857 * We have no axioms.
1858 */
1859 else {
1860 if (conjecture_true) {
1861 output_string = "Theorem";
1862 }
1863 if (conjecture_false) {
1864 output_string = "CounterSatisfiable";
1865 }
1866 if (!conjecture_found) {
1867 output_string = "Theorem";
1868 }
1869 /*
1870 * We now have just a conjecture (or not), so keep going and sort it out
1871 * later --
1872 */
1873 }
1874 }
1875 if (output_string != "") {
1876 cout << "% SZS status " << output_string << " for "
1877 << params::problem_name
1878 << " : established by clause simplification." << endl;
1879 if (params::generate_tptp_proof) {
1880 cout << "% SZS output start Proof for " << params::problem_name << endl;
1881 unordered_set<string> names;
1882 cout << records_p->to_tptp_string(names) << endl;
1883 cout << "% SZS output end Proof for " << params::problem_name << endl;
1884 }
1885 exit(EXIT_SUCCESS);
1886 }
1887 /*
1888 * If none of the special cases forced us to stop, then add the
1889 * FOF material to the matrix.
1890 */
1891 i = 0;
1892 for (Clause& c : simplified_fof_clauses) {
1893 matrix->add_clause(c, simplified_fof_roles[i], simplified_fof_names[i]);
1894 i++;
1895 }
1896 }
1897 return true;
1898}
Representation of clauses.
Definition Clause.hpp:52
Representation of first order formulas.
Definition FOF.hpp:58
static SimplificationResult simplify_cnf(vector< Clause > &)
Simplify the clauses in a CNF using the method in Clause.
Definition FOF.cpp:1490
void add_clause(Clause &, string="", string="")
Add a Clause to the Matrix and update the index accordingly.
Definition Matrix.cpp:99
void set_num_preds(size_t)
Make an empty index.
Definition Matrix.cpp:46
bool true_false_added() const
Sometimes $true and $false appear in the TPTP collection. See if you included them during the parsing...
size_t get_num_preds() const
Basic get method.
void check_timeout()
void read_tptp_from_file(const string &)
Read the file into a string, while stripping out and collecting comment blocks.
string to_tptp_string(const unordered_set< string > &)
Format everything.
Exception used by the application in main(...).

◆ problem_is_cnf_only()

bool TPTPParser::problem_is_cnf_only ( ) const

Self-explanatory.

Definition at line 2140 of file TPTPParser.cpp.

2140 {
2141 return cnf_only;
2142}

◆ read_tptp_from_file()

void TPTPParser::read_tptp_from_file ( const string & file_name)
private

Read the file into a string, while stripping out and collecting comment blocks.

(Yes, better done with a custom skip parser, but writing those is a pain.)

Parameters
file_nameReference to a string containing the file name

Definition at line 1453 of file TPTPParser.cpp.

1453 {
1454 // Used to collect up comments as you see them.
1455 string comment;
1456 bool in_comment = false;
1457
1458 char c;
1459
1460 ifstream file;
1461 file.unsetf(std::ios_base::skipws);
1462 file.open(file_name);
1463 if (file.fail()) {
1464 throw (file_open_exception(file_name));
1465 }
1466 file.get(c);
1467 while (file.good()) {
1468 // Detect the start of a comment.
1469 if (!in_comment && c == '/') {
1470 if (file.peek() == '*') {
1471 file.get(c);
1472 in_comment = true;
1473 comment.clear();
1474 }
1475 else file_contents += c;
1476 }
1477 // Detect the end of a comment.
1478 else if (in_comment && c == '*') {
1479 if (file.peek() == '/') {
1480 file.get(c);
1481 in_comment = false;
1482 comment_blocks.push_back(comment);
1483 }
1484 else comment += c;
1485 }
1486 // Nothings to see. We're just adding to the
1487 // relevant output.
1488 else if (in_comment)
1489 comment += c;
1490 else
1491 file_contents += c;
1492 file.get(c);
1493 }
1494 file.close();
1495}
Exception used by the application in main(...).

◆ show_file_includes()

void TPTPParser::show_file_includes ( )

Show any includes present in the TPTP file.

These are collected as part of the parse.

Definition at line 1900 of file TPTPParser.cpp.

1900 {
1901 for (FileIncludeItem i : file_includes) {
1902 cout << "From " << i.first << ": ";
1903 if (i.second.size() == 0)
1904 cout << "all";
1905 else
1906 for (string s : i.second)
1907 cout << s << " ";
1908 cout << endl;
1909 }
1910}

◆ simplified_fof_has_axioms()

bool TPTPParser::simplified_fof_has_axioms ( ) const

Where there any axioms for an FOF problem after simplification?

Definition at line 2161 of file TPTPParser.cpp.

2161 {
2162 return has_axioms_remaining;
2163}

Member Data Documentation

◆ comment_blocks

vector<string> TPTPParser::comment_blocks
private

Each comment is stored here.

Definition at line 672 of file TPTPParser.hpp.

◆ file_contents

string TPTPParser::file_contents
private

Contents of the TPTP file, with comments removed.

Assuming of course that you used read_tptp_from_file.

Definition at line 668 of file TPTPParser.hpp.

◆ fip

FunctionIndex* TPTPParser::fip
private

The class has pointers to all the relevant indices.

These are used directly to make the actual data structures used by the prover.

Definition at line 686 of file TPTPParser.hpp.

◆ matrix

Matrix* TPTPParser::matrix
private

The class has a pointer to the matrix, and can therefore construct it as it parses.

Definition at line 705 of file TPTPParser.hpp.

◆ pip

PredicateIndex* TPTPParser::pip
private

The class has pointers to all the relevant indices.

These are used directly to make the actual data structures used by the prover.

Definition at line 700 of file TPTPParser.hpp.

◆ tip

TermIndex* TPTPParser::tip
private

The class has pointers to all the relevant indices.

These are used directly to make the actual data structures used by the prover.

Definition at line 693 of file TPTPParser.hpp.

◆ tptp_proof_output_p

TPTPRecords* TPTPParser::tptp_proof_output_p
private

Used to build the complete TPTP description of the proof process that's completed by the parser.

Definition at line 710 of file TPTPParser.hpp.

◆ vip

VariableIndex* TPTPParser::vip
private

The class has pointers to all the relevant indices.

These are used directly to make the actual data structures used by the prover.

Definition at line 679 of file TPTPParser.hpp.


The documentation for this class was generated from the following files: