Connect++ 0.1
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
PredicateIndex.hpp
1/*
2
3Copyright © 2023-24 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 PREDICATEINDEX_HPP
26#define PREDICATEINDEX_HPP
27
28#include<iostream>
29#include<iomanip>
30#include<string>
31#include<vector>
32#include<unordered_map>
33
34#include "Predicate.hpp"
35#include "FunctionHash.hpp"
36
37using std::pair;
38using std::vector;
39using std::unordered_map;
40using std::string;
41using std::ostream;
42using std::endl;
43using std::cerr;
44
45using PredIndexType = pair<string, Arity>;
46using PredMapType = pair<PredIndexType, Predicate*>;
47
59private:
63 vector<Predicate*> preds;
67 unordered_map<PredIndexType, Predicate*, fun_hash> name_index;
71 ID next_index;
72public:
81 PredicateIndex(const PredicateIndex&&) = delete;
82 PredicateIndex& operator=(const PredicateIndex&) = delete;
83 PredicateIndex& operator=(const PredicateIndex&&) = delete;
87 inline size_t get_num_preds() const { return preds.size(); }
94 Predicate* add_predicate(const string&, Arity);
101 Predicate* find_predicate(const string&, Arity);
105 Arity find_maximum_arity() const;
111 bool true_false_added() const;
116 Predicate* operator[](size_t i) { return preds[i]; }
117
118 friend ostream& operator<<(ostream&, const PredicateIndex&);
119};
120
121#endif
Basic representation of predicates: here just names, ids and arities.
Definition Predicate.hpp:51
Management of Predicate objects.
Definition PredicateIndex.hpp:58
Predicate * find_predicate(const string &, Arity)
Self-explanatory.
Definition PredicateIndex.cpp:54
Predicate * add_predicate(const string &, Arity)
Self-explanatory.
Definition PredicateIndex.cpp:39
bool true_false_added() const
Sometimes $true and $false appear in the TPTP collection. See if you included them during the parsing...
Definition PredicateIndex.cpp:75
size_t get_num_preds() const
Basic get method.
Definition PredicateIndex.hpp:87
Predicate * operator[](size_t i)
Access to Predicate pointers, but don't mess with them!
Definition PredicateIndex.hpp:116
Arity find_maximum_arity() const
Find the largest arity appearing in the index.
Definition PredicateIndex.cpp:65
PredicateIndex(const PredicateIndex &)=delete
Copying these is a terrible idea.