Connect++ 0.6.0
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;
77public:
86 PredicateIndex(const PredicateIndex&&) = delete;
87 PredicateIndex& operator=(const PredicateIndex&) = delete;
88 PredicateIndex& operator=(const PredicateIndex&&) = delete;
92 inline size_t get_num_preds() const { return preds.size(); }
99 Predicate* add_predicate(const string&, Arity);
106 Predicate* find_predicate(const string&, Arity);
110 Arity find_maximum_arity() const;
116 bool true_false_added() const;
121 Predicate* operator[](size_t i) { return preds[i]; }
128 return add_predicate(
129 params::definitional_predicate_prefix + std::to_string(next_definitional_id++),
130 arity);
131 }
132
133 friend ostream& operator<<(ostream&, const PredicateIndex&);
134};
135
136#endif
Basic representation of predicates: here just names, ids and arities.
Definition Predicate.hpp:51
Management of Predicate objects.
vector< Predicate * > preds
Pointers to all predicates.
ID next_definitional_id
Automatically generate IDs for definitional predicates.
Predicate * make_definitional_predicate(Arity arity)
Make a new, unique definitional predicate.
Predicate * find_predicate(const string &, Arity)
Self-explanatory.
Predicate * add_predicate(const string &, Arity)
Self-explanatory.
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.
ID next_index
Automatically generate IDs.
Predicate * operator[](size_t i)
Access to Predicate pointers, but don't mess with them!
Arity find_maximum_arity() const
Find the largest arity appearing in the index.
PredicateIndex(const PredicateIndex &)=delete
Copying these is a terrible idea.
unordered_map< PredIndexType, Predicate *, fun_hash > name_index
Fast lookup using name and arity.