![]() |
Connect++ 0.6.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 | unify (Term *, Term *) |
Implementation of unification for a pair of Terms. | |
UnificationOutcome | unify_terms (Term *, Term *) |
Main method implementing the traditional unification algorithm. | |
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 &l1, const Literal &l2) |
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: for the polynomial-time approach. All the real work happens here. | |
Private Attributes | |
Substitution | s |
Build the resulting substitution here. | |
vector< 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" and "unify_terms" methods, depending on whether you're using the traditional or polynomial time version.
For the polynomial time version, 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 vector, taking something from the end and placing any results on the end as well.
The traditional version is based on Figure 1, page 454, Handbook of Automated Reasoning Volume 1.
Note that some modifications have to be made compared with the original presentations, because the method used to make substitutions takes immediate effect. As a result, for example, 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 89 of file Unifier.hpp.
|
inline |
There isn't really much to initialize.
Definition at line 108 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 195 of file Unifier.cpp.
|
private |
Implementation of unification: for the polynomial-time approach. All the real work happens here.
Definition at line 127 of file Unifier.cpp.
|
inline |
Unification of Literals.
This is the version that is used most of the time, so there is an attempt here to optimize it.
Definition at line 168 of file Unifier.hpp.
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 88 of file Unifier.cpp.
Unification of Literals.
Definition at line 115 of file Unifier.cpp.
Implementation of unification for a pair of Terms.
term1 | Pointer to first term |
term2 | Pointer to second term |
Definition at line 27 of file Unifier.cpp.
|
inline |
Make a nice string representation.
subbed | Use substitutions if true. |
Definition at line 200 of file Unifier.hpp.
Implementation of unification for a pair of Terms.
term1 | Pointer to first term |
term2 | Pointer to second term |
Definition at line 38 of file Unifier.cpp.
Main method implementing the traditional unification algorithm.
Definition at line 48 of file Unifier.cpp.
|
friend |
Definition at line 218 of file Unifier.cpp.
|
private |
Build the resulting substitution here.
Definition at line 94 of file Unifier.hpp.
|
private |
Queue used by complete_unification method.
Definition at line 98 of file Unifier.hpp.