lojix/prolog/src/main/com/thesett/aima/logic/fol/prolog/builtins/PrologUnifier.java
public List<Variable> unify(Term query, Term statement)
    {
        /*log.fine("unify(Term left = " + query + ", Term right = " + statement + "): called");*/

        // Find all free variables in the query.
        Set<Variable> freeVars = TermUtils.findFreeNonAnonymousVariables(query);

        // Build up all the variable bindings in both sides of the unification in these bindings.
        List<Variable> queryBindings = new LinkedList<Variable>();
        List<Variable> statementBindings = new LinkedList<Variable>();

        // Fund the most general unifier, if possible.
        boolean unified = unifyInternal(query, statement, queryBindings, statementBindings);
        List<Variable> results = null;

        // If a unification was found, only retain the free variables in the query in the results returned.
        if (unified)
        {
            queryBindings.retainAll(freeVars);
            results = new ArrayList<Variable>(queryBindings);
        }

        return results;
    }
public List<Variable> unify(Term query, Term statement)
    {
        /*log.fine("unify(Term left = " + query + ", Term right = " + statement + "): called");*/

        // Find all free variables in the query.
        Set<Variable> freeVars = TermUtils.findFreeNonAnonymousVariables(query);

        // Build up all the variable bindings in both sides of the unification in these bindings.
        List<Variable> queryBindings = new LinkedList<Variable>();
        List<Variable> statementBindings = new LinkedList<Variable>();

        // Fund the most general unifier, if possible.
        boolean unified = unifyInternal(query, statement, queryBindings, statementBindings);
        List<Variable> results = null;

        // If a unification was found, only retain the free variables in the query in the results returned.
        if (unified)
        {
            queryBindings.retainAll(freeVars);
            results = new ArrayList<Variable>(queryBindings);
        }

        return results;
    }
public List < Variable > unify ( Term query , Term statement ) { /*log.fine("unify(Term left = " + query + ", Term right = " + statement + "): called");*/ // Find all free variables in the query. Set < Variable > freeVars = TermUtils . findFreeNonAnonymousVariables ( query ) ; // Build up all the variable bindings in both sides of the unification in these bindings. List < Variable > queryBindings = new LinkedList < Variable > ( ) ; List < Variable > statementBindings = new LinkedList < Variable > ( ) ; // Fund the most general unifier, if possible. boolean unified = unifyInternal ( query , statement , queryBindings , statementBindings ) ; List < Variable > results = null ; // If a unification was found, only retain the free variables in the query in the results returned. if ( unified ) { queryBindings . retainAll ( freeVars ) ; results = new ArrayList < Variable > ( queryBindings ) ; } return results ; }
Unifies two terms and produces a list of bound variables that form the unification, when it it possible.

@param  query     The left term to unify.
@param  statement The right term to unify.

@return A list of bound variables to form the unification, or <tt>null</tt> when no unification is possible.
Unifies two terms and produces a list of bound variables that form the unification when it it possible .