Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
renamed fes to libFES
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis committed Jun 2, 2015
1 parent d4740f5 commit 2b2ff60
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
100 changes: 50 additions & 50 deletions src/sage/libs/fes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ EXAMPLES:
Random Degree-2 System::
sage: from sage.libs.fes import exhaustive_search # optional - FES
sage: n = 16 # optional - FES
sage: R = BooleanPolynomialRing(n, 'x') # optional - FES
sage: solution = dict(zip(R.gens(), VectorSpace(GF(2), n).random_element())) # optional - FES
sage: F = [ R.random_element() for i in range(n+10) ] # optional - FES
sage: G = [ f + f.subs(solution) for f in F] # optional - FES
sage: sols = exhaustive_search(G) # optional - FES
sage: solution in sols # optional - FES
sage: from sage.libs.fes import exhaustive_search # optional - libFES
sage: n = 16 # optional - libFES
sage: R = BooleanPolynomialRing(n, 'x') # optional - libFES
sage: solution = dict(zip(R.gens(), VectorSpace(GF(2), n).random_element())) # optional - libFES
sage: F = [ R.random_element() for i in range(n+10) ] # optional - libFES
sage: G = [ f + f.subs(solution) for f in F] # optional - libFES
sage: sols = exhaustive_search(G) # optional - libFES
sage: solution in sols # optional - libFES
True
sage: len(sols) # optional - FES
sage: len(sols) # optional - libFES
1
Cylic benchmark::
sage: from sage.rings.ideal import Cyclic # optional - FES
sage: from sage.libs.fes import exhaustive_search # optional - FES
sage: n = 10 # optional - FES
sage: R = BooleanPolynomialRing(n, 'x') # optional - FES
sage: sols = exhaustive_search( Cyclic(R) ) # optional - FES
sage: len(sols) # optional - FES
sage: from sage.rings.ideal import Cyclic # optional - libFES
sage: from sage.libs.fes import exhaustive_search # optional - libFES
sage: n = 10 # optional - libFES
sage: R = BooleanPolynomialRing(n, 'x') # optional - libFES
sage: sols = exhaustive_search( Cyclic(R) ) # optional - libFES
sage: len(sols) # optional - libFES
1
sage: set(sols[0]) == set(R.gens()) # optional - FES
sage: set(sols[0]) == set(R.gens()) # optional - libFES
True
REFERENCES:
Expand All @@ -73,7 +73,7 @@ from libc.stdint cimport uint64_t
cdef extern from "fes_interface.h":
ctypedef int (*solution_callback_t)(void *, uint64_t)

void exhaustive_search_wrapper(int n, int n_eqs, int degree, int ***coeffs, solution_callback_t callback, void* callback_state, int verbose, int T)
void exhaustive_search_wrapper(int n, int n_eqs, int degree, int ***coeffs, solution_callback_t callback, void* callback_state, int verbose)


include 'sage/ext/interrupt.pxi' #sig_on(), sig_off()
Expand Down Expand Up @@ -132,35 +132,35 @@ def exhaustive_search(eqs, max_sols=Infinity, verbose=False):
NOTE:
Using this function requires the optional package FES to be installed.
Using this function requires the optional package libFES to be installed.
EXAMPLE:
A very simple example::
sage: from sage.libs.fes import exhaustive_search # optional - FES
sage: R.<x,y,z> = BooleanPolynomialRing() # optional - FES
sage: exhaustive_search( [x*y + z + y + 1, x+y+z, x*y + y*z] ) # optional - FES
sage: from sage.libs.fes import exhaustive_search # optional - libFES
sage: R.<x,y,z> = BooleanPolynomialRing() # optional - libFES
sage: exhaustive_search( [x*y + z + y + 1, x+y+z, x*y + y*z] ) # optional - libFES
[{y: 0, z: 1, x: 1}]
Another very simple example::
sage: R.<x,y,z,t,w> = BooleanPolynomialRing() # optional - FES
sage: f = x*y*z + z + y + 1 # optional - FES
sage: sorted( exhaustive_search( [f, x+y+z, x*y + y*z] ) ) # optional - FES
sage: R.<x,y,z,t,w> = BooleanPolynomialRing() # optional - libFES
sage: f = x*y*z + z + y + 1 # optional - libFES
sage: sorted( exhaustive_search( [f, x+y+z, x*y + y*z] ) ) # optional - libFES
[{w: 0, t: 0, y: 0, z: 1, x: 1}, {w: 0, t: 1, y: 0, z: 1, x: 1}, {w: 1, t: 0, y: 0, z: 1, x: 1}, {w: 1, t: 1, y: 0, z: 1, x: 1}]
An example with several solutions::
sage: R.<x,y,z, t> = BooleanPolynomialRing() # optional - FES
sage: eqs = [x*z + y*t + 1, x*y + y*z + z*t + t*x , x+y+z+1] # optional - FES
sage: sorted( exhaustive_search( eqs ) ) # optional - FES
sage: R.<x,y,z, t> = BooleanPolynomialRing() # optional - libFES
sage: eqs = [x*z + y*t + 1, x*y + y*z + z*t + t*x , x+y+z+1] # optional - libFES
sage: sorted( exhaustive_search( eqs ) ) # optional - libFES
[{t: 0, y: 1, z: 1, x: 1}, {t: 1, y: 1, z: 0, x: 0}]
We voluntarily limit the number of solutions returned by the library::
sage: eqs = [x*z + y*t + 1, x*y + y*z + z*t + t*x , x+y+z+1] # optional - FES
sage: exhaustive_search(eqs, max_sols=1 ) # optional - FES
sage: eqs = [x*z + y*t + 1, x*y + y*z + z*t + t*x , x+y+z+1] # optional - libFES
sage: exhaustive_search(eqs, max_sols=1 ) # optional - libFES
[{t: 0, y: 1, z: 1, x: 1}]
.. SEEALSO::
Expand All @@ -182,11 +182,11 @@ def exhaustive_search(eqs, max_sols=Infinity, verbose=False):
eqs = Sequence(eqs)
R = eqs.ring()
if R.base_ring() != GF(2):
raise ValueError, "FES only deals with equations over GF(2)"
raise ValueError, "libFES only deals with equations over GF(2)"

degree = max( [f.degree() for f in eqs] )
if degree <= 1:
raise ValueError("the FES library requires equations to be non-linear")
raise ValueError("the libFES library requires equations to be non-linear")
n = R.ngens()


Expand Down Expand Up @@ -221,7 +221,7 @@ def exhaustive_search(eqs, max_sols=Infinity, verbose=False):

# ------- runs the library
sig_on()
exhaustive_search_wrapper(n, len(eqs), degree, coeffs, report_solution, <void *> internal_state, verbose, 0)
exhaustive_search_wrapper(n, len(eqs), degree, coeffs, report_solution, <void *> internal_state, verbose)
sig_off()

# ------- frees memory occupied by the dense representation of the equations
Expand Down Expand Up @@ -255,15 +255,15 @@ def find_coordinate_change(As, max_tries=64):
Testing that the function works::
sage: from sage.libs.fes import find_coordinate_change # optional - FES
sage: n = 40 # optional - FES
sage: K = GF(2) # optional - FES
sage: R = BooleanPolynomialRing(n, 'x') # optional - FES
sage: foo = [ MatrixSpace(GF(2), n, n).random_element() ] # optional - FES
sage: f = [ M + M.T for M in foo ] # optional - FES
sage: S = find_coordinate_change( f ) # optional - FES
sage: g = [ S.T*M*S for M in f ] # optional - FES
sage: vector ([ M[0,1] for M in g[:32]]).is_zero() # optional - FES
sage: from sage.libs.fes import find_coordinate_change # optional - libFES
sage: n = 40 # optional - libFES
sage: K = GF(2) # optional - libFES
sage: R = BooleanPolynomialRing(n, 'x') # optional - libFES
sage: foo = [ MatrixSpace(GF(2), n, n).random_element() ] # optional - libFES
sage: f = [ M + M.T for M in foo ] # optional - libFES
sage: S = find_coordinate_change( f ) # optional - libFES
sage: g = [ S.T*M*S for M in f ] # optional - libFES
sage: vector ([ M[0,1] for M in g[:32]]).is_zero() # optional - libFES
True
"""
n = As[0].nrows()
Expand Down Expand Up @@ -294,7 +294,7 @@ def find_coordinate_change(As, max_tries=64):

def prepare_polynomials(f):
"""
Finds a linear combination of the equations that is faster to solve by FES
Finds a linear combination of the equations that is faster to solve by libFES
INPUT:
Expand All @@ -304,15 +304,15 @@ def prepare_polynomials(f):
We check that the function does what it is supposed to do::
sage: from sage.libs.fes import prepare_polynomials # optional - FES
sage: n = 35 # optional - FES
sage: K = GF(2) # optional - FES
sage: R = BooleanPolynomialRing(n, 'x') # optional - FES
sage: from sage.libs.fes import prepare_polynomials # optional - libFES
sage: n = 35 # optional - libFES
sage: K = GF(2) # optional - libFES
sage: R = BooleanPolynomialRing(n, 'x') # optional - libFES
sage: f = [ sum( [K.random_element() * R.gen(i) * R.gen(j) for i in range(n) for j in range(i)] ) \
+ sum( [K.random_element() * R.gen(i) for i in range(n) ] ) \
+ K.random_element() for l in range(n) ] # optional - FES
sage: g = prepare_polynomials(f) # optional - FES
sage: map(lambda x:x.lm(), g) # optional - FES, random
+ K.random_element() for l in range(n) ] # optional - libFES
sage: g = prepare_polynomials(f) # optional - libFES
sage: map(lambda x:x.lm(), g) # optional - libFES, random
0
"""
if f == []:
Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/polynomial/multi_polynomial_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,9 +1361,9 @@ def solve(self, algorithm='polybori', n=1, eliminate_linear_variables=True, ver
[[0, 0, 0], [0, 0, 0]]
We can force the use of exhaustive search if the optional
package ``FES`` is present::
package ``libFES`` is present::
sage: sol = S.solve(algorithm='exhaustive_search'); sol # random, optional - FES
sage: sol = S.solve(algorithm='exhaustive_search'); sol # random, optional - libFES
[{x: 1, y: 1, z: 1}]
sage: S.subs( sol[0] )
[0, 0, 0]
Expand Down Expand Up @@ -1414,8 +1414,8 @@ def solve(self, algorithm='polybori', n=1, eliminate_linear_variables=True, ver

if S != []:
if algorithm == "exhaustive_search":
if not is_package_installed('fes'):
raise ValueError('algorithm=exhaustive_search requires the optional library FES. Run "install_package(\'fes\')" to install it.')
if not is_package_installed('libFES'):
raise ValueError('algorithm=exhaustive_search requires the optional library libFES. Run "sage -i libFES" to install it.')
from sage.libs.fes import exhaustive_search
solutions = exhaustive_search(S, max_sols=n, verbose=verbose, **kwds)

Expand Down

0 comments on commit 2b2ff60

Please sign in to comment.