1 | LIB "tst.lib"; |
---|
2 | tst_init(); |
---|
3 | |
---|
4 | |
---|
5 | //====================== Exercise 5.1 ============================= |
---|
6 | proc min_generating_set (matrix P,S) |
---|
7 | "USAGE: min_generating_set(P,S); P,S matrix |
---|
8 | ASSUME: The entries of P,S are homogeneous and ordered by ascending |
---|
9 | degrees. The first entry of S equals 1. (As satisfied by |
---|
10 | the first two output matrices of invariant_ring(G).) |
---|
11 | RETURN: ideal |
---|
12 | NOTE: The given generators for the output ideal form a minimal |
---|
13 | generating set for the ring generated by the entries of |
---|
14 | P,S. The generators are homogeneous and ordered by |
---|
15 | descending degrees. |
---|
16 | " |
---|
17 | { |
---|
18 | if (defined(flatten)==0) { LIB "matrix.lib"; } |
---|
19 | ideal I1,I2 = flatten(P),flatten(S); |
---|
20 | int i1,i2 = size(I1),size(I2); |
---|
21 | // We order the generators by descending degrees |
---|
22 | // (the first generator 1 of I2 is omitted): |
---|
23 | int i,j,s = i1,i2,i1+i2-1; |
---|
24 | ideal I; |
---|
25 | for (int k=1; k<=s; k++) |
---|
26 | { |
---|
27 | if (i==0) { I[k]=I2[j]; j--; } |
---|
28 | else |
---|
29 | { |
---|
30 | if (j==0) { I[k]=I1[i]; i--; } |
---|
31 | else |
---|
32 | { |
---|
33 | if (deg(I1[i])>deg(I2[j])) { I[k]=I1[i]; i--; } |
---|
34 | else { I[k]=I2[j]; j--; } |
---|
35 | } |
---|
36 | } |
---|
37 | } |
---|
38 | intvec deg_I = deg(I[1..s]); |
---|
39 | int n = nvars(basering); |
---|
40 | def BR = basering; |
---|
41 | |
---|
42 | // Create a new ring with elimination order: |
---|
43 | //--------------------------------------------------------------- |
---|
44 | // **** this part uses the command ringlist which is **** |
---|
45 | // **** only available in SINGULAR-3-0-0 or newer **** |
---|
46 | //--------------------------------------------------------------- |
---|
47 | list rData = ringlist(BR); |
---|
48 | intvec wDp; |
---|
49 | for (k=1; k<=n; k++) { |
---|
50 | rData[2][k] ="x("+string(k)+ ")"; |
---|
51 | wDp[k]=1; |
---|
52 | } |
---|
53 | for (k=1; k<=s; k++) { rData[2][n+k] ="y("+string(k)+ ")"; } |
---|
54 | rData[3][1] = list("dp",wDp); |
---|
55 | rData[3][2] = list("wp",deg_I); |
---|
56 | def R_aux = ring(rData); |
---|
57 | setring R_aux; |
---|
58 | //--------------------------------------------------------------- |
---|
59 | |
---|
60 | ideal J; |
---|
61 | map phi = BR, x(1..n); |
---|
62 | ideal I = phi(I); |
---|
63 | for (k=1; k<=s; k++) { J[k] = y(k)-I[k]; } |
---|
64 | option(redSB); |
---|
65 | J = std(J); |
---|
66 | |
---|
67 | // Remove all generators that are depending on some x(i) from J: |
---|
68 | int s_J = size(J); |
---|
69 | for (k=1; k<=s_J; k++) { if (J[k]>=x(n)) {J[k]=0;} } |
---|
70 | |
---|
71 | // The monomial order on K[y] is chosen such that linear leading |
---|
72 | // terms in J are in 1-1 correspondence to superfluous generators |
---|
73 | // in I : |
---|
74 | ideal J_1jet = std(jet(lead(J),1)); |
---|
75 | intvec to_remove; |
---|
76 | i=1; |
---|
77 | for (k=1; k<=s; k++) |
---|
78 | { |
---|
79 | if (reduce(y(k),J_1jet)==0){ to_remove[i]=k; i++; } |
---|
80 | } |
---|
81 | setring BR; |
---|
82 | if (to_remove == 0) { return(ideal(I)); } |
---|
83 | for (i=1; i<=size(to_remove); i++) |
---|
84 | { |
---|
85 | I[to_remove[i]] = 0; |
---|
86 | } |
---|
87 | I = simplify(I,2); |
---|
88 | return(I); |
---|
89 | } |
---|
90 | |
---|
91 | ring R1 = 0, (x,y), dp; |
---|
92 | matrix P[1][3] = x2+y2, x2-y2, x3-y3; |
---|
93 | matrix S[1][5] = 1, x-y, x3-xy2, x4-y4, xy3+y4; |
---|
94 | min_generating_set(P,S); |
---|
95 | //-> _[1]=x2-y2 |
---|
96 | //-> _[2]=x2+y2 |
---|
97 | //-> _[3]=x-y |
---|
98 | |
---|
99 | ring R = 2, x(1..4), dp; |
---|
100 | matrix A[4][4]; |
---|
101 | A[1,4]=1; A[2,1]=1; A[3,2]=1; A[4,3]=1; |
---|
102 | if (not(defined(invariant_ring))){ LIB "finvar.lib"; } |
---|
103 | matrix P,S = invariant_ring(A); |
---|
104 | ideal MGS = min_generating_set(P,S); |
---|
105 | deg(MGS[1]); |
---|
106 | //-> 5 |
---|
107 | |
---|
108 | |
---|
109 | kill R,R1; |
---|
110 | //====================== Exercise 5.2 ============================= |
---|
111 | proc is_unit (poly f) |
---|
112 | "USAGE: is_unit(f); f poly |
---|
113 | RETURN: int; 1 if f is a unit in the active ring, |
---|
114 | 0 otherwise. |
---|
115 | " |
---|
116 | { |
---|
117 | return(leadmonom(f)==1); |
---|
118 | } |
---|
119 | |
---|
120 | ring R = 0, (x,y), dp; |
---|
121 | poly f = 3+x; |
---|
122 | is_unit(f); |
---|
123 | ring R1 = 0, (x,y), ds; |
---|
124 | is_unit(imap(R,f)); |
---|
125 | ring R2 = 0, (x,y), (ds(1),dp); |
---|
126 | is_unit(imap(R,f)); |
---|
127 | ring R3 = 0, (x,y), (dp(1),ds); |
---|
128 | is_unit(imap(R,f)); |
---|
129 | |
---|
130 | proc invert_unit (poly u, int d) |
---|
131 | "USAGE: invert_unit(u,d); u poly, d int |
---|
132 | RETURN: poly; |
---|
133 | NOTE: If u is a unit in the active ring, the output polynomial |
---|
134 | is the power series expansion of the inverse of u up to |
---|
135 | order d. Otherwise, the zero polynomial is returned. |
---|
136 | " |
---|
137 | { |
---|
138 | if (is_unit(u)==0) { return(poly(0)); } |
---|
139 | poly u_0 = jet(u,0); |
---|
140 | u = jet(1-u/u_0,d); |
---|
141 | poly u_1 = u; |
---|
142 | poly inv = 1 + u_1; |
---|
143 | for (int i=2; i<=d; i++) |
---|
144 | { |
---|
145 | u_1 = jet(u_1*u,d); |
---|
146 | inv = inv + u_1; |
---|
147 | } |
---|
148 | return(inv/u_0); |
---|
149 | } |
---|
150 | |
---|
151 | setring R1; |
---|
152 | poly inv_f = invert_unit(imap(R,f),100); |
---|
153 | lead(imap(R,f)*inv_f - 1); |
---|
154 | //-> 1/1546132562196033993109383389296863818106322566003x101 |
---|
155 | |
---|
156 | |
---|
157 | kill R,R1,R2,R3; |
---|
158 | //====================== Exercise 5.3 ============================= |
---|
159 | if (not(defined(minAssGTZ))){ LIB "primdec.lib"; } |
---|
160 | ring R = 0, (x,y,z), dp; |
---|
161 | poly f = ((x4+y4-z4)^4-x2y5z9)*(x4+y4-z4); |
---|
162 | ideal Slocf = f,jacob(f); |
---|
163 | list SLoc = minAssGTZ(Slocf); |
---|
164 | SLoc; |
---|
165 | //-> [1]: |
---|
166 | //-> _[1]=x4+y4 |
---|
167 | //-> _[2]=z |
---|
168 | //-> [2]: |
---|
169 | //-> _[1]=y-z |
---|
170 | //-> _[2]=x |
---|
171 | //-> [3]: |
---|
172 | //-> _[1]=y+z |
---|
173 | //-> _[2]=x |
---|
174 | //-> [4]: |
---|
175 | //-> _[1]=y2+z2 |
---|
176 | //-> _[2]=x |
---|
177 | //-> [5]: |
---|
178 | //-> _[1]=x2+z2 |
---|
179 | //-> _[2]=y |
---|
180 | //-> [6]: |
---|
181 | //-> _[1]=y |
---|
182 | //-> _[2]=x+z |
---|
183 | //-> [7]: |
---|
184 | //-> _[1]=y |
---|
185 | //-> _[2]=x-z |
---|
186 | |
---|
187 | if (not(defined(hnexpansion))){ LIB "hnoether.lib"; } |
---|
188 | ring R_loc1 = 0, (u,v), ds; |
---|
189 | map phi = R,u,v-1,1; |
---|
190 | poly f = phi(f); |
---|
191 | def L1 = hnexpansion(f); |
---|
192 | def HNE_ring1 = L1[1]; |
---|
193 | setring HNE_ring1; |
---|
194 | list INV = invariants(hne); |
---|
195 | // Number of branches: |
---|
196 | size(INV)-1; |
---|
197 | //-> 3 |
---|
198 | // Intersection Multiplicities of the branches: |
---|
199 | print(INV[size(INV)][2]); |
---|
200 | //-> 0 1 1 |
---|
201 | //-> 1 0 2 |
---|
202 | //-> 1 2 0 |
---|
203 | |
---|
204 | for (int i=1; i<size(INV); i++) |
---|
205 | { |
---|
206 | if (INV[i][5]==0){ print("branch No."+string(i)+" is smooth");} |
---|
207 | } |
---|
208 | |
---|
209 | ring R_loc2 = (0,a), (u,v), ds; |
---|
210 | minpoly = a2+1; |
---|
211 | map phi = R,u,v-a,1; |
---|
212 | poly f = phi(f); |
---|
213 | def L2 = hnexpansion(f); |
---|
214 | def HNE_ring2 = L2[1]; |
---|
215 | setring HNE_ring2; |
---|
216 | displayInvariants(hne); |
---|
217 | |
---|
218 | ring R_loc3 = (0,a), (u,v), ds; |
---|
219 | minpoly = a4+1; |
---|
220 | map phi = R,1,v-a,u; |
---|
221 | poly f = phi(f); |
---|
222 | def L3 = hnexpansion(f); |
---|
223 | displayInvariants(L3); |
---|
224 | |
---|
225 | |
---|
226 | kill R,R_loc1,R_loc2,R_loc3,HNE_ring1,HNE_ring2,L1,L2,i,INV; |
---|
227 | //====================== Exercise 5.4 ============================= |
---|
228 | ring R = 0, (x,y,z), dp; |
---|
229 | poly f = 3y3-3xy2-2xy3+x2y3+x3; |
---|
230 | poly C = homog(f,z); |
---|
231 | ideal I = jacob(C); |
---|
232 | I = std(I); |
---|
233 | if(not(defined(primdecGTZ))){ LIB "primdec.lib"; } |
---|
234 | list SLoc = primdecGTZ(I); |
---|
235 | SLoc; |
---|
236 | factorize(jet(f,3)); |
---|
237 | //-> [1]: |
---|
238 | //-> _[1]=1 |
---|
239 | //-> _[2]=x3-3xy2+3y3 |
---|
240 | //-> [2]: |
---|
241 | //-> 1,1 |
---|
242 | |
---|
243 | ideal Adj_S = 1; |
---|
244 | for (int k=1; k<=3; k++) |
---|
245 | { |
---|
246 | Adj_S = intersect(Adj_S,SLoc[k][2]); |
---|
247 | } |
---|
248 | Adj_S = intersect(Adj_S,SLoc[k][2]^2); |
---|
249 | ideal Adj_LS_3 = jet(std(Adj_S),3); |
---|
250 | Adj_LS_3 = simplify(Adj_LS_3,6); Adj_LS_3; |
---|
251 | |
---|
252 | if (not(defined(randomid))){ LIB "random.lib"; } |
---|
253 | def f(1),f(2) = randomid(Adj_LS_3,2,10); |
---|
254 | ideal I(1) = f(1),C; |
---|
255 | ideal I(2) = f(2),C; |
---|
256 | ideal B(1) = sat(I(1),I)[1]; |
---|
257 | ideal B(2) = sat(I(2),I)[1]; |
---|
258 | |
---|
259 | Adj_S = intersect(Adj_S,B(1),B(2)); |
---|
260 | option(redSB); |
---|
261 | ideal L' = jet(std(Adj_S),4); |
---|
262 | L' = simplify(L',6); |
---|
263 | poly f' = randomid(L',1,10)[1]; |
---|
264 | ideal I' = f',C; |
---|
265 | ideal B(3) = sat(I',L')[1]; |
---|
266 | |
---|
267 | ideal L'' = jet(std(intersect(Adj_LS_3,B(3))),3); |
---|
268 | L'' = simplify(L'',6); L''; |
---|
269 | poly f''(1),f''(2) = L''[1..2]; |
---|
270 | |
---|
271 | ring R_t = (0,t), (x,y,z), dp; |
---|
272 | poly f'' = imap(R,f''(1)) + t*imap(R,f''(2)); |
---|
273 | ideal I_t = f'', imap(R,C); |
---|
274 | I_t = std(I_t); |
---|
275 | ideal L'' = imap(R,L''); |
---|
276 | I_t = sat(I_t,L'')[1]; |
---|
277 | I_t = std(subst(I_t,z,1)); |
---|
278 | def phi_x = reduce(x,I_t); phi_x; |
---|
279 | def phi_y = reduce(y,I_t); phi_y; |
---|
280 | |
---|
281 | map testmap = R, phi_x, phi_y, 1; |
---|
282 | testmap(C); |
---|
283 | //-> 0 |
---|
284 | ring S = 0, (t,x,y), dp; |
---|
285 | ideal I_t = imap(R_t,I_t); |
---|
286 | eliminate(I_t,t); |
---|
287 | //-> _[1]=x2y3-2xy3+x3-3xy2+3y3 |
---|
288 | |
---|
289 | tst_status(1);$ |
---|
290 | |
---|