Based on some older post, I have some prolog program, which specifies propositions. Let's call it "logic.pl"
:-op(800, fx, ¬).
:-op(801, xfy, ∧).
:-op(802, xfy, ∨).
:-op(803, xfy, →).
:-op(804, xfy, ↔).
:-op(800, xfy, #).
m_Proposition_Binary_x_y(X ∨ Y, X, Y).
m_Proposition_Binary_x_y(X ∧ Y, X, Y).
m_Proposition_Binary_x_y(X → Y, X, Y).
m_Proposition_Binary_x_y(X ↔ Y, X, Y).
m_Proposition(X) :-
m_Proposition_Atom(X).
m_Proposition(Binary) :-
m_Proposition_Binary_x_y(Binary, X, Y),
m_Proposition(X),
m_Proposition(Y).
m_Proposition(¬ X) :-
m_Proposition(X).
m_Proposition_Atom(p).
m_Proposition_Atom(q).
my aim now is to process some prolog functions based on a python program. The library python gives for that purpose is pyswip.
My problem with this library now is the swipl function intersection/3. If I run e.g. this function
intersection([A,(A→B)], [p, (p→q)], Aim).
from SWI-Prolog manually, I get the output I want:
A = p,
B = q,
Aim = [p, p→q].
but within the python code:
from pyswip import Prolog
prolog = Prolog()
prolog.consult("logic.pl")
for res in prolog.query("intersection([A,(A→B)], [p, (p→q)], Aim)."):
print(res)
My output is:
{'A': 'p', 'B': 'q', 'Aim': [Atom('331781'), Functor(8343821,2,p,q)]}
My question now is, what is the reason for:
'Aim': [Atom('331781'), Functor(8343821,2,p,q)]
And is there a way to translate that into my expected output?
Aim = [p, p→q]