1
+ # sage.doctest: optional - sage.rings.polynomial.pbori
1
2
"""
2
3
SAT Functions for Boolean Polynomials
3
4
@@ -71,8 +72,8 @@ def solve(F, converter=None, solver=None, n=1, target_variables=None, **kwds):
71
72
72
73
We construct a very small-scale AES system of equations::
73
74
74
- sage: sr = mq.SR(1,1,1,4, gf2=True,polybori=True) # optional - sage.modules
75
- sage: while True: # workaround (see :trac:`31891`) # optional - sage.modules
75
+ sage: sr = mq.SR(1, 1, 1, 4, gf2=True, polybori=True) # optional - sage.modules sage.rings.finite_rings
76
+ sage: while True: # workaround (see :trac:`31891`) # optional - sage.modules sage.rings.finite_rings
76
77
....: try:
77
78
....: F, s = sr.polynomial_system()
78
79
....: break
@@ -82,14 +83,14 @@ def solve(F, converter=None, solver=None, n=1, target_variables=None, **kwds):
82
83
and pass it to a SAT solver::
83
84
84
85
sage: from sage.sat.boolean_polynomials import solve as solve_sat
85
- sage: s = solve_sat(F) # optional - pycryptosat sage.modules
86
- sage: F.subs(s[0]) # optional - pycryptosat sage.modules
86
+ sage: s = solve_sat(F) # optional - pycryptosat sage.modules sage.rings.finite_rings
87
+ sage: F.subs(s[0]) # optional - pycryptosat sage.modules sage.rings.finite_rings
87
88
Polynomial Sequence with 36 Polynomials in 0 Variables
88
89
89
90
This time we pass a few options through to the converter and the solver::
90
91
91
- sage: s = solve_sat(F, c_max_vars_sparse=4, c_cutting_number=8) # optional - pycryptosat sage.modules
92
- sage: F.subs(s[0]) # optional - pycryptosat sage.modules
92
+ sage: s = solve_sat(F, c_max_vars_sparse=4, c_cutting_number=8) # optional - pycryptosat sage.modules sage.rings.finite_rings
93
+ sage: F.subs(s[0]) # optional - pycryptosat sage.modules sage.rings.finite_rings
93
94
Polynomial Sequence with 36 Polynomials in 0 Variables
94
95
95
96
We construct a very simple system with three solutions
@@ -126,7 +127,7 @@ def solve(F, converter=None, solver=None, n=1, target_variables=None, **kwds):
126
127
127
128
Now we are only interested in the solutions of the variables a and b::
128
129
129
- sage: solve_sat(F,n=infinity,target_variables=[a,b]) # optional - pycryptosat sage.modules
130
+ sage: solve_sat(F, n=infinity, target_variables=[a,b]) # optional - pycryptosat sage.modules
130
131
[{b: 0, a: 0}, {b: 1, a: 1}]
131
132
132
133
Here, we generate and solve the cubic equations of the AES SBox (see :trac:`26676`)::
@@ -136,7 +137,7 @@ def solve(F, converter=None, solver=None, n=1, target_variables=None, **kwds):
136
137
sage: sr = sage.crypto.mq.SR(1, 4, 4, 8, # long time, optional - pycryptosat sage.modules
137
138
....: allow_zero_inversions=True)
138
139
sage: sb = sr.sbox() # long time, optional - pycryptosat sage.modules
139
- sage: eqs = sb.polynomials(degree = 3) # long time, optional - pycryptosat sage.modules
140
+ sage: eqs = sb.polynomials(degree=3) # long time, optional - pycryptosat sage.modules
140
141
sage: eqs = PolynomialSequence(eqs) # long time, optional - pycryptosat sage.modules
141
142
sage: variables = map(str, eqs.variables()) # long time, optional - pycryptosat sage.modules
142
143
sage: variables = ",".join(variables) # long time, optional - pycryptosat sage.modules
@@ -343,11 +344,11 @@ def learn(F, converter=None, solver=None, max_learnt_length=3, interreduction=Fa
343
344
344
345
We construct a simple system and solve it::
345
346
346
- sage: set_random_seed(2300) # optional - pycryptosat
347
- sage: sr = mq.SR(1,2,2,4, gf2=True,polybori=True) # optional - pycryptosat
348
- sage: F,s = sr.polynomial_system() # optional - pycryptosat
349
- sage: H = learn_sat(F) # optional - pycryptosat
350
- sage: H[-1] # optional - pycryptosat
347
+ sage: set_random_seed(2300)
348
+ sage: sr = mq.SR(1, 2, 2, 4, gf2=True, polybori=True) # optional - pycryptosat sage.modules sage.rings.finite_rings
349
+ sage: F,s = sr.polynomial_system() # optional - pycryptosat sage.modules sage.rings.finite_rings
350
+ sage: H = learn_sat(F) # optional - pycryptosat sage.modules sage.rings.finite_rings
351
+ sage: H[-1] # optional - pycryptosat sage.modules sage.rings.finite_rings
351
352
k033 + 1
352
353
"""
353
354
try :
0 commit comments