Connect++ 0.6.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#include "TermHash.hpp"
33
34using std::unordered_map;
35using std::vector;
36using std::ostream;
37using std::endl;
38
54class TermIndex {
55private:
63 unordered_map<Term, Term*, term_hash> index;
67 vector<Term*> term_pointers;
73 Term* find(const Term&);
74public:
75 TermIndex() : index(), term_pointers() {}
76 ~TermIndex();
82 TermIndex(const TermIndex&) = delete;
83 TermIndex(const TermIndex&&) = delete;
84 TermIndex& operator=(const TermIndex&) = delete;
85 TermIndex& operator=(const TermIndex&&) = delete;
89 size_t get_size() const { return term_pointers.size(); }
113 Term* add_function_term(Function*, const vector<Term*>&);
142
143 friend ostream& operator<<(ostream&, const TermIndex&);
144};
145
146#endif
Basic representation of functions.
Definition Function.hpp:54
General representation of terms.
Definition Term.hpp:62
Look after terms, using hash consing to avoid storing copies of terms.
Definition TermIndex.hpp:54
Term * find(const Term &)
Find a term in the index.
Definition TermIndex.cpp:28
size_t get_size() const
Basic get method.
Definition TermIndex.hpp:89
Term * add_function_term(Function *, const vector< Term * > &)
Self-explanatory: add a Term containing a function to the index.
Definition TermIndex.cpp:56
vector< Term * > term_pointers
Used to make destruction easy.
Definition TermIndex.hpp:67
unordered_map< Term, Term *, term_hash > index
Hash table for storing pointers to where Terms are actually stored.
Definition TermIndex.hpp:63
Term * add_variable_term(Variable *)
Self-explanatory: add a Term containing a variable to the index.
Definition TermIndex.cpp:41
Term * replace_variable_in_term_with_term(Term *, Variable *, Term *)
Minor variation on replace_variable_in_term.
Definition TermIndex.cpp:95
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:74
TermIndex(const TermIndex &)=delete
Don't allow copying as this is a terrible idea.
Basic representation of variables.
Definition Variable.hpp:58