Hello all,

A few months ago i wrote a large SageMathCloud worksheet based on 
BooleanFunction, e.g.
https://cloud.sagemath.com/projects/80f4c9e7-8a37-4f59-82e7-aa179ec0b652/files/public/bent-functions-duals-Cayley-graphs.sagews
(This SageMathCloud worksheet is much too long, and badly needs 
refactoring.)

I am now attempting to put the code into a more usable form, and am finding 
some seeming inconsistencies in BooleanFunction. Should I use Trac to 
report these as bugs?

(1) You can create a BooleanFunction of 0 variables (a constant), but you 
cannot save it to a file. Same with a BooleanFunction of 1 variable.

sage: save_file=os.path.join(SAGE_TMP,'save_file.sobj')
sage: print save_file
/home/leopardi/.sage/temp/catawba/8109/save_file.sobj
sage: b0=BooleanFunction([0])
sage: print b0.truth_table()
(False,)
sage: print b0.nvariables()
0
sage: save(b0,save_file)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-51-0ddfad8f6d36> in <module>()
----> 1 save(b0,save_file)

sage/structure/sage_object.pyx in sage.structure.sage_object.save 
(/usr/lib/sagemath//src/build/cythonized/sage/structure/sage_object.c:12085)()

sage/structure/sage_object.pyx in 
sage.structure.sage_object.SageObject.save 
(/usr/lib/sagemath//src/build/cythonized/sage/structure/sage_object.c:3631)()

sage/structure/sage_object.pyx in 
sage.structure.sage_object.SageObject.dumps 
(/usr/lib/sagemath//src/build/cythonized/sage/structure/sage_object.c:3922)()

sage/crypto/boolean_function.pyx in 
sage.crypto.boolean_function.BooleanFunction.__reduce__ 
(/usr/lib/sagemath//src/build/cythonized/sage/crypto/boolean_function.c:16901)()

sage/crypto/boolean_function.pyx in 
sage.crypto.boolean_function.BooleanFunction.truth_table 
(/usr/lib/sagemath//src/build/cythonized/sage/crypto/boolean_function.c:11727)()

sage/rings/integer.pyx in sage.rings.integer.Integer.__lshift__ 
(/usr/lib/sagemath//src/build/cythonized/sage/rings/integer.c:37039)()

ValueError: negative shift count

sage: b1.truth_table()
(False, True)
sage: b1.nvariables()
1
sage: save(b1,save_file)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-55-f5c8864359bd> in <module>()
----> 1 save(b1,save_file)

sage/structure/sage_object.pyx in sage.structure.sage_object.save 
(/usr/lib/sagemath//src/build/cythonized/sage/structure/sage_object.c:12085)()

sage/structure/sage_object.pyx in 
sage.structure.sage_object.SageObject.save 
(/usr/lib/sagemath//src/build/cythonized/sage/structure/sage_object.c:3631)()

sage/structure/sage_object.pyx in 
sage.structure.sage_object.SageObject.dumps 
(/usr/lib/sagemath//src/build/cythonized/sage/structure/sage_object.c:3922)()

sage/crypto/boolean_function.pyx in 
sage.crypto.boolean_function.BooleanFunction.__reduce__ 
(/usr/lib/sagemath//src/build/cythonized/sage/crypto/boolean_function.c:16901)()

sage/crypto/boolean_function.pyx in 
sage.crypto.boolean_function.BooleanFunction.truth_table 
(/usr/lib/sagemath//src/build/cythonized/sage/crypto/boolean_function.c:11727)()

sage/rings/integer.pyx in sage.rings.integer.Integer.__lshift__ 
(/usr/lib/sagemath//src/build/cythonized/sage/rings/integer.c:37039)()

ValueError: negative shift count

sage: b2.truth_table()
(False, True, True, False)
sage: b2.nvariables()
2
sage: save(b2,save_file)

This causes a problem for me, because I am trying to generate and save 
lists of Boolean functions of 2*m variables for m from 0 to some fixed 
number, and cannot save the list because I can't save the first element.
My work around would be to start from m=1.


(2) You cannot evaluate the algebraic normal form of a BooleanFunction of 0 
variables. In addition, the error message incorrectly says that the number 
of variables must be greater than 1, but you *can* evaluate the algebraic 
normal form of a function of 1 variable.

sage: b0.algebraic_normal_form()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-60-8dd0bae0cd3a> in <module>()
----> 1 b0.algebraic_normal_form()

sage/crypto/boolean_function.pyx in 
sage.crypto.boolean_function.BooleanFunction.algebraic_normal_form 
(/usr/lib/sagemath//src/build/cythonized/sage/crypto/boolean_function.c:11074)()

sage/rings/polynomial/pbori.pyx in 
sage.rings.polynomial.pbori.BooleanPolynomialRing.__init__ 
(/usr/lib/sagemath//src/build/cythonized/sage/rings/polynomial/pbori.cpp:5976)()

ValueError: Number of variables must be greater than 1.
sage: b1.algebraic_normal_form()
x
sage: b2.algebraic_normal_form()
x0 + x1

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to