Connect++ 0.6.1
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 *)
 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?
 
string get_tptp_conversion_string () const
 Self-explanatory.
 

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.
 
string tptp_conversion_string
 Used to build a string containing the TPTP-friendly description of the clause conversion.
 

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 659 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 )

The only constructor that makes sense.

Definition at line 1406 of file TPTPParser.cpp.

1413:
1416vip(new_vip),
1417fip(new_fip),
1418tip(new_tip),
1419pip(new_pip),
1420matrix(new_matrix) {
1421 // var_index_p is global in the tptp_parser namespace. It is
1422 // used by semantic actions.
1423 var_index_p = new_vip;
1424 // Similar for fun_index_p and so on...
1425 fun_index_p = new_fip;
1426 t_index_p = new_tip;
1427 p_index_p = new_pip;
1428 // And remember that FOF also needs to use the indices.
1429 FOF::set_indexes(std::tuple<VariableIndex*, FunctionIndex*, PredicateIndex*, TermIndex*>
1430 (new_vip, new_fip, new_pip, new_tip));
1431 clear();
1433};
static void set_indexes(std::tuple< VariableIndex *, FunctionIndex *, PredicateIndex *, TermIndex * > is)
Set up pointer to the variable index etc.
Definition FOF.hpp:236
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.
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.
string tptp_conversion_string
Used to build a string containing the TPTP-friendly description of the clause conversion.
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 723 of file TPTPParser.hpp.

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

◆ 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 1903 of file TPTPParser.cpp.

1903 {
1904 equals_added = false;
1905 conjecture_found = false;
1906 negated_conjecture_found = false;
1907 conjecture_true = false;
1908 conjecture_false = false;
1909 found_true_axiom = false;
1910 found_false_axiom = false;
1911 negated_conjecture_exists = false;
1912 has_axioms = false;
1913 has_axioms_remaining = false;
1914 cnf_only = false;
1915 number_of_negated_conjecture_clauses = 0;
1916 number_of_simplified_negated_conjecture_clauses = 0;
1917 equals_p = nullptr;
1918 neg_lit = false;
1919 is_first_status = true;
1920 current_clause_role = "";
1921 current_formula_role = "";
1922 current_formula_name = "";
1923 clause_roles.clear();
1924 formula_roles.clear();
1925 formula_names.clear();
1926 file_contents.clear();
1927 comment_blocks.clear();
1928 status = "";
1929 all_defined.clear();
1930 all_system.clear();
1931 distinct_objects.clear();
1932 current_clause.clear();
1933 current_formula.clear();
1934 all_formulas.clear();
1935 all_clauses.clear();
1936 file_includes.clear();
1937 to_include.clear();
1938 include_this_item = true;
1939 include_file_path = fs::path();
1940}
void clear()
Straightforward reset method.
Definition Clause.hpp:86
void clear()
Make an FOFType::Empty.
Definition FOF.hpp:265

◆ conjecture_present()

bool TPTPParser::conjecture_present ( ) const

Did a conjecture turn up anywhere in the parse?

Definition at line 2109 of file TPTPParser.cpp.

2109 {
2110 return conjecture_found;
2111}

◆ equality_used()

bool TPTPParser::equality_used ( )

Did equality turn up anywhere in the parse?

Definition at line 1950 of file TPTPParser.cpp.

1950 {
1951 return equals_added;
1952}

◆ fof_conjecture_is_false()

bool TPTPParser::fof_conjecture_is_false ( ) const

Self-explanatory.

Definition at line 2132 of file TPTPParser.cpp.

2132 {
2133 return conjecture_false;
2134}

◆ fof_conjecture_is_missing()

bool TPTPParser::fof_conjecture_is_missing ( ) const

Was there a conjecture clause in the problem file?

Definition at line 2136 of file TPTPParser.cpp.

2136 {
2137 return !conjecture_found;
2138}

◆ fof_conjecture_is_true()

bool TPTPParser::fof_conjecture_is_true ( ) const

Self-explanatory.

Definition at line 2127 of file TPTPParser.cpp.

2127 {
2128 return conjecture_true;
2129}

◆ fof_has_axioms()

bool TPTPParser::fof_has_axioms ( ) const

Where there any axioms for an FOF problem before simplification?

Definition at line 2148 of file TPTPParser.cpp.

2148 {
2149 return has_axioms;
2150}

◆ fof_negated_conjecture_removed()

bool TPTPParser::fof_negated_conjecture_removed ( ) const

Was there a conjecture clause that got simplified away?

Definition at line 2140 of file TPTPParser.cpp.

2140 {
2141 return conjecture_found && (number_of_simplified_negated_conjecture_clauses == 0);
2142}

◆ 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 1942 of file TPTPParser.cpp.

1942 {
1943 return all_defined;
1944}

◆ 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 1962 of file TPTPParser.cpp.

1962 {
1963 if (equals_added)
1964 return equals_p;
1965 else
1966 return nullptr;
1967}

◆ get_problem_status()

string TPTPParser::get_problem_status ( )

The parse tries to identify the problem status.

Definition at line 1958 of file TPTPParser.cpp.

1958 {
1959 return status;
1960}

◆ 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 1946 of file TPTPParser.cpp.

1946 {
1947 return all_system;
1948}

◆ get_tptp_conversion_string()

string TPTPParser::get_tptp_conversion_string ( ) const
inline

Self-explanatory.

Definition at line 852 of file TPTPParser.hpp.

852 {
854 }

◆ negated_conjecture_present()

bool TPTPParser::negated_conjecture_present ( ) const

Did a negated conjecture turn up anywhere in the parse?

Definition at line 2113 of file TPTPParser.cpp.

2113 {
2114 return negated_conjecture_found;
2115}

◆ 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 2117 of file TPTPParser.cpp.

2117 {
2118 return ((all_formulas.size() > 0 && !conjecture_found) ||
2119 (all_formulas.size() > 0 && (conjecture_true || conjecture_false)) ||
2120 (all_formulas.size() == 0 && !negated_conjecture_found) ||
2121 (all_formulas.size() == 0 && !negated_conjecture_exists));
2122}

◆ 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 1954 of file TPTPParser.cpp.

1954 {
1955 return all_formulas.size();
1956}

◆ 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 1479 of file TPTPParser.cpp.

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

◆ problem_is_cnf_only()

bool TPTPParser::problem_is_cnf_only ( ) const

Self-explanatory.

Definition at line 2123 of file TPTPParser.cpp.

2123 {
2124 return cnf_only;
2125}

◆ 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 1435 of file TPTPParser.cpp.

1435 {
1436 // Used to collect up comments as you see them.
1437 string comment;
1438 bool in_comment = false;
1439
1440 char c;
1441
1442 ifstream file;
1443 file.unsetf(std::ios_base::skipws);
1444 file.open(file_name);
1445 if (file.fail()) {
1446 throw (file_open_exception(file_name));
1447 }
1448 file.get(c);
1449 while (file.good()) {
1450 // Detect the start of a comment.
1451 if (!in_comment && c == '/') {
1452 if (file.peek() == '*') {
1453 file.get(c);
1454 in_comment = true;
1455 comment.clear();
1456 }
1457 else file_contents += c;
1458 }
1459 // Detect the end of a comment.
1460 else if (in_comment && c == '*') {
1461 if (file.peek() == '/') {
1462 file.get(c);
1463 in_comment = false;
1464 comment_blocks.push_back(comment);
1465 }
1466 else comment += c;
1467 }
1468 // Nothings to see. We're just adding to the
1469 // relevant output.
1470 else if (in_comment)
1471 comment += c;
1472 else
1473 file_contents += c;
1474 file.get(c);
1475 }
1476 file.close();
1477}
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 1891 of file TPTPParser.cpp.

1891 {
1892 for (FileIncludeItem i : file_includes) {
1893 cout << "From " << i.first << ": ";
1894 if (i.second.size() == 0)
1895 cout << "all";
1896 else
1897 for (string s : i.second)
1898 cout << s << " ";
1899 cout << endl;
1900 }
1901}

◆ simplified_fof_has_axioms()

bool TPTPParser::simplified_fof_has_axioms ( ) const

Where there any axioms for an FOF problem after simplification?

Definition at line 2144 of file TPTPParser.cpp.

2144 {
2145 return has_axioms_remaining;
2146}

Member Data Documentation

◆ comment_blocks

vector<string> TPTPParser::comment_blocks
private

Each comment is stored here.

Definition at line 670 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 666 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 684 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 703 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 698 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 691 of file TPTPParser.hpp.

◆ tptp_conversion_string

string TPTPParser::tptp_conversion_string
private

Used to build a string containing the TPTP-friendly description of the clause conversion.

Definition at line 708 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 677 of file TPTPParser.hpp.


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