JPL を介して Java で Prolog を使用するためのクエリを作成したいので、ドキュメントを読みます (http://www.swi-prolog.org/packages/jpl/java_api/getting_started.html)。プロローグの述語は次のとおりです。
child_of(joe, ralf).
child_of(mary, joe).
child_of(steve, joe).
child_of(steve, ralf).
descendent_of(X, Y) :-
    child_of(X, Y).
descendent_of(X, Y) :-
    child_of(Z, Y),
descendent_of(X, Z).
私のコードは次のようになります
Variable X = new Variable();
        Query q4 =
            new Query(
                "descendent_of",
                new Term[] {X,new Atom("joe")}
            );
        java.util.Hashtable solution;
        while ( q4.hasMoreSolutions() ){
            solution = q4.nextSolution();
            System.out.println( "X = " + solution.get(X));
        }
プロローグの述語によると、私の Java コードは「mary」と「steve」を取得する必要がありますが、次のようになります。
X = null
X = null
私が間違っていることは何ですか?前もって感謝します
編集:これは私のテスト全体です
Query q1 =
    new Query(
        "consult",
        new Term[] {new Atom("C:\\Users\\cardozo\\Documents\\fer\\info2\\lore\\test.pl")}
    );
return q1;
System.out.println( "consult " + (q.query() ? "succeeded" : "failed"));
Query q2 =
    new Query(
        "child_of",
        new Term[] {new Atom("joe"),new Atom("X")}
    );
Boolean resp= q2.query();
System.out.println("child_of(joe,X) is " + resp.toString()
);
Query q3 =
    new Query(
        "descendent_of",
        new Term[] {new Atom("steve"),new Atom("ralf")}
    );
System.out.println(
    "descendent_of(joe,ralf) is " +
    ( q3.query() ? "provable" : "not provable" )
);
Variable X = new Variable();
Query q4 =
    new Query(
        "descendent_of",
        new Term[] {X,new Atom("joe")}
    );
java.util.Hashtable solution;
q4.query();
while ( q4.hasMoreSolutions() ){
    solution = q4.nextSolution();
    System.out.println( "X = " + solution.get("X"));
}
そして、これが結果として私のJavaコンソールに表示されるものです
run:
% C:\Users\cardozo\Documents\fer\info2\lore\test.pl compiled 0.00 sec, 8 clauses
consult succeeded
child_of(joe,X) is false
descendent_of(joe,ralf) is provable
X = null
X = null
BUILD SUCCESSFUL (total time: 0 seconds)