![]() |
Connect++ 0.4.0
A fast, readable connection prover for first-order logic.
|
Wrap up various applications of unificiation into a single class: all the unification you need to do happens here. More...
#include <Unifier.hpp>
Public Member Functions | |
Unifier () | |
There isn't really much to initialize. | |
Unifier (const Unifier &)=delete | |
You really only need one Unifier! | |
Unifier (const Unifier &&)=delete | |
Unifier & | operator= (const Unifier &)=delete |
Unifier & | operator= (const Unifier &&)=delete |
Substitution | get_substitution () const |
Trivial get methods for the result. | |
UnificationOutcome | operator() (Term *, Term *) |
Implementation of unification for a pair of Terms. | |
UnificationOutcome | operator() (const vector< Term * > &, const vector< Term * > &) |
The same as the main operator(), but you've already extracted the arguments for the things of interest into lists. | |
UnificationOutcome | operator() (Literal *, Literal *) |
Unification of Literals. | |
UnificationOutcome | operator() (const Literal &, const Literal &) |
void | backtrack () |
Apply the backtracking process to the substitution that has been constructed. | |
string | to_string (bool subbed=false) const |
Make a nice string representation. | |
Private Member Functions | |
UnificationOutcome | complete_unification () |
Implementation of unification: all the real work happens here. | |
Private Attributes | |
Substitution | s |
Build the resulting substitution here. | |
deque< UPair > | to_do |
Queue used by complete_unification method. | |
Friends | |
ostream & | operator<< (ostream &, const Unifier &) |
Wrap up various applications of unificiation into a single class: all the unification you need to do happens here.
You may find yourself unifying Terms, Literals and so on. This puts it all in one place. The class is a function class with various overloaded operator() methods.
All the real work happens in the "complete_unification" method.
See the Wikipedia page. This is apparently due to Montelli and Montanari (1982). Looking at "An Efficient Unification Algorithm – yes, indeed it is. The algorithm as stated in the paper is nondeterministic, and apparently you get a bunch of different outcomes depending on the details of the implementation.
So: this one uses a queue, taking something from the end and placing any results at the beginning.
Note that some modifications have to be made compared with the paper's presentation, because the method used to make substitutions takes immediate effect. As a result, substitutions get removed by the Delete rule, so you might as well remove them immediately. Also, when substituting x=? you don't need to check whether x appears in the other equations.
Definition at line 83 of file Unifier.hpp.
|
inline |
There isn't really much to initialize.
Definition at line 102 of file Unifier.hpp.
|
delete |
You really only need one Unifier!
As always, copying is a bad idea so let the compiler help you out.
void Unifier::backtrack | ( | ) |
Apply the backtracking process to the substitution that has been constructed.
Definition at line 134 of file Unifier.cpp.
|
private |
Implementation of unification: all the real work happens here.
Definition at line 72 of file Unifier.cpp.
|
inline |
Unification of Literals.
Definition at line 59 of file Unifier.cpp.
UnificationOutcome Unifier::operator() | ( | const vector< Term * > & | t1s, |
const vector< Term * > & | t2s ) |
The same as the main operator(), but you've already extracted the arguments for the things of interest into lists.
t1s | Reference to vector of pointers to Terms |
t2s | Reference to vector of pointers to Terms |
Definition at line 34 of file Unifier.cpp.
Unification of Literals.
Definition at line 47 of file Unifier.cpp.
Implementation of unification for a pair of Terms.
See the Wikipedia page. This is apparently due to Montelli and Montanari (1982). Looking at "An Efficient Unification Algorithm – yes, indeed it is.
See also the documentation for complete_unification.
term1 | Pointer to first term |
term2 | Pointer to second term |
Definition at line 28 of file Unifier.cpp.
|
inline |
Make a nice string representation.
subbed | Use substitutions if true. |
Definition at line 164 of file Unifier.hpp.
|
friend |
Definition at line 157 of file Unifier.cpp.
|
private |
Build the resulting substitution here.
Definition at line 88 of file Unifier.hpp.
|
private |
Queue used by complete_unification method.
Definition at line 92 of file Unifier.hpp.