applied-ai-018 commited on
Commit
b99c033
·
verified ·
1 Parent(s): 85d0127

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/__init__.cpython-310.pyc +0 -0
  2. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/appellseqs.cpython-310.pyc +0 -0
  3. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/compatibility.cpython-310.pyc +0 -0
  4. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/constructor.cpython-310.pyc +0 -0
  5. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/densearith.cpython-310.pyc +0 -0
  6. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/densetools.cpython-310.pyc +0 -0
  7. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/distributedmodules.cpython-310.pyc +0 -0
  8. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/domainmatrix.cpython-310.pyc +0 -0
  9. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/factortools.cpython-310.pyc +0 -0
  10. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/fields.cpython-310.pyc +0 -0
  11. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/galoistools.cpython-310.pyc +0 -0
  12. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/groebnertools.cpython-310.pyc +0 -0
  13. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/modulargcd.cpython-310.pyc +0 -0
  14. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/monomials.cpython-310.pyc +0 -0
  15. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/multivariate_resultants.cpython-310.pyc +0 -0
  16. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/orderings.cpython-310.pyc +0 -0
  17. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/orthopolys.cpython-310.pyc +0 -0
  18. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/partfrac.cpython-310.pyc +0 -0
  19. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyclasses.cpython-310.pyc +0 -0
  20. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyconfig.cpython-310.pyc +0 -0
  21. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyerrors.cpython-310.pyc +0 -0
  22. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyfuncs.cpython-310.pyc +0 -0
  23. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polymatrix.cpython-310.pyc +0 -0
  24. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyoptions.cpython-310.pyc +0 -0
  25. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyquinticconst.cpython-310.pyc +0 -0
  26. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyroots.cpython-310.pyc +0 -0
  27. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polytools.cpython-310.pyc +0 -0
  28. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyutils.cpython-310.pyc +0 -0
  29. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/rationaltools.cpython-310.pyc +0 -0
  30. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/ring_series.cpython-310.pyc +0 -0
  31. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/rings.cpython-310.pyc +0 -0
  32. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/rootisolation.cpython-310.pyc +0 -0
  33. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/rootoftools.cpython-310.pyc +0 -0
  34. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/specialpolys.cpython-310.pyc +0 -0
  35. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/sqfreetools.cpython-310.pyc +0 -0
  36. llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/subresultants_qq_zz.cpython-310.pyc +0 -0
  37. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__init__.py +0 -0
  38. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  39. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__pycache__/test_extensions.cpython-310.pyc +0 -0
  40. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__pycache__/test_ideals.cpython-310.pyc +0 -0
  41. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__pycache__/test_modules.cpython-310.pyc +0 -0
  42. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/test_extensions.py +196 -0
  43. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/test_homomorphisms.py +113 -0
  44. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/test_ideals.py +131 -0
  45. llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/test_modules.py +408 -0
  46. llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__init__.py +27 -0
  47. llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__pycache__/__init__.cpython-310.pyc +0 -0
  48. llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__pycache__/basis.cpython-310.pyc +0 -0
  49. llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__pycache__/exceptions.cpython-310.pyc +0 -0
  50. llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__pycache__/galois_resolvents.cpython-310.pyc +0 -0
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (5.29 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/appellseqs.cpython-310.pyc ADDED
Binary file (8.71 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/compatibility.cpython-310.pyc ADDED
Binary file (62 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/constructor.cpython-310.pyc ADDED
Binary file (9.27 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/densearith.cpython-310.pyc ADDED
Binary file (34.3 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/densetools.cpython-310.pyc ADDED
Binary file (26.9 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/distributedmodules.cpython-310.pyc ADDED
Binary file (23 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/domainmatrix.cpython-310.pyc ADDED
Binary file (512 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/factortools.cpython-310.pyc ADDED
Binary file (33.3 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/fields.cpython-310.pyc ADDED
Binary file (18.9 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/galoistools.cpython-310.pyc ADDED
Binary file (53.4 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/groebnertools.cpython-310.pyc ADDED
Binary file (22.7 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/modulargcd.cpython-310.pyc ADDED
Binary file (49.7 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/monomials.cpython-310.pyc ADDED
Binary file (19.9 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/multivariate_resultants.cpython-310.pyc ADDED
Binary file (17.4 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/orderings.cpython-310.pyc ADDED
Binary file (11.8 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/orthopolys.cpython-310.pyc ADDED
Binary file (8.97 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/partfrac.cpython-310.pyc ADDED
Binary file (12.9 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyclasses.cpython-310.pyc ADDED
Binary file (55.1 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyconfig.cpython-310.pyc ADDED
Binary file (1.67 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyerrors.cpython-310.pyc ADDED
Binary file (7.18 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyfuncs.cpython-310.pyc ADDED
Binary file (8.74 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polymatrix.cpython-310.pyc ADDED
Binary file (11.7 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyoptions.cpython-310.pyc ADDED
Binary file (21.4 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyquinticconst.cpython-310.pyc ADDED
Binary file (132 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyroots.cpython-310.pyc ADDED
Binary file (31 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polytools.cpython-310.pyc ADDED
Binary file (176 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/polyutils.cpython-310.pyc ADDED
Binary file (15.7 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/rationaltools.cpython-310.pyc ADDED
Binary file (3.12 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/ring_series.cpython-310.pyc ADDED
Binary file (47.9 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/rings.cpython-310.pyc ADDED
Binary file (69.5 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/rootisolation.cpython-310.pyc ADDED
Binary file (51.2 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/rootoftools.cpython-310.pyc ADDED
Binary file (34.3 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/specialpolys.cpython-310.pyc ADDED
Binary file (14.4 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/sqfreetools.cpython-310.pyc ADDED
Binary file (11.1 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/__pycache__/subresultants_qq_zz.cpython-310.pyc ADDED
Binary file (68.2 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__init__.py ADDED
File without changes
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (195 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__pycache__/test_extensions.cpython-310.pyc ADDED
Binary file (7.87 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__pycache__/test_ideals.cpython-310.pyc ADDED
Binary file (4.74 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/__pycache__/test_modules.cpython-310.pyc ADDED
Binary file (15.8 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/test_extensions.py ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sympy.core.symbol import symbols
2
+ from sympy.functions.elementary.trigonometric import (cos, sin)
3
+ from sympy.polys import QQ, ZZ
4
+ from sympy.polys.polytools import Poly
5
+ from sympy.polys.polyerrors import NotInvertible
6
+ from sympy.polys.agca.extensions import FiniteExtension
7
+ from sympy.polys.domainmatrix import DomainMatrix
8
+
9
+ from sympy.testing.pytest import raises
10
+
11
+ from sympy.abc import x, y, t
12
+
13
+
14
+ def test_FiniteExtension():
15
+ # Gaussian integers
16
+ A = FiniteExtension(Poly(x**2 + 1, x))
17
+ assert A.rank == 2
18
+ assert str(A) == 'ZZ[x]/(x**2 + 1)'
19
+ i = A.generator
20
+ assert i.parent() is A
21
+
22
+ assert i*i == A(-1)
23
+ raises(TypeError, lambda: i*())
24
+
25
+ assert A.basis == (A.one, i)
26
+ assert A(1) == A.one
27
+ assert i**2 == A(-1)
28
+ assert i**2 != -1 # no coercion
29
+ assert (2 + i)*(1 - i) == 3 - i
30
+ assert (1 + i)**8 == A(16)
31
+ assert A(1).inverse() == A(1)
32
+ raises(NotImplementedError, lambda: A(2).inverse())
33
+
34
+ # Finite field of order 27
35
+ F = FiniteExtension(Poly(x**3 - x + 1, x, modulus=3))
36
+ assert F.rank == 3
37
+ a = F.generator # also generates the cyclic group F - {0}
38
+ assert F.basis == (F(1), a, a**2)
39
+ assert a**27 == a
40
+ assert a**26 == F(1)
41
+ assert a**13 == F(-1)
42
+ assert a**9 == a + 1
43
+ assert a**3 == a - 1
44
+ assert a**6 == a**2 + a + 1
45
+ assert F(x**2 + x).inverse() == 1 - a
46
+ assert F(x + 2)**(-1) == F(x + 2).inverse()
47
+ assert a**19 * a**(-19) == F(1)
48
+ assert (a - 1) / (2*a**2 - 1) == a**2 + 1
49
+ assert (a - 1) // (2*a**2 - 1) == a**2 + 1
50
+ assert 2/(a**2 + 1) == a**2 - a + 1
51
+ assert (a**2 + 1)/2 == -a**2 - 1
52
+ raises(NotInvertible, lambda: F(0).inverse())
53
+
54
+ # Function field of an elliptic curve
55
+ K = FiniteExtension(Poly(t**2 - x**3 - x + 1, t, field=True))
56
+ assert K.rank == 2
57
+ assert str(K) == 'ZZ(x)[t]/(t**2 - x**3 - x + 1)'
58
+ y = K.generator
59
+ c = 1/(x**3 - x**2 + x - 1)
60
+ assert ((y + x)*(y - x)).inverse() == K(c)
61
+ assert (y + x)*(y - x)*c == K(1) # explicit inverse of y + x
62
+
63
+
64
+ def test_FiniteExtension_eq_hash():
65
+ # Test eq and hash
66
+ p1 = Poly(x**2 - 2, x, domain=ZZ)
67
+ p2 = Poly(x**2 - 2, x, domain=QQ)
68
+ K1 = FiniteExtension(p1)
69
+ K2 = FiniteExtension(p2)
70
+ assert K1 == FiniteExtension(Poly(x**2 - 2))
71
+ assert K2 != FiniteExtension(Poly(x**2 - 2))
72
+ assert len({K1, K2, FiniteExtension(p1)}) == 2
73
+
74
+
75
+ def test_FiniteExtension_mod():
76
+ # Test mod
77
+ K = FiniteExtension(Poly(x**3 + 1, x, domain=QQ))
78
+ xf = K(x)
79
+ assert (xf**2 - 1) % 1 == K.zero
80
+ assert 1 % (xf**2 - 1) == K.zero
81
+ assert (xf**2 - 1) / (xf - 1) == xf + 1
82
+ assert (xf**2 - 1) // (xf - 1) == xf + 1
83
+ assert (xf**2 - 1) % (xf - 1) == K.zero
84
+ raises(ZeroDivisionError, lambda: (xf**2 - 1) % 0)
85
+ raises(TypeError, lambda: xf % [])
86
+ raises(TypeError, lambda: [] % xf)
87
+
88
+ # Test mod over ring
89
+ K = FiniteExtension(Poly(x**3 + 1, x, domain=ZZ))
90
+ xf = K(x)
91
+ assert (xf**2 - 1) % 1 == K.zero
92
+ raises(NotImplementedError, lambda: (xf**2 - 1) % (xf - 1))
93
+
94
+
95
+ def test_FiniteExtension_from_sympy():
96
+ # Test to_sympy/from_sympy
97
+ K = FiniteExtension(Poly(x**3 + 1, x, domain=ZZ))
98
+ xf = K(x)
99
+ assert K.from_sympy(x) == xf
100
+ assert K.to_sympy(xf) == x
101
+
102
+
103
+ def test_FiniteExtension_set_domain():
104
+ KZ = FiniteExtension(Poly(x**2 + 1, x, domain='ZZ'))
105
+ KQ = FiniteExtension(Poly(x**2 + 1, x, domain='QQ'))
106
+ assert KZ.set_domain(QQ) == KQ
107
+
108
+
109
+ def test_FiniteExtension_exquo():
110
+ # Test exquo
111
+ K = FiniteExtension(Poly(x**4 + 1))
112
+ xf = K(x)
113
+ assert K.exquo(xf**2 - 1, xf - 1) == xf + 1
114
+
115
+
116
+ def test_FiniteExtension_convert():
117
+ # Test from_MonogenicFiniteExtension
118
+ K1 = FiniteExtension(Poly(x**2 + 1))
119
+ K2 = QQ[x]
120
+ x1, x2 = K1(x), K2(x)
121
+ assert K1.convert(x2) == x1
122
+ assert K2.convert(x1) == x2
123
+
124
+ K = FiniteExtension(Poly(x**2 - 1, domain=QQ))
125
+ assert K.convert_from(QQ(1, 2), QQ) == K.one/2
126
+
127
+
128
+ def test_FiniteExtension_division_ring():
129
+ # Test division in FiniteExtension over a ring
130
+ KQ = FiniteExtension(Poly(x**2 - 1, x, domain=QQ))
131
+ KZ = FiniteExtension(Poly(x**2 - 1, x, domain=ZZ))
132
+ KQt = FiniteExtension(Poly(x**2 - 1, x, domain=QQ[t]))
133
+ KQtf = FiniteExtension(Poly(x**2 - 1, x, domain=QQ.frac_field(t)))
134
+ assert KQ.is_Field is True
135
+ assert KZ.is_Field is False
136
+ assert KQt.is_Field is False
137
+ assert KQtf.is_Field is True
138
+ for K in KQ, KZ, KQt, KQtf:
139
+ xK = K.convert(x)
140
+ assert xK / K.one == xK
141
+ assert xK // K.one == xK
142
+ assert xK % K.one == K.zero
143
+ raises(ZeroDivisionError, lambda: xK / K.zero)
144
+ raises(ZeroDivisionError, lambda: xK // K.zero)
145
+ raises(ZeroDivisionError, lambda: xK % K.zero)
146
+ if K.is_Field:
147
+ assert xK / xK == K.one
148
+ assert xK // xK == K.one
149
+ assert xK % xK == K.zero
150
+ else:
151
+ raises(NotImplementedError, lambda: xK / xK)
152
+ raises(NotImplementedError, lambda: xK // xK)
153
+ raises(NotImplementedError, lambda: xK % xK)
154
+
155
+
156
+ def test_FiniteExtension_Poly():
157
+ K = FiniteExtension(Poly(x**2 - 2))
158
+ p = Poly(x, y, domain=K)
159
+ assert p.domain == K
160
+ assert p.as_expr() == x
161
+ assert (p**2).as_expr() == 2
162
+
163
+ K = FiniteExtension(Poly(x**2 - 2, x, domain=QQ))
164
+ K2 = FiniteExtension(Poly(t**2 - 2, t, domain=K))
165
+ assert str(K2) == 'QQ[x]/(x**2 - 2)[t]/(t**2 - 2)'
166
+
167
+ eK = K2.convert(x + t)
168
+ assert K2.to_sympy(eK) == x + t
169
+ assert K2.to_sympy(eK ** 2) == 4 + 2*x*t
170
+ p = Poly(x + t, y, domain=K2)
171
+ assert p**2 == Poly(4 + 2*x*t, y, domain=K2)
172
+
173
+
174
+ def test_FiniteExtension_sincos_jacobian():
175
+ # Use FiniteExtensino to compute the Jacobian of a matrix involving sin
176
+ # and cos of different symbols.
177
+ r, p, t = symbols('rho, phi, theta')
178
+ elements = [
179
+ [sin(p)*cos(t), r*cos(p)*cos(t), -r*sin(p)*sin(t)],
180
+ [sin(p)*sin(t), r*cos(p)*sin(t), r*sin(p)*cos(t)],
181
+ [ cos(p), -r*sin(p), 0],
182
+ ]
183
+
184
+ def make_extension(K):
185
+ K = FiniteExtension(Poly(sin(p)**2+cos(p)**2-1, sin(p), domain=K[cos(p)]))
186
+ K = FiniteExtension(Poly(sin(t)**2+cos(t)**2-1, sin(t), domain=K[cos(t)]))
187
+ return K
188
+
189
+ Ksc1 = make_extension(ZZ[r])
190
+ Ksc2 = make_extension(ZZ)[r]
191
+
192
+ for K in [Ksc1, Ksc2]:
193
+ elements_K = [[K.convert(e) for e in row] for row in elements]
194
+ J = DomainMatrix(elements_K, (3, 3), K)
195
+ det = J.charpoly()[-1] * (-K.one)**3
196
+ assert det == K.convert(r**2*sin(p))
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/test_homomorphisms.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for homomorphisms."""
2
+
3
+ from sympy.core.singleton import S
4
+ from sympy.polys.domains.rationalfield import QQ
5
+ from sympy.abc import x, y
6
+ from sympy.polys.agca import homomorphism
7
+ from sympy.testing.pytest import raises
8
+
9
+
10
+ def test_printing():
11
+ R = QQ.old_poly_ring(x)
12
+
13
+ assert str(homomorphism(R.free_module(1), R.free_module(1), [0])) == \
14
+ 'Matrix([[0]]) : QQ[x]**1 -> QQ[x]**1'
15
+ assert str(homomorphism(R.free_module(2), R.free_module(2), [0, 0])) == \
16
+ 'Matrix([ \n[0, 0], : QQ[x]**2 -> QQ[x]**2\n[0, 0]]) '
17
+ assert str(homomorphism(R.free_module(1), R.free_module(1) / [[x]], [0])) == \
18
+ 'Matrix([[0]]) : QQ[x]**1 -> QQ[x]**1/<[x]>'
19
+ assert str(R.free_module(0).identity_hom()) == 'Matrix(0, 0, []) : QQ[x]**0 -> QQ[x]**0'
20
+
21
+ def test_operations():
22
+ F = QQ.old_poly_ring(x).free_module(2)
23
+ G = QQ.old_poly_ring(x).free_module(3)
24
+ f = F.identity_hom()
25
+ g = homomorphism(F, F, [0, [1, x]])
26
+ h = homomorphism(F, F, [[1, 0], 0])
27
+ i = homomorphism(F, G, [[1, 0, 0], [0, 1, 0]])
28
+
29
+ assert f == f
30
+ assert f != g
31
+ assert f != i
32
+ assert (f != F.identity_hom()) is False
33
+ assert 2*f == f*2 == homomorphism(F, F, [[2, 0], [0, 2]])
34
+ assert f/2 == homomorphism(F, F, [[S.Half, 0], [0, S.Half]])
35
+ assert f + g == homomorphism(F, F, [[1, 0], [1, x + 1]])
36
+ assert f - g == homomorphism(F, F, [[1, 0], [-1, 1 - x]])
37
+ assert f*g == g == g*f
38
+ assert h*g == homomorphism(F, F, [0, [1, 0]])
39
+ assert g*h == homomorphism(F, F, [0, 0])
40
+ assert i*f == i
41
+ assert f([1, 2]) == [1, 2]
42
+ assert g([1, 2]) == [2, 2*x]
43
+
44
+ assert i.restrict_domain(F.submodule([x, x]))([x, x]) == i([x, x])
45
+ h1 = h.quotient_domain(F.submodule([0, 1]))
46
+ assert h1([1, 0]) == h([1, 0])
47
+ assert h1.restrict_domain(h1.domain.submodule([x, 0]))([x, 0]) == h([x, 0])
48
+
49
+ raises(TypeError, lambda: f/g)
50
+ raises(TypeError, lambda: f + 1)
51
+ raises(TypeError, lambda: f + i)
52
+ raises(TypeError, lambda: f - 1)
53
+ raises(TypeError, lambda: f*i)
54
+
55
+
56
+ def test_creation():
57
+ F = QQ.old_poly_ring(x).free_module(3)
58
+ G = QQ.old_poly_ring(x).free_module(2)
59
+ SM = F.submodule([1, 1, 1])
60
+ Q = F / SM
61
+ SQ = Q.submodule([1, 0, 0])
62
+
63
+ matrix = [[1, 0], [0, 1], [-1, -1]]
64
+ h = homomorphism(F, G, matrix)
65
+ h2 = homomorphism(Q, G, matrix)
66
+ assert h.quotient_domain(SM) == h2
67
+ raises(ValueError, lambda: h.quotient_domain(F.submodule([1, 0, 0])))
68
+ assert h2.restrict_domain(SQ) == homomorphism(SQ, G, matrix)
69
+ raises(ValueError, lambda: h.restrict_domain(G))
70
+ raises(ValueError, lambda: h.restrict_codomain(G.submodule([1, 0])))
71
+ raises(ValueError, lambda: h.quotient_codomain(F))
72
+
73
+ im = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
74
+ for M in [F, SM, Q, SQ]:
75
+ assert M.identity_hom() == homomorphism(M, M, im)
76
+ assert SM.inclusion_hom() == homomorphism(SM, F, im)
77
+ assert SQ.inclusion_hom() == homomorphism(SQ, Q, im)
78
+ assert Q.quotient_hom() == homomorphism(F, Q, im)
79
+ assert SQ.quotient_hom() == homomorphism(SQ.base, SQ, im)
80
+
81
+ class conv:
82
+ def convert(x, y=None):
83
+ return x
84
+
85
+ class dummy:
86
+ container = conv()
87
+
88
+ def submodule(*args):
89
+ return None
90
+ raises(TypeError, lambda: homomorphism(dummy(), G, matrix))
91
+ raises(TypeError, lambda: homomorphism(F, dummy(), matrix))
92
+ raises(
93
+ ValueError, lambda: homomorphism(QQ.old_poly_ring(x, y).free_module(3), G, matrix))
94
+ raises(ValueError, lambda: homomorphism(F, G, [0, 0]))
95
+
96
+
97
+ def test_properties():
98
+ R = QQ.old_poly_ring(x, y)
99
+ F = R.free_module(2)
100
+ h = homomorphism(F, F, [[x, 0], [y, 0]])
101
+ assert h.kernel() == F.submodule([-y, x])
102
+ assert h.image() == F.submodule([x, 0], [y, 0])
103
+ assert not h.is_injective()
104
+ assert not h.is_surjective()
105
+ assert h.restrict_codomain(h.image()).is_surjective()
106
+ assert h.restrict_domain(F.submodule([1, 0])).is_injective()
107
+ assert h.quotient_domain(
108
+ h.kernel()).restrict_codomain(h.image()).is_isomorphism()
109
+
110
+ R2 = QQ.old_poly_ring(x, y, order=(("lex", x), ("ilex", y))) / [x**2 + 1]
111
+ F = R2.free_module(2)
112
+ h = homomorphism(F, F, [[x, 0], [y, y + 1]])
113
+ assert h.is_isomorphism()
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/test_ideals.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Test ideals.py code."""
2
+
3
+ from sympy.polys import QQ, ilex
4
+ from sympy.abc import x, y, z
5
+ from sympy.testing.pytest import raises
6
+
7
+
8
+ def test_ideal_operations():
9
+ R = QQ.old_poly_ring(x, y)
10
+ I = R.ideal(x)
11
+ J = R.ideal(y)
12
+ S = R.ideal(x*y)
13
+ T = R.ideal(x, y)
14
+
15
+ assert not (I == J)
16
+ assert I == I
17
+
18
+ assert I.union(J) == T
19
+ assert I + J == T
20
+ assert I + T == T
21
+
22
+ assert not I.subset(T)
23
+ assert T.subset(I)
24
+
25
+ assert I.product(J) == S
26
+ assert I*J == S
27
+ assert x*J == S
28
+ assert I*y == S
29
+ assert R.convert(x)*J == S
30
+ assert I*R.convert(y) == S
31
+
32
+ assert not I.is_zero()
33
+ assert not J.is_whole_ring()
34
+
35
+ assert R.ideal(x**2 + 1, x).is_whole_ring()
36
+ assert R.ideal() == R.ideal(0)
37
+ assert R.ideal().is_zero()
38
+
39
+ assert T.contains(x*y)
40
+ assert T.subset([x, y])
41
+
42
+ assert T.in_terms_of_generators(x) == [R(1), R(0)]
43
+
44
+ assert T**0 == R.ideal(1)
45
+ assert T**1 == T
46
+ assert T**2 == R.ideal(x**2, y**2, x*y)
47
+ assert I**5 == R.ideal(x**5)
48
+
49
+
50
+ def test_exceptions():
51
+ I = QQ.old_poly_ring(x).ideal(x)
52
+ J = QQ.old_poly_ring(y).ideal(1)
53
+ raises(ValueError, lambda: I.union(x))
54
+ raises(ValueError, lambda: I + J)
55
+ raises(ValueError, lambda: I * J)
56
+ raises(ValueError, lambda: I.union(J))
57
+ assert (I == J) is False
58
+ assert I != J
59
+
60
+
61
+ def test_nontriv_global():
62
+ R = QQ.old_poly_ring(x, y, z)
63
+
64
+ def contains(I, f):
65
+ return R.ideal(*I).contains(f)
66
+
67
+ assert contains([x, y], x)
68
+ assert contains([x, y], x + y)
69
+ assert not contains([x, y], 1)
70
+ assert not contains([x, y], z)
71
+ assert contains([x**2 + y, x**2 + x], x - y)
72
+ assert not contains([x + y + z, x*y + x*z + y*z, x*y*z], x**2)
73
+ assert contains([x + y + z, x*y + x*z + y*z, x*y*z], x**3)
74
+ assert contains([x + y + z, x*y + x*z + y*z, x*y*z], x**4)
75
+ assert not contains([x + y + z, x*y + x*z + y*z, x*y*z], x*y**2)
76
+ assert contains([x + y + z, x*y + x*z + y*z, x*y*z], x**4 + y**3 + 2*z*y*x)
77
+ assert contains([x + y + z, x*y + x*z + y*z, x*y*z], x*y*z)
78
+ assert contains([x, 1 + x + y, 5 - 7*y], 1)
79
+ assert contains(
80
+ [x**3 + y**3, y**3 + z**3, z**3 + x**3, x**2*y + x**2*z + y**2*z],
81
+ x**3)
82
+ assert not contains(
83
+ [x**3 + y**3, y**3 + z**3, z**3 + x**3, x**2*y + x**2*z + y**2*z],
84
+ x**2 + y**2)
85
+
86
+ # compare local order
87
+ assert not contains([x*(1 + x + y), y*(1 + z)], x)
88
+ assert not contains([x*(1 + x + y), y*(1 + z)], x + y)
89
+
90
+
91
+ def test_nontriv_local():
92
+ R = QQ.old_poly_ring(x, y, z, order=ilex)
93
+
94
+ def contains(I, f):
95
+ return R.ideal(*I).contains(f)
96
+
97
+ assert contains([x, y], x)
98
+ assert contains([x, y], x + y)
99
+ assert not contains([x, y], 1)
100
+ assert not contains([x, y], z)
101
+ assert contains([x**2 + y, x**2 + x], x - y)
102
+ assert not contains([x + y + z, x*y + x*z + y*z, x*y*z], x**2)
103
+ assert contains([x*(1 + x + y), y*(1 + z)], x)
104
+ assert contains([x*(1 + x + y), y*(1 + z)], x + y)
105
+
106
+
107
+ def test_intersection():
108
+ R = QQ.old_poly_ring(x, y, z)
109
+ # SCA, example 1.8.11
110
+ assert R.ideal(x, y).intersect(R.ideal(y**2, z)) == R.ideal(y**2, y*z, x*z)
111
+
112
+ assert R.ideal(x, y).intersect(R.ideal()).is_zero()
113
+
114
+ R = QQ.old_poly_ring(x, y, z, order="ilex")
115
+ assert R.ideal(x, y).intersect(R.ideal(y**2 + y**2*z, z + z*x**3*y)) == \
116
+ R.ideal(y**2, y*z, x*z)
117
+
118
+
119
+ def test_quotient():
120
+ # SCA, example 1.8.13
121
+ R = QQ.old_poly_ring(x, y, z)
122
+ assert R.ideal(x, y).quotient(R.ideal(y**2, z)) == R.ideal(x, y)
123
+
124
+
125
+ def test_reduction():
126
+ from sympy.polys.distributedmodules import sdm_nf_buchberger_reduced
127
+ R = QQ.old_poly_ring(x, y)
128
+ I = R.ideal(x**5, y)
129
+ e = R.convert(x**3 + y**2)
130
+ assert I.reduce_element(e) == e
131
+ assert I.reduce_element(e, NF=sdm_nf_buchberger_reduced) == R.convert(x**3)
llmeval-env/lib/python3.10/site-packages/sympy/polys/agca/tests/test_modules.py ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Test modules.py code."""
2
+
3
+ from sympy.polys.agca.modules import FreeModule, ModuleOrder, FreeModulePolyRing
4
+ from sympy.polys import CoercionFailed, QQ, lex, grlex, ilex, ZZ
5
+ from sympy.abc import x, y, z
6
+ from sympy.testing.pytest import raises
7
+ from sympy.core.numbers import Rational
8
+
9
+
10
+ def test_FreeModuleElement():
11
+ M = QQ.old_poly_ring(x).free_module(3)
12
+ e = M.convert([1, x, x**2])
13
+ f = [QQ.old_poly_ring(x).convert(1), QQ.old_poly_ring(x).convert(x), QQ.old_poly_ring(x).convert(x**2)]
14
+ assert list(e) == f
15
+ assert f[0] == e[0]
16
+ assert f[1] == e[1]
17
+ assert f[2] == e[2]
18
+ raises(IndexError, lambda: e[3])
19
+
20
+ g = M.convert([x, 0, 0])
21
+ assert e + g == M.convert([x + 1, x, x**2])
22
+ assert f + g == M.convert([x + 1, x, x**2])
23
+ assert -e == M.convert([-1, -x, -x**2])
24
+ assert e - g == M.convert([1 - x, x, x**2])
25
+ assert e != g
26
+
27
+ assert M.convert([x, x, x]) / QQ.old_poly_ring(x).convert(x) == [1, 1, 1]
28
+ R = QQ.old_poly_ring(x, order="ilex")
29
+ assert R.free_module(1).convert([x]) / R.convert(x) == [1]
30
+
31
+
32
+ def test_FreeModule():
33
+ M1 = FreeModule(QQ.old_poly_ring(x), 2)
34
+ assert M1 == FreeModule(QQ.old_poly_ring(x), 2)
35
+ assert M1 != FreeModule(QQ.old_poly_ring(y), 2)
36
+ assert M1 != FreeModule(QQ.old_poly_ring(x), 3)
37
+ M2 = FreeModule(QQ.old_poly_ring(x, order="ilex"), 2)
38
+
39
+ assert [x, 1] in M1
40
+ assert [x] not in M1
41
+ assert [2, y] not in M1
42
+ assert [1/(x + 1), 2] not in M1
43
+
44
+ e = M1.convert([x, x**2 + 1])
45
+ X = QQ.old_poly_ring(x).convert(x)
46
+ assert e == [X, X**2 + 1]
47
+ assert e == [x, x**2 + 1]
48
+ assert 2*e == [2*x, 2*x**2 + 2]
49
+ assert e*2 == [2*x, 2*x**2 + 2]
50
+ assert e/2 == [x/2, (x**2 + 1)/2]
51
+ assert x*e == [x**2, x**3 + x]
52
+ assert e*x == [x**2, x**3 + x]
53
+ assert X*e == [x**2, x**3 + x]
54
+ assert e*X == [x**2, x**3 + x]
55
+
56
+ assert [x, 1] in M2
57
+ assert [x] not in M2
58
+ assert [2, y] not in M2
59
+ assert [1/(x + 1), 2] in M2
60
+
61
+ e = M2.convert([x, x**2 + 1])
62
+ X = QQ.old_poly_ring(x, order="ilex").convert(x)
63
+ assert e == [X, X**2 + 1]
64
+ assert e == [x, x**2 + 1]
65
+ assert 2*e == [2*x, 2*x**2 + 2]
66
+ assert e*2 == [2*x, 2*x**2 + 2]
67
+ assert e/2 == [x/2, (x**2 + 1)/2]
68
+ assert x*e == [x**2, x**3 + x]
69
+ assert e*x == [x**2, x**3 + x]
70
+ assert e/(1 + x) == [x/(1 + x), (x**2 + 1)/(1 + x)]
71
+ assert X*e == [x**2, x**3 + x]
72
+ assert e*X == [x**2, x**3 + x]
73
+
74
+ M3 = FreeModule(QQ.old_poly_ring(x, y), 2)
75
+ assert M3.convert(e) == M3.convert([x, x**2 + 1])
76
+
77
+ assert not M3.is_submodule(0)
78
+ assert not M3.is_zero()
79
+
80
+ raises(NotImplementedError, lambda: ZZ.old_poly_ring(x).free_module(2))
81
+ raises(NotImplementedError, lambda: FreeModulePolyRing(ZZ, 2))
82
+ raises(CoercionFailed, lambda: M1.convert(QQ.old_poly_ring(x).free_module(3)
83
+ .convert([1, 2, 3])))
84
+ raises(CoercionFailed, lambda: M3.convert(1))
85
+
86
+
87
+ def test_ModuleOrder():
88
+ o1 = ModuleOrder(lex, grlex, False)
89
+ o2 = ModuleOrder(ilex, lex, False)
90
+
91
+ assert o1 == ModuleOrder(lex, grlex, False)
92
+ assert (o1 != ModuleOrder(lex, grlex, False)) is False
93
+ assert o1 != o2
94
+
95
+ assert o1((1, 2, 3)) == (1, (5, (2, 3)))
96
+ assert o2((1, 2, 3)) == (-1, (2, 3))
97
+
98
+
99
+ def test_SubModulePolyRing_global():
100
+ R = QQ.old_poly_ring(x, y)
101
+ F = R.free_module(3)
102
+ Fd = F.submodule([1, 0, 0], [1, 2, 0], [1, 2, 3])
103
+ M = F.submodule([x**2 + y**2, 1, 0], [x, y, 1])
104
+
105
+ assert F == Fd
106
+ assert Fd == F
107
+ assert F != M
108
+ assert M != F
109
+ assert Fd != M
110
+ assert M != Fd
111
+ assert Fd == F.submodule(*F.basis())
112
+
113
+ assert Fd.is_full_module()
114
+ assert not M.is_full_module()
115
+ assert not Fd.is_zero()
116
+ assert not M.is_zero()
117
+ assert Fd.submodule().is_zero()
118
+
119
+ assert M.contains([x**2 + y**2 + x, 1 + y, 1])
120
+ assert not M.contains([x**2 + y**2 + x, 1 + y, 2])
121
+ assert M.contains([y**2, 1 - x*y, -x])
122
+
123
+ assert not F.submodule([1 + x, 0, 0]) == F.submodule([1, 0, 0])
124
+ assert F.submodule([1, 0, 0], [0, 1, 0]).union(F.submodule([0, 0, 1])) == F
125
+ assert not M.is_submodule(0)
126
+
127
+ m = F.convert([x**2 + y**2, 1, 0])
128
+ n = M.convert(m)
129
+ assert m.module is F
130
+ assert n.module is M
131
+
132
+ raises(ValueError, lambda: M.submodule([1, 0, 0]))
133
+ raises(TypeError, lambda: M.union(1))
134
+ raises(ValueError, lambda: M.union(R.free_module(1).submodule([x])))
135
+
136
+ assert F.submodule([x, x, x]) != F.submodule([x, x, x], order="ilex")
137
+
138
+
139
+ def test_SubModulePolyRing_local():
140
+ R = QQ.old_poly_ring(x, y, order=ilex)
141
+ F = R.free_module(3)
142
+ Fd = F.submodule([1 + x, 0, 0], [1 + y, 2 + 2*y, 0], [1, 2, 3])
143
+ M = F.submodule([x**2 + y**2, 1, 0], [x, y, 1])
144
+
145
+ assert F == Fd
146
+ assert Fd == F
147
+ assert F != M
148
+ assert M != F
149
+ assert Fd != M
150
+ assert M != Fd
151
+ assert Fd == F.submodule(*F.basis())
152
+
153
+ assert Fd.is_full_module()
154
+ assert not M.is_full_module()
155
+ assert not Fd.is_zero()
156
+ assert not M.is_zero()
157
+ assert Fd.submodule().is_zero()
158
+
159
+ assert M.contains([x**2 + y**2 + x, 1 + y, 1])
160
+ assert not M.contains([x**2 + y**2 + x, 1 + y, 2])
161
+ assert M.contains([y**2, 1 - x*y, -x])
162
+
163
+ assert F.submodule([1 + x, 0, 0]) == F.submodule([1, 0, 0])
164
+ assert F.submodule(
165
+ [1, 0, 0], [0, 1, 0]).union(F.submodule([0, 0, 1 + x*y])) == F
166
+
167
+ raises(ValueError, lambda: M.submodule([1, 0, 0]))
168
+
169
+
170
+ def test_SubModulePolyRing_nontriv_global():
171
+ R = QQ.old_poly_ring(x, y, z)
172
+ F = R.free_module(1)
173
+
174
+ def contains(I, f):
175
+ return F.submodule(*[[g] for g in I]).contains([f])
176
+
177
+ assert contains([x, y], x)
178
+ assert contains([x, y], x + y)
179
+ assert not contains([x, y], 1)
180
+ assert not contains([x, y], z)
181
+ assert contains([x**2 + y, x**2 + x], x - y)
182
+ assert not contains([x + y + z, x*y + x*z + y*z, x*y*z], x**2)
183
+ assert contains([x + y + z, x*y + x*z + y*z, x*y*z], x**3)
184
+ assert contains([x + y + z, x*y + x*z + y*z, x*y*z], x**4)
185
+ assert not contains([x + y + z, x*y + x*z + y*z, x*y*z], x*y**2)
186
+ assert contains([x + y + z, x*y + x*z + y*z, x*y*z], x**4 + y**3 + 2*z*y*x)
187
+ assert contains([x + y + z, x*y + x*z + y*z, x*y*z], x*y*z)
188
+ assert contains([x, 1 + x + y, 5 - 7*y], 1)
189
+ assert contains(
190
+ [x**3 + y**3, y**3 + z**3, z**3 + x**3, x**2*y + x**2*z + y**2*z],
191
+ x**3)
192
+ assert not contains(
193
+ [x**3 + y**3, y**3 + z**3, z**3 + x**3, x**2*y + x**2*z + y**2*z],
194
+ x**2 + y**2)
195
+
196
+ # compare local order
197
+ assert not contains([x*(1 + x + y), y*(1 + z)], x)
198
+ assert not contains([x*(1 + x + y), y*(1 + z)], x + y)
199
+
200
+
201
+ def test_SubModulePolyRing_nontriv_local():
202
+ R = QQ.old_poly_ring(x, y, z, order=ilex)
203
+ F = R.free_module(1)
204
+
205
+ def contains(I, f):
206
+ return F.submodule(*[[g] for g in I]).contains([f])
207
+
208
+ assert contains([x, y], x)
209
+ assert contains([x, y], x + y)
210
+ assert not contains([x, y], 1)
211
+ assert not contains([x, y], z)
212
+ assert contains([x**2 + y, x**2 + x], x - y)
213
+ assert not contains([x + y + z, x*y + x*z + y*z, x*y*z], x**2)
214
+ assert contains([x*(1 + x + y), y*(1 + z)], x)
215
+ assert contains([x*(1 + x + y), y*(1 + z)], x + y)
216
+
217
+
218
+ def test_syzygy():
219
+ R = QQ.old_poly_ring(x, y, z)
220
+ M = R.free_module(1).submodule([x*y], [y*z], [x*z])
221
+ S = R.free_module(3).submodule([0, x, -y], [z, -x, 0])
222
+ assert M.syzygy_module() == S
223
+
224
+ M2 = M / ([x*y*z],)
225
+ S2 = R.free_module(3).submodule([z, 0, 0], [0, x, 0], [0, 0, y])
226
+ assert M2.syzygy_module() == S2
227
+
228
+ F = R.free_module(3)
229
+ assert F.submodule(*F.basis()).syzygy_module() == F.submodule()
230
+
231
+ R2 = QQ.old_poly_ring(x, y, z) / [x*y*z]
232
+ M3 = R2.free_module(1).submodule([x*y], [y*z], [x*z])
233
+ S3 = R2.free_module(3).submodule([z, 0, 0], [0, x, 0], [0, 0, y])
234
+ assert M3.syzygy_module() == S3
235
+
236
+
237
+ def test_in_terms_of_generators():
238
+ R = QQ.old_poly_ring(x, order="ilex")
239
+ M = R.free_module(2).submodule([2*x, 0], [1, 2])
240
+ assert M.in_terms_of_generators(
241
+ [x, x]) == [R.convert(Rational(1, 4)), R.convert(x/2)]
242
+ raises(ValueError, lambda: M.in_terms_of_generators([1, 0]))
243
+
244
+ M = R.free_module(2) / ([x, 0], [1, 1])
245
+ SM = M.submodule([1, x])
246
+ assert SM.in_terms_of_generators([2, 0]) == [R.convert(-2/(x - 1))]
247
+
248
+ R = QQ.old_poly_ring(x, y) / [x**2 - y**2]
249
+ M = R.free_module(2)
250
+ SM = M.submodule([x, 0], [0, y])
251
+ assert SM.in_terms_of_generators(
252
+ [x**2, x**2]) == [R.convert(x), R.convert(y)]
253
+
254
+
255
+ def test_QuotientModuleElement():
256
+ R = QQ.old_poly_ring(x)
257
+ F = R.free_module(3)
258
+ N = F.submodule([1, x, x**2])
259
+ M = F/N
260
+ e = M.convert([x**2, 2, 0])
261
+
262
+ assert M.convert([x + 1, x**2 + x, x**3 + x**2]) == 0
263
+ assert e == [x**2, 2, 0] + N == F.convert([x**2, 2, 0]) + N == \
264
+ M.convert(F.convert([x**2, 2, 0]))
265
+
266
+ assert M.convert([x**2 + 1, 2*x + 2, x**2]) == e + [0, x, 0] == \
267
+ e + M.convert([0, x, 0]) == e + F.convert([0, x, 0])
268
+ assert M.convert([x**2 + 1, 2, x**2]) == e - [0, x, 0] == \
269
+ e - M.convert([0, x, 0]) == e - F.convert([0, x, 0])
270
+ assert M.convert([0, 2, 0]) == M.convert([x**2, 4, 0]) - e == \
271
+ [x**2, 4, 0] - e == F.convert([x**2, 4, 0]) - e
272
+ assert M.convert([x**3 + x**2, 2*x + 2, 0]) == (1 + x)*e == \
273
+ R.convert(1 + x)*e == e*(1 + x) == e*R.convert(1 + x)
274
+ assert -e == [-x**2, -2, 0]
275
+
276
+ f = [x, x, 0] + N
277
+ assert M.convert([1, 1, 0]) == f / x == f / R.convert(x)
278
+
279
+ M2 = F/[(2, 2*x, 2*x**2), (0, 0, 1)]
280
+ G = R.free_module(2)
281
+ M3 = G/[[1, x]]
282
+ M4 = F.submodule([1, x, x**2], [1, 0, 0]) / N
283
+ raises(CoercionFailed, lambda: M.convert(G.convert([1, x])))
284
+ raises(CoercionFailed, lambda: M.convert(M3.convert([1, x])))
285
+ raises(CoercionFailed, lambda: M.convert(M2.convert([1, x, x])))
286
+ assert M2.convert(M.convert([2, x, x**2])) == [2, x, 0]
287
+ assert M.convert(M4.convert([2, 0, 0])) == [2, 0, 0]
288
+
289
+
290
+ def test_QuotientModule():
291
+ R = QQ.old_poly_ring(x)
292
+ F = R.free_module(3)
293
+ N = F.submodule([1, x, x**2])
294
+ M = F/N
295
+
296
+ assert M != F
297
+ assert M != N
298
+ assert M == F / [(1, x, x**2)]
299
+ assert not M.is_zero()
300
+ assert (F / F.basis()).is_zero()
301
+
302
+ SQ = F.submodule([1, x, x**2], [2, 0, 0]) / N
303
+ assert SQ == M.submodule([2, x, x**2])
304
+ assert SQ != M.submodule([2, 1, 0])
305
+ assert SQ != M
306
+ assert M.is_submodule(SQ)
307
+ assert not SQ.is_full_module()
308
+
309
+ raises(ValueError, lambda: N/F)
310
+ raises(ValueError, lambda: F.submodule([2, 0, 0]) / N)
311
+ raises(ValueError, lambda: R.free_module(2)/F)
312
+ raises(CoercionFailed, lambda: F.convert(M.convert([1, x, x**2])))
313
+
314
+ M1 = F / [[1, 1, 1]]
315
+ M2 = M1.submodule([1, 0, 0], [0, 1, 0])
316
+ assert M1 == M2
317
+
318
+
319
+ def test_ModulesQuotientRing():
320
+ R = QQ.old_poly_ring(x, y, order=(("lex", x), ("ilex", y))) / [x**2 + 1]
321
+ M1 = R.free_module(2)
322
+ assert M1 == R.free_module(2)
323
+ assert M1 != QQ.old_poly_ring(x).free_module(2)
324
+ assert M1 != R.free_module(3)
325
+
326
+ assert [x, 1] in M1
327
+ assert [x] not in M1
328
+ assert [1/(R.convert(x) + 1), 2] in M1
329
+ assert [1, 2/(1 + y)] in M1
330
+ assert [1, 2/y] not in M1
331
+
332
+ assert M1.convert([x**2, y]) == [-1, y]
333
+
334
+ F = R.free_module(3)
335
+ Fd = F.submodule([x**2, 0, 0], [1, 2, 0], [1, 2, 3])
336
+ M = F.submodule([x**2 + y**2, 1, 0], [x, y, 1])
337
+
338
+ assert F == Fd
339
+ assert Fd == F
340
+ assert F != M
341
+ assert M != F
342
+ assert Fd != M
343
+ assert M != Fd
344
+ assert Fd == F.submodule(*F.basis())
345
+
346
+ assert Fd.is_full_module()
347
+ assert not M.is_full_module()
348
+ assert not Fd.is_zero()
349
+ assert not M.is_zero()
350
+ assert Fd.submodule().is_zero()
351
+
352
+ assert M.contains([x**2 + y**2 + x, -x**2 + y, 1])
353
+ assert not M.contains([x**2 + y**2 + x, 1 + y, 2])
354
+ assert M.contains([y**2, 1 - x*y, -x])
355
+
356
+ assert F.submodule([x, 0, 0]) == F.submodule([1, 0, 0])
357
+ assert not F.submodule([y, 0, 0]) == F.submodule([1, 0, 0])
358
+ assert F.submodule([1, 0, 0], [0, 1, 0]).union(F.submodule([0, 0, 1])) == F
359
+ assert not M.is_submodule(0)
360
+
361
+
362
+ def test_module_mul():
363
+ R = QQ.old_poly_ring(x)
364
+ M = R.free_module(2)
365
+ S1 = M.submodule([x, 0], [0, x])
366
+ S2 = M.submodule([x**2, 0], [0, x**2])
367
+ I = R.ideal(x)
368
+
369
+ assert I*M == M*I == S1 == x*M == M*x
370
+ assert I*S1 == S2 == x*S1
371
+
372
+
373
+ def test_intersection():
374
+ # SCA, example 2.8.5
375
+ F = QQ.old_poly_ring(x, y).free_module(2)
376
+ M1 = F.submodule([x, y], [y, 1])
377
+ M2 = F.submodule([0, y - 1], [x, 1], [y, x])
378
+ I = F.submodule([x, y], [y**2 - y, y - 1], [x*y + y, x + 1])
379
+ I1, rel1, rel2 = M1.intersect(M2, relations=True)
380
+ assert I1 == M2.intersect(M1) == I
381
+ for i, g in enumerate(I1.gens):
382
+ assert g == sum(c*x for c, x in zip(rel1[i], M1.gens)) \
383
+ == sum(d*y for d, y in zip(rel2[i], M2.gens))
384
+
385
+ assert F.submodule([x, y]).intersect(F.submodule([y, x])).is_zero()
386
+
387
+
388
+ def test_quotient():
389
+ # SCA, example 2.8.6
390
+ R = QQ.old_poly_ring(x, y, z)
391
+ F = R.free_module(2)
392
+ assert F.submodule([x*y, x*z], [y*z, x*y]).module_quotient(
393
+ F.submodule([y, z], [z, y])) == QQ.old_poly_ring(x, y, z).ideal(x**2*y**2 - x*y*z**2)
394
+ assert F.submodule([x, y]).module_quotient(F.submodule()).is_whole_ring()
395
+
396
+ M = F.submodule([x**2, x**2], [y**2, y**2])
397
+ N = F.submodule([x + y, x + y])
398
+ q, rel = M.module_quotient(N, relations=True)
399
+ assert q == R.ideal(y**2, x - y)
400
+ for i, g in enumerate(q.gens):
401
+ assert g*N.gens[0] == sum(c*x for c, x in zip(rel[i], M.gens))
402
+
403
+
404
+ def test_groebner_extendend():
405
+ M = QQ.old_poly_ring(x, y, z).free_module(3).submodule([x + 1, y, 1], [x*y, z, z**2])
406
+ G, R = M._groebner_vec(extended=True)
407
+ for i, g in enumerate(G):
408
+ assert g == sum(c*gen for c, gen in zip(R[i], M.gens))
llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Computational algebraic field theory. """
2
+
3
+ __all__ = [
4
+ 'minpoly', 'minimal_polynomial',
5
+
6
+ 'field_isomorphism', 'primitive_element', 'to_number_field',
7
+
8
+ 'isolate',
9
+
10
+ 'round_two',
11
+
12
+ 'prime_decomp', 'prime_valuation',
13
+
14
+ 'galois_group',
15
+ ]
16
+
17
+ from .minpoly import minpoly, minimal_polynomial
18
+
19
+ from .subfield import field_isomorphism, primitive_element, to_number_field
20
+
21
+ from .utilities import isolate
22
+
23
+ from .basis import round_two
24
+
25
+ from .primes import prime_decomp, prime_valuation
26
+
27
+ from .galoisgroups import galois_group
llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (684 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__pycache__/basis.cpython-310.pyc ADDED
Binary file (7.27 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__pycache__/exceptions.cpython-310.pyc ADDED
Binary file (2.1 kB). View file
 
llmeval-env/lib/python3.10/site-packages/sympy/polys/numberfields/__pycache__/galois_resolvents.cpython-310.pyc ADDED
Binary file (24.3 kB). View file