lojix/interpreter/src/main/com/thesett/aima/logic/fol/interpreter/ResolutionInterpreter.java
private void evaluateQuery()
    {
        /*log.fine("Read query from input.");*/

        // Create an iterator to generate all solutions on demand with. Iteration will stop if the request to
        // the parser for the more ';' token fails.
        Iterator<Set<Variable>> i = engine.iterator();

        if (!i.hasNext())
        {
            System.out.println("false. ");

            return;
        }

        for (; i.hasNext();)
        {
            Set<Variable> solution = i.next();

            if (solution.isEmpty())
            {
                System.out.print("true");
            }
            else
            {
                for (Iterator<Variable> j = solution.iterator(); j.hasNext();)
                {
                    Variable nextVar = j.next();

                    String varName = engine.getVariableName(nextVar.getName());

                    System.out.print(varName + " = " + nextVar.getValue().toString(engine, true, false));

                    if (j.hasNext())
                    {
                        System.out.println();
                    }
                }
            }

            // Finish automatically if there are no more solutions.
            if (!i.hasNext())
            {
                System.out.println(".");

                break;
            }

            // Check if the user wants more solutions.
            try
            {
                int key = consoleReader.readVirtualKey();

                if (key == SEMICOLON)
                {
                    System.out.println(" ;");
                }
                else
                {
                    System.out.println();

                    break;
                }
            }
            catch (IOException e)
            {
                throw new IllegalStateException(e);
            }
        }
    }
private void evaluateQuery()
    {
        /*log.fine("Read query from input.");*/

        // Create an iterator to generate all solutions on demand with. Iteration will stop if the request to
        // the parser for the more ';' token fails.
        Iterator<Set<Variable>> i = engine.iterator();

        if (!i.hasNext())
        {
            System.out.println("false. ");

            return;
        }

        for (; i.hasNext();)
        {
            Set<Variable> solution = i.next();

            if (solution.isEmpty())
            {
                System.out.print("true");
            }
            else
            {
                for (Iterator<Variable> j = solution.iterator(); j.hasNext();)
                {
                    Variable nextVar = j.next();

                    String varName = engine.getVariableName(nextVar.getName());

                    System.out.print(varName + " = " + nextVar.getValue().toString(engine, true, false));

                    if (j.hasNext())
                    {
                        System.out.println();
                    }
                }
            }

            // Finish automatically if there are no more solutions.
            if (!i.hasNext())
            {
                System.out.println(".");

                break;
            }

            // Check if the user wants more solutions.
            try
            {
                int key = consoleReader.readVirtualKey();

                if (key == SEMICOLON)
                {
                    System.out.println(" ;");
                }
                else
                {
                    System.out.println();

                    break;
                }
            }
            catch (IOException e)
            {
                throw new IllegalStateException(e);
            }
        }
    }
Evaluates a query. In the case of queries, the interner is used to recover textual names for the resulting
variable bindings. The user is queried through the parser to if more than one solution is required.