Connect++ 0.1
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
Clause.hpp
1/*
2
3Copyright © 2023 Sean Holden. All rights reserved.
4
5*/
6/*
7
8This file is part of Connect++.
9
10Connect++ is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License as published by the
12Free Software Foundation, either version 3 of the License, or (at your
13option) any later version.
14
15Connect++ is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18more details.
19
20You should have received a copy of the GNU General Public License along
21with Connect++. If not, see <https://www.gnu.org/licenses/>.
22
23*/
24
25#ifndef CLAUSE_HPP
26#define CLAUSE_HPP
27
28#include<iostream>
29#include<string>
30#include<vector>
31
32#include "Literal.hpp"
33
34using std::vector;
35using std::string;
36using std::ostream;
37using std::endl;
38
45class Clause {
46private:
50 vector<Literal> c;
51public:
52 Clause() : c() {}
58 Clause(const vector<Literal>& new_lits) : c(new_lits) {
59 #ifdef DEBUGMESSAGES
60 if (new_lits.size() == 0)
61 cerr << "Why are you constructing an empty clause?" << endl;
62 #endif
63 }
67 inline size_t size() const { return c.size(); }
71 inline bool empty() const { return c.empty(); }
75 inline void clear() { c.clear(); }
79 bool is_positive() const;
83 bool is_negative() const;
92 void add_lit(const Literal&);
98 void drop_literal(LitNum);
104 Literal extract_literal(LitNum);
113 Literal& operator[](size_t);
130 string to_string(bool = false) const;
136 string to_prolog_string() const;
144 string make_LaTeX(bool = false) const;
145
146 vector<Literal>::const_iterator cbegin() const { return c.cbegin(); }
147 vector<Literal>::const_iterator cend() const { return c.cend(); }
148 vector<Literal>::iterator begin() { return c.begin(); }
149 vector<Literal>::iterator end() { return c.end(); }
150
151 friend ostream& operator<<(ostream&, const Clause&);
152};
153
154#endif
Representation of clauses.
Definition Clause.hpp:45
Literal & operator[](size_t)
Direct read of the specified Literal.
Definition Clause.cpp:120
Literal extract_literal(LitNum)
Get rid of and return the specified Literal.
Definition Clause.cpp:96
bool empty() const
Straightforward get method.
Definition Clause.hpp:71
void clear()
Straightforward reset method.
Definition Clause.hpp:75
string to_prolog_string() const
Convert to a string that can be read by Prolog.
Definition Clause.cpp:139
Clause make_copy_with_new_vars(VariableIndex &, TermIndex &) const
Make a copy of an entire clause, introducing new variables.
Definition Clause.cpp:63
bool is_positive() const
A clause is positive if it has no negated literals.
Definition Clause.cpp:28
void add_lit(const Literal &)
Add a literal, making sure you don't duplicate.
Definition Clause.cpp:52
size_t size() const
Straightforward get method.
Definition Clause.hpp:67
bool is_negative() const
A clause is negative if it has only negated literals.
Definition Clause.cpp:40
string make_LaTeX(bool=false) const
Convert the clause to a LaTeX representation.
Definition Clause.cpp:150
Clause(const vector< Literal > &new_lits)
Construction is just taking a new vector of Literals.
Definition Clause.hpp:58
void drop_literal(LitNum)
Get rid of the specified Literal.
Definition Clause.cpp:75
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of argume...
Definition Literal.hpp:50
Look after terms, using hash consing to avoid storing copies of terms.
Definition TermIndex-hash.hpp:26
Storage of named variables, and management of new, anonymous variables.
Definition VariableIndex.hpp:61