/usr/lib/python2.7/dist-packages/brial/PyPolyBoRi.py is in python-brial 1.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | """PolyBoRi's interface to libpolybori*
This file makes interfaces to PolyBoRi's runtime libraries available in Python via sage.
AUTHOR:
The PolyBoRi Team, 2007-2012
Examples:
>>> from brial.frontend import *
>>> r=declare_ring(["x0","x1","x2","y0","y1","y2"], globals())
>>> x0>x1
True
>>> x0>x1*x2
True
>>> y0>y1
True
>>> y0>y1*y2
True
>>> r = r.clone(ordering=dlex)
>>> r(x0) > r(x1)
True
>>> r(x0) > r(x1*x2)
False
>>> r = r.clone(ordering=dp_asc)
>>> r(x0) > r(x1)
False
>>> r(x0) > r(x1*x2)
False
>>> r = r.clone(ordering=block_dlex, blocks=[3])
>>> r(x0) > r(x1)
True
>>> r(x0) > r(x1*x2)
False
>>> r(x0) > r(y0*y1*y2)
True
>>> r = r.clone(ordering=block_dp_asc)
>>> r(x0) > r(x1)
False
>>> r(x0) > r(y0)
False
>>> r(x0) > r(x1*x2)
False
>>> r = r.clone(ordering=block_dp_asc, blocks=[3])
>>> r(x0) > r(y0)
True
>>> r(x0) > r(y0*y1)
True
>>> r = r.clone(names=["z17", "z7"])
>>> [r.variable(idx) for idx in xrange(3)]
[z17, z7, x2]
>>> r = r.clone(names="abcde")
>>> [r.variable(idx) for idx in xrange(6)]
[a, b, c, d, e, y2]
"""
from sage import all
from sage.rings.polynomial.pbori import *
import weakref
class OrderCode:
pass
OrderCode.__dict__ = order_dict
OrderCode.__module__ = __name__
def Ring(n, order='lp', names=None, blocks=[]):
pbnames = names
if pbnames is None:
pbnames = ['x(' + str(idx) + ')' for idx in range(n)]
order = TermOrder_from_pb_order(n, order, blocks)
R = BooleanPolynomialRing(n, names=pbnames, order=order)
return R
BoolePolynomialVector = BooleanPolynomialVector
#todo: PolyBoRi's original interface uses its WeakRingPtr here
def WeakRingRef(ring):
return weakref.weakref(ring)
Monomial = MonomialFactory()
Polynomial = PolynomialFactory()
Variable = VariableFactory()
_add_up_polynomials = add_up_polynomials
def add_up_polynomials(polys, init):
"""
Adds up the polynomials in polys (which should be a BoolePolynomialVector or a sequence of ???
"""
if not isinstance(polys, BoolePolynomialVector):
vec = BoolePolynomialVector
for p in polys:
vec.append(p)
polys = vec
return _add_up_polynomials(polys, init)
_gauss_on_polys = gauss_on_polys
def gauss_on_polys(l):
vec = BoolePolynomialVector(l)
return list(_gauss_on_polys(vec))
|