lojix/logic/src/main/com/thesett/aima/logic/fol/TermUtils.java
public static Set<Variable> findFreeVariables(Term query)
    {
        QueueBasedSearchMethod<Term, Term> freeVarSearch = new DepthFirstSearch<Term, Term>();
        freeVarSearch.reset();
        freeVarSearch.addStartState(query);
        freeVarSearch.setGoalPredicate(new FreeVariablePredicate());

        return (Set<Variable>) (Set) Searches.setOf(freeVarSearch);
    }
public static Set<Variable> findFreeVariables(Term query)
    {
        QueueBasedSearchMethod<Term, Term> freeVarSearch = new DepthFirstSearch<Term, Term>();
        freeVarSearch.reset();
        freeVarSearch.addStartState(query);
        freeVarSearch.setGoalPredicate(new FreeVariablePredicate());

        return (Set<Variable>) (Set) Searches.setOf(freeVarSearch);
    }
Calculates the set of free variables in a term.

@param  query The term to calculate the free non-anonymous variable set from.

@return A set of variables that are free and non-anonymous in the term.