Connect++ 0.6.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
TermHash.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 TERMHASH_HPP
26#define TERMHASH_HPP
27
28#include <boost/container_hash/hash.hpp>
29
30#include "Term.hpp"
31
38struct term_hash {
39 size_t operator()(const Term& t) const {
40 size_t hash = 0;
41 for (size_t i = 0; i < t.arity(); i++)
42 boost::hash_combine(hash, t[i]);
43 boost::hash_combine(hash, t.get_v());
44 boost::hash_combine(hash, t.get_f());
45 return hash;
46 }
47};
48
49#endif
General representation of terms.
Definition Term.hpp:62
Variable * get_v() const
Self-explanatory access function.
Definition Term.hpp:86
Function * get_f() const
Self-explanatory access function.
Definition Term.hpp:90
Arity arity() const
Self-explanatory access function.
Definition Term.hpp:102
Hashing for terms using the Boost library.
Definition TermHash.hpp:38