Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error by using char '¬' as operator in prolog and translate it with pyswip #139

Open
Losbarthos opened this issue Jan 11, 2022 · 0 comments

Comments

@Losbarthos
Copy link

Losbarthos commented Jan 11, 2022

For some reason the char '¬' used as operator in a prolog file leads to an error in pyswip.

Python-file:

 from pyswip import Prolog

prolog = Prolog()

prolog.consult("test.pl")

for res in prolog.query(f"m_Proposition_Binary_x_y(∨(¬(p), q), A, B)."):
	print(res)

Prolog-file ("test.pl")

:-op(800, fx, ¬).
:-op(802, xfy, ∨).

m_Proposition_Binary_x_y(X ∨ Y, X, Y).

Error-Message:

Traceback (most recent call last):
  File "~/test.py", line 43, in <module>
    for res in prolog.query(f"m_Proposition_Binary_x_y(∨(¬(p), q), A, B)."):
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/prolog.py", line 112, in __call__
    t = getTerm(swipl_list)
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 436, in getTerm
    res = getList(t)
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 451, in getList
    result.append(getTerm(head))
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 438, in getTerm
    res = getFunctor(t)
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 460, in getFunctor
    return Functor.fromTerm(t)
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 291, in fromTerm
    args.append(getTerm(a0 + i))
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 438, in getTerm
    res = getFunctor(t)
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 460, in getFunctor
    return Functor.fromTerm(t)
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 293, in fromTerm
    return cls(f.value, args=args, a0=a0)
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 267, in __init__
    self.name = Atom(PL_functor_name(self.handle))
  File "/home/martin/.local/lib/python3.9/site-packages/pyswip/easy.py", line 68, in __init__
    self.chars = PL_atom_wchars(self.handle, byref(slen))
ValueError: character U+ffffffac is not in range [U+0000; U+10ffff]

For some reason '¬' (has unicode U+00AC) is translated into U+ffffffac. Can you reproduce this error/bug?

If I replace '¬' (in prolog and python-file) by some other char, say '~' or '∧' everything works fine and gives:
{'A': '∧(p)', 'B': 'q'}
or
{'A': '~(p)', 'B': 'q'}

Version used
0.2.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant