Connect++ 0.6.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
FunctionIndex.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 FUNCTIONINDEX_HPP
26#define FUNCTIONINDEX_HPP
27
28#include<iostream>
29#include<iomanip>
30#include<string>
31#include<vector>
32#include<unordered_map>
33
34#include "Function.hpp"
35#include "FunctionHash.hpp"
36
37using std::pair;
38using std::setw;
39using std::ostream;
40using std::string;
41using std::vector;
42using std::unordered_map;
43using std::cerr;
44using std::endl;
45
46using FunIndexType = pair<string, Arity>;
47using FunMapType = pair<FunIndexType, Function*>;
48
65private:
69 vector<Function*> funs;
73 unordered_map<pair<string, Arity>, Function*, fun_hash> name_index;
82public:
89 FunctionIndex(const FunctionIndex&) = delete;
90 FunctionIndex(const FunctionIndex&&) = delete;
91 FunctionIndex& operator=(const FunctionIndex&) = delete;
92 FunctionIndex& operator=(const FunctionIndex&&) = delete;
96 size_t get_size() const { return funs.size(); }
105 Function* add_function(const string&, Arity);
118 Function* find_function(const string&, Arity);
123 Arity find_maximum_arity() const;
128 Arity find_minimum_arity() const;
133 Function* operator[](size_t i) { return funs[i]; }
134
135 friend ostream& operator<<(ostream&, const FunctionIndex&);
136};
137
138#endif
Basic representation of functions.
Definition Function.hpp:54
Mechanism for looking after functions.
unordered_map< pair< string, Arity >, Function *, fun_hash > name_index
Fast lookup from name/arity to pointer to the Function.
Arity find_minimum_arity() const
Find the smallest arity appearing for any Function in the index.
size_t get_size() const
Self-explanatory.
ID next_index
Keep track of ids for adding new Functions.
Arity find_maximum_arity() const
Find the largest arity appearing for any Function in the index.
Function * find_function(const string &, Arity)
Look up a stored Function by name and arity.
Function * add_function(const string &, Arity)
Add a new function to the index.
uint32_t skolem_function_number
Automate the naming of Skolem functions.
vector< Function * > funs
Pointers to all the Functions used.
FunctionIndex(const FunctionIndex &)=delete
As usual, trying to copy one of these is a really bad idea.
Function * operator[](size_t i)
Access to pointers to Functions, but don't mess with them!
Function * make_skolem_function(Arity)
Add a new Skolem function. Naming is automatic.
Hashing for functions using the Boost library for hashing.