Connect++ 0.5.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
TermIndex.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 TERMINDEX_HPP
26#define TERMINDEX_HPP
27
28#include <iostream>
29#include <vector>
30#include <unordered_map>
31
32/*
33* Not necessarily needed -- only if HASHCONSTERMS is defined.
34* But no harm in including it.
35*/
36#include "TermHash.hpp"
37
38using std::unordered_map;
39using std::vector;
40using std::ostream;
41using std::endl;
42
75class TermIndex {
76private:
77
85#ifdef HASHCONSTERMS
86 unordered_map<Term, Term*, term_hash> index;
87#endif
93 vector<Term*> term_pointers;
99 Term* find(const Term&);
100public:
101
102#ifdef HASHCONSTERMS
103 TermIndex() : index(), term_pointers() {}
104#else
105 TermIndex() : term_pointers() {}
106#endif
107
108 ~TermIndex();
114 TermIndex(const TermIndex&) = delete;
115 TermIndex(const TermIndex&&) = delete;
116 TermIndex& operator=(const TermIndex&) = delete;
117 TermIndex& operator=(const TermIndex&&) = delete;
121 size_t get_size() const { return term_pointers.size(); }
145 Term* add_function_term(Function*, const vector<Term*>&);
174
175 friend ostream& operator<<(ostream&, const TermIndex&);
176};
177
178#endif
Basic representation of functions.
Definition Function.hpp:54
General representation of terms.
Definition Term.hpp:62
Look after terms, (ideally) using hash consing to avoid storing copies of terms.
Definition TermIndex.hpp:75
Term * find(const Term &)
Find a term in the index.
Definition TermIndex.cpp:40
size_t get_size() const
Basic get method.
Term * add_function_term(Function *, const vector< Term * > &)
Self-explanatory: add a Term containing a function to the index.
Definition TermIndex.cpp:73
vector< Term * > term_pointers
Hash table for storing pointers to where Terms are actually stored.
Definition TermIndex.hpp:93
Term * add_variable_term(Variable *)
Self-explanatory: add a Term containing a variable to the index.
Definition TermIndex.cpp:56
Term * replace_variable_in_term_with_term(Term *, Variable *, Term *)
Minor variation on replace_variable_in_term.
Term * replace_variable_in_term(Variable *, Variable *, Term *)
Replace a variable in a term with an alternative, maintaining the structure of the TermIndex.
Definition TermIndex.cpp:93
TermIndex(const TermIndex &)=delete
Don't allow copying as this is a terrible idea.
Basic representation of variables.
Definition Variable.hpp:58