Connect++ 0.4.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
Substitution.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 SUBSTITUTION_HPP
26#define SUBSTITUTION_HPP
27
28#include<iostream>
29#include<string>
30#include<vector>
31
32#include "vic_strings.hpp"
33#include "Term.hpp"
34
35using std::pair;
36using std::vector;
37using std::string;
38using std::ostream;
39using std::endl;
40
46using SubPair = pair<Variable*, Term*>;
47
58private:
65 vector<SubPair> sub;
66public:
74 size_t size() const { return sub.size(); }
81 void push_back(Variable*, Term*);
85 void clear() { sub.clear(); }
92 void apply() const;
99 void backtrack() const;
105 string to_string(bool = false) const;
113 string make_LaTeX(bool = false) const;
117 vector<SubPair>::iterator begin() { return sub.begin(); }
121 vector<SubPair>::iterator end() { return sub.end(); }
125 vector<SubPair>::const_iterator cbegin() { return sub.cbegin(); }
129 vector<SubPair>::const_iterator cend() { return sub.cend(); }
130
131 friend ostream& operator<<(ostream&, const Substitution&);
132};
133
134#endif
General representation of a substitution.
vector< SubPair >::const_iterator cend()
Iteration is just iteration over the vector of pairs.
vector< SubPair >::iterator end()
Iteration is just iteration over the vector of pairs.
string make_LaTeX(bool=false) const
Make a useable LaTeX representation.
void backtrack() const
Remove a substitution everywhere.
void push_back(Variable *, Term *)
Add a pair to a substitution.
vector< SubPair >::const_iterator cbegin()
Iteration is just iteration over the vector of pairs.
size_t size() const
Trivial get method.
Substitution()
Trivial constructor.
vector< SubPair > sub
A single substitution is just a pointer to the Variable being sustituted, and a pointer to the Term t...
void clear()
Clear a substitution.
void apply() const
Apply a substitution everywhere.
vector< SubPair >::iterator begin()
Iteration is just iteration over the vector of pairs.
string to_string(bool=false) const
Make a string representation.
General representation of terms.
Definition Term.hpp:62
Basic representation of variables.
Definition Variable.hpp:58