Connect++ 0.5.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 *)
 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.
 

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 658 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

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

1897 {
1898 equals_added = false;
1899 conjecture_found = false;
1900 negated_conjecture_found = false;
1901 conjecture_true = false;
1902 conjecture_false = false;
1903 found_true_axiom = false;
1904 found_false_axiom = false;
1905 negated_conjecture_exists = false;
1906 has_axioms = false;
1907 has_axioms_remaining = false;
1908 cnf_only = false;
1909 number_of_negated_conjecture_clauses = 0;
1910 number_of_simplified_negated_conjecture_clauses = 0;
1911 equals_p = nullptr;
1912 neg_lit = false;
1913 is_first_status = true;
1914 current_clause_role = "";
1915 current_formula_role = "";
1916 current_formula_name = "";
1917 clause_roles.clear();
1918 formula_roles.clear();
1919 formula_names.clear();
1920 file_contents.clear();
1921 comment_blocks.clear();
1922 status = "";
1923 all_defined.clear();
1924 all_system.clear();
1925 distinct_objects.clear();
1926 current_clause.clear();
1927 current_formula.clear();
1928 all_formulas.clear();
1929 all_clauses.clear();
1930 file_includes.clear();
1931 to_include.clear();
1932 include_this_item = true;
1933 include_file_path = fs::path();
1934}
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 2103 of file TPTPParser.cpp.

2103 {
2104 return conjecture_found;
2105}

◆ equality_used()

bool TPTPParser::equality_used ( )

Did equality turn up anywhere in the parse?

Definition at line 1944 of file TPTPParser.cpp.

1944 {
1945 return equals_added;
1946}

◆ fof_conjecture_is_false()

bool TPTPParser::fof_conjecture_is_false ( ) const

Self-explanatory.

Definition at line 2126 of file TPTPParser.cpp.

2126 {
2127 return conjecture_false;
2128}

◆ fof_conjecture_is_missing()

bool TPTPParser::fof_conjecture_is_missing ( ) const

Was there a conjecture clause in the problem file?

Definition at line 2130 of file TPTPParser.cpp.

2130 {
2131 return !conjecture_found;
2132}

◆ fof_conjecture_is_true()

bool TPTPParser::fof_conjecture_is_true ( ) const

Self-explanatory.

Definition at line 2121 of file TPTPParser.cpp.

2121 {
2122 return conjecture_true;
2123}

◆ fof_has_axioms()

bool TPTPParser::fof_has_axioms ( ) const

Where there any axioms for an FOF problem before simplification?

Definition at line 2142 of file TPTPParser.cpp.

2142 {
2143 return has_axioms;
2144}

◆ fof_negated_conjecture_removed()

bool TPTPParser::fof_negated_conjecture_removed ( ) const

Was there a conjecture clause that got simplified away?

Definition at line 2134 of file TPTPParser.cpp.

2134 {
2135 return conjecture_found && (number_of_simplified_negated_conjecture_clauses == 0);
2136}

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

1936 {
1937 return all_defined;
1938}

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

1956 {
1957 if (equals_added)
1958 return equals_p;
1959 else
1960 return nullptr;
1961}

◆ get_problem_status()

string TPTPParser::get_problem_status ( )

The parse tries to identify the problem status.

Definition at line 1952 of file TPTPParser.cpp.

1952 {
1953 return status;
1954}

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

1940 {
1941 return all_system;
1942}

◆ get_tptp_conversion_string()

string TPTPParser::get_tptp_conversion_string ( ) const
inline

Self-explanatory.

Definition at line 836 of file TPTPParser.hpp.

836 {
838 }

◆ negated_conjecture_present()

bool TPTPParser::negated_conjecture_present ( ) const

Did a negated conjecture turn up anywhere in the parse?

Definition at line 2107 of file TPTPParser.cpp.

2107 {
2108 return negated_conjecture_found;
2109}

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

2111 {
2112 return ((all_formulas.size() > 0 && !conjecture_found) ||
2113 (all_formulas.size() > 0 && (conjecture_true || conjecture_false)) ||
2114 (all_formulas.size() == 0 && !negated_conjecture_found) ||
2115 (all_formulas.size() == 0 && !negated_conjecture_exists));
2116}

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

1948 {
1949 return all_formulas.size();
1950}

◆ 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 and 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 vector<Clause> vc;
1579 if (formula_roles[i] == string("conjecture")) {
1580 conjecture_index = i;
1581 if (found_one_conjecture) {
1582 cout << "% SZS status Error for "
1583 << params::problem_name
1584 << " : more than one conjecture in the input file." << endl;
1585 exit(EXIT_FAILURE);
1586 }
1587 else {
1588 found_one_conjecture = true;
1589 }
1590 // This is rather important!
1591 f.negate();
1592 if (!params::no_definitional) {
1593 f.definitional_convert_to_cnf_clauses(vc);
1594 definitional_conversion.push_back(true);
1595 }
1596 else {
1597 f.convert_to_cnf_clauses(vc);
1598 definitional_conversion.push_back(false);
1599 }
1600 number_of_negated_conjecture_clauses = vc.size();
1601 }
1602 else {
1603 if (params::all_definitional || !conjecture_found) {
1604 f.definitional_convert_to_cnf_clauses(vc);
1605 definitional_conversion.push_back(true);
1606 }
1607 else {
1608 f.convert_to_cnf_clauses(vc);
1609 definitional_conversion.push_back(false);
1610 }
1611 }
1612 all_fof_clauses.push_back(vc);
1613 i++;
1614 }
1615 /*
1616 * Now all_fof_clauses has unsimplified clauses, as
1617 * does all_clauses. We also know where any conjecture
1618 * is.
1619 *
1620 * Before doing anything else, it might be that all we
1621 * want is to see the clause conversion.
1622 */
1623 i = 0;
1624 if (params::show_clauses) {
1625 for (vector<Clause>& vc : all_fof_clauses) {
1626 cout << "---------------------" << endl;
1627 cout << "Formula: " << formula_names[i] << ", "
1628 << formula_roles[i] << endl;
1629 cout << all_formulas[i] << endl;
1630 cout << "Clauses:";
1631 if (definitional_conversion[i]) {
1632 cout << " (definitional conversion)";
1633 }
1634 cout << endl;
1636 for (const Clause& c : vc) {
1637 cout << c << endl;
1638 }
1639 i++;
1640 }
1641 exit(EXIT_SUCCESS);
1642 }
1643 /*
1644 * OK - so we've got more to do. Now simplify everything,
1645 * but keep track of any strange cases.
1646 *
1647 * Start with the case when the problem is CNF only.
1648 */
1649 SimplificationResult cnf_result = FOF::simplify_cnf(all_clauses, clause_roles);
1650 /*
1651 * Did we somehow manage to delete all the negated conjectures?
1652 */
1653 for (const string& s : clause_roles) {
1654 if (s == string("negated_conjecture")) {
1655 negated_conjecture_exists = true;
1656 break;
1657 }
1658 }
1659 string output_string;
1660 vector<Clause> simplified_fof_clauses;
1661 vector<string> simplified_fof_roles;
1662 /*
1663 * Note that we can draw the following conclusions regardless of whether
1664 * or not any equality axioms have been added.
1665 */
1666 if (all_formulas.size() == 0) {
1667 if (cnf_result == SimplificationResult::Tautology) {
1668 output_string = "Satisfiable";
1669 }
1670 if (cnf_result == SimplificationResult::Contradiction) {
1671 output_string = "Unsatisfiable";
1672 }
1673 if (output_string != "") {
1674 cout << "% SZS status " << output_string << " for "
1675 << params::problem_name
1676 << " : established by clause simplification." << endl;
1677 std::exit(EXIT_SUCCESS);
1678 }
1679 }
1680 // Here, we know it's a problem with FOF stuff in it.
1681 else {
1682 i = 0;
1683 for (vector<Clause> cs : all_fof_clauses) {
1684 SimplificationResult fof_result = FOF::simplify_cnf(cs);
1685
1686 if (i == conjecture_index && conjecture_found) {
1687 number_of_simplified_negated_conjecture_clauses = cs.size();
1688 }
1689
1690 if (params::generate_tptp_proof) {
1691 tptp_conversion_string += "\n% Formula: ";
1692 tptp_conversion_string += formula_names[i];
1693 tptp_conversion_string += " ( ";
1694 tptp_conversion_string += formula_roles[i];
1695 tptp_conversion_string += " ) ";
1696 if (definitional_conversion[i]) {
1697 tptp_conversion_string += "(definitionally) ";
1698 }
1699 tptp_conversion_string += "converted to clauses:\n";
1700 }
1701
1702 if (fof_result == SimplificationResult::Tautology) {
1703 if (i == conjecture_index && conjecture_found) {
1704 conjecture_false = true;
1705 if (params::verbosity > 1) {
1706 cout << "The conjecture is equivalent to $false." << endl;
1707 }
1708 }
1709 else {
1710 found_true_axiom = true;
1711 if (params::verbosity > 1) {
1712 cout << "Axiom is equivalent to $true." << endl;
1713 }
1714 }
1715 if (params::generate_tptp_proof) {
1716 tptp_conversion_string += "cnf(";
1717 tptp_conversion_string += string(formula_names[i]);
1718 tptp_conversion_string += ", ";
1719 if (formula_roles[i] == string("conjecture"))
1720 tptp_conversion_string += "negated_conjecture";
1721 else
1722 tptp_conversion_string += formula_roles[i];
1723 tptp_conversion_string += ", $true).\n";
1724 }
1725 i++;
1726 continue;
1727 }
1728 else if (fof_result == SimplificationResult::Contradiction) {
1729 if (i == conjecture_index && conjecture_found) {
1730 conjecture_true = true;
1731 if (params::verbosity > 1) {
1732 cout << "The conjecture is equivalent to $true." << endl;
1733 }
1734 }
1735 else {
1736 found_false_axiom = true;
1737 if (params::verbosity > 1) {
1738 cout << "Axiom is equivalent to $false." << endl;
1739 }
1740 }
1741 if (params::generate_tptp_proof) {
1742 tptp_conversion_string += "cnf(";
1743 tptp_conversion_string += string(formula_names[i]);
1744 tptp_conversion_string += ", ";
1745 if (formula_roles[i] == string("conjecture"))
1746 tptp_conversion_string += "negated_conjecture";
1747 else
1748 tptp_conversion_string += formula_roles[i];
1749 tptp_conversion_string += ", $false).\n";
1750 }
1751 i++;
1752 continue;
1753 }
1754 else {
1755 size_t clause_count = 1;
1756 for (const Clause& c : cs) {
1757 simplified_fof_clauses.push_back(c);
1758 simplified_fof_roles.push_back(formula_roles[i]);
1759 if (params::generate_tptp_proof) {
1760 tptp_conversion_string += "cnf(";
1761 tptp_conversion_string += string(formula_names[i]);
1763 tptp_conversion_string += std::to_string(clause_count);
1764 tptp_conversion_string += ", ";
1765 if (formula_roles[i] == string("conjecture"))
1766 tptp_conversion_string += "negated_conjecture";
1767 else
1768 tptp_conversion_string += formula_roles[i];
1769 tptp_conversion_string += ", ";
1770 tptp_conversion_string += c.to_tptp_string();
1771 tptp_conversion_string += ").";
1772 tptp_conversion_string += "\n";
1773 }
1774 clause_count++;
1775 }
1776 i++;
1777 }
1778 }
1779 }
1780 /*
1781 * Remember: this actually does some setup work, so don't do it
1782 * until *everything* else is in place. In particular, definitional
1783 * clause conversion can introduce new predicates, so this has to
1784 * happen later.
1785 */
1787
1788 i = 0;
1789 for (Clause& c : all_clauses)
1790 matrix->add_clause(c, clause_roles[i++]);
1791 /*
1792 * If it's a CNF only problem we're done! However, if there are FOF
1793 * clauses then we have to deal with all the silly possibilities.
1794 */
1795 if (all_formulas.size() > 0) {
1796 /*
1797 * Now I know about all odd instances where a part of the problem
1798 * gave rise to clauses that were equivalent to $true or $false.
1799 *
1800 * Does this allow me to stop?
1801 */
1802 string output_string;
1803 if (cnf_result == SimplificationResult::Contradiction || found_false_axiom) {
1804 if (conjecture_true) {
1805 output_string = "TautologousConclusionContradictoryAxioms";
1806 }
1807 else if (conjecture_false) {
1808 output_string = "UnsatisfiableConclusionContradictoryAxioms";
1809 }
1810 else if (!conjecture_found) {
1811 output_string = "Unsatisfiable";
1812 }
1813 else {
1814 output_string = "ContradictoryAxioms";
1815 }
1816 }
1817 else {
1818 /*
1819 * The case of something in the axioms being $true just shrinks the
1820 * set of axioms. So you need to handle the situation where there
1821 * are no axioms remaining!
1822 */
1823 has_axioms_remaining = (all_clauses.size() > 0);
1824 if (!has_axioms_remaining) {
1825 for (const string& s : simplified_fof_roles) {
1826 if (s != "conjecture") {
1827 has_axioms_remaining = true;
1828 break;
1829 }
1830 }
1831 }
1832 if (has_axioms_remaining) {
1833 /*
1834 * So: assuming you have some axioms, what happens if the conjecture
1835 * was $true or $false?
1836 *
1837 * If the conjecture is $false then, as you have axioms, the outcome
1838 * still needs to be determined in case the axioms are contradictory.
1839 */
1840 if (conjecture_true) {
1841 output_string = "Theorem";
1842 }
1843 /*
1844 * We now have just axioms, or axioms with a false conjecture, so
1845 * keep going and sort it out later --
1846 */
1847 }
1848 /*
1849 * We have no axioms.
1850 */
1851 else {
1852 if (conjecture_true) {
1853 output_string = "Theorem";
1854 }
1855 if (conjecture_false) {
1856 output_string = "CounterSatisfiable";
1857 }
1858 if (!conjecture_found) {
1859 output_string = "Theorem";
1860 }
1861 /*
1862 * We now have just a conjecture (or not), so keep going and sort it out
1863 * later --
1864 */
1865 }
1866 }
1867 if (output_string != "") {
1868 cout << "% SZS status " << output_string << " for "
1869 << params::problem_name
1870 << " : established by clause simplification." << endl;
1871 exit(EXIT_SUCCESS);
1872 }
1873 /*
1874 * If none of the special cases forced us to stop, then add the
1875 * FOF material to the matrix.
1876 */
1877 i = 0;
1878 for (Clause& c : simplified_fof_clauses) {
1879 matrix->add_clause(c, simplified_fof_roles[i++]);
1880 }
1881 }
1882 return true;
1883}
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:91
void set_num_preds(size_t)
Make an empty index.
Definition Matrix.cpp:42
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 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 2117 of file TPTPParser.cpp.

2117 {
2118 return cnf_only;
2119}

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

1885 {
1886 for (FileIncludeItem i : file_includes) {
1887 cout << "From " << i.first << ": ";
1888 if (i.second.size() == 0)
1889 cout << "all";
1890 else
1891 for (string s : i.second)
1892 cout << s << " ";
1893 cout << endl;
1894 }
1895}

◆ simplified_fof_has_axioms()

bool TPTPParser::simplified_fof_has_axioms ( ) const

Where there any axioms for an FOF problem after simplification?

Definition at line 2138 of file TPTPParser.cpp.

2138 {
2139 return has_axioms_remaining;
2140}

Member Data Documentation

◆ comment_blocks

vector<string> TPTPParser::comment_blocks
private

Each comment is stored here.

Definition at line 669 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 665 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 683 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 702 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 697 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 690 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 707 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 676 of file TPTPParser.hpp.


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