How to save pyprover object with pickle

Viewed 44

I want to save logical expressions of pyprover with pickle. The following is the code I wrote in google corabolatory.

!pip install pyprover
import pickle
from pyprover import *

logic = ~A & B

print(1,logic)
print(2,type(logic))
print(3,type(A))

with open("test.pickle","wb") as f:
  pickle.dump(logic,f)

with open("test.pickle","rb") as f:
  logic2 = pickle.load(f) # error

print(logic2)

The output is below

1 ~A & B
2 <class 'pyprover.logic.And'>
3 <class 'pyprover.logic.Prop'>
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-27-4cd4fe38fcb4> in <module>
     12 
     13 with open("test.pickle","rb") as f:
---> 14   logic2 = pickle.load(f) # error
     15 
     16 print(logic2)

AttributeError: 'Top' object has no attribute 'elems'

How can I save the logical expression with pickle? pyprover github

If you know how to save the object, I do not care about whether or not it uses pickle. I tried dill,only to get the same result as pickle.

I wrote an dill issue here

I tried to import modules like this but it didn't solve the problem.

import dill 
import pyprover
from pyprover import *
from pyprover.logic import *
from pyprover.parser import *
from pyprover.constants import *
from pyprover.atoms import *
from pyprover.util import *
from pyprover.tools import *
from pyprover.__coconut__ import *
from pyprover.__init__ import *

0 Answers
Related