1 | LIB "tst.lib"; |
---|
2 | tst_init(); |
---|
3 | |
---|
4 | |
---|
5 | //====================== Exercise 3.1 ============================= |
---|
6 | proc is_reg_sequence (ideal I) |
---|
7 | "USAGE: is_reg_sequence(I); I ideal, |
---|
8 | RETURN: 1 if the given (ordered) list of generators for I is a |
---|
9 | regular sequence; |
---|
10 | 0 otherwise. |
---|
11 | " |
---|
12 | { |
---|
13 | int i; |
---|
14 | ideal J; |
---|
15 | while(i<size(I)) |
---|
16 | { |
---|
17 | i++; |
---|
18 | if (size(reduce(quotient(J,I[i]),J))!=0) |
---|
19 | { |
---|
20 | return(0); |
---|
21 | } |
---|
22 | J = groebner(J+I[i]); |
---|
23 | } |
---|
24 | if (size(reduce(1,J))==0) { return(0); } |
---|
25 | return(1); |
---|
26 | } |
---|
27 | |
---|
28 | ring R = 0, (x,y,z), dp; |
---|
29 | ideal I = (x-1)*z, (x-1)*y, x; |
---|
30 | is_reg_sequence (I); |
---|
31 | //-> 0 |
---|
32 | I = (x-1)*z, x, (x-1)*y; |
---|
33 | is_reg_sequence (I); |
---|
34 | //-> 1 |
---|
35 | |
---|
36 | |
---|
37 | kill R; |
---|
38 | //====================== Exercise 3.2 ============================= |
---|
39 | if (not(defined(isCM))){ LIB "homolog.lib"; } |
---|
40 | ring R1 = 0, (x,y,z), dp; |
---|
41 | ideal I = xy, yz, xz; |
---|
42 | ring R1_loc = 0, (x,y,z), ds; |
---|
43 | ideal I = imap(R1,I); // ideal generated by I in localized ring |
---|
44 | isCM(I); |
---|
45 | |
---|
46 | ring R2 = 0, (s,t,x,y,z,w), dp; |
---|
47 | ideal I = x-s4, y-s3t, z-st3, w-t4; |
---|
48 | ideal IC = eliminate(I,st); |
---|
49 | ring R2_loc = 0, (x,y,z,w), ds; |
---|
50 | ideal IC = imap(R2,IC); |
---|
51 | isCM(IC); |
---|
52 | |
---|
53 | |
---|
54 | kill R1,R1_loc,R2,R2_loc; |
---|
55 | //====================== Exercise 3.3 ============================= |
---|
56 | proc truncate(module phi, int d) |
---|
57 | "USAGE: truncate(phi,d); phi module, d int |
---|
58 | ASSUME: phi comes assigned with an admissible degree vector as an |
---|
59 | attribute |
---|
60 | RETURN: module |
---|
61 | NOTE: Output is a presentation matrix for the truncation of |
---|
62 | coker(phi) at d. |
---|
63 | " |
---|
64 | { |
---|
65 | if ( typeof(attrib(phi,"isHomog"))=="string" ) |
---|
66 | { |
---|
67 | ERROR("No admissible degree vector assigned"); |
---|
68 | } |
---|
69 | else |
---|
70 | { |
---|
71 | intvec v=attrib(phi,"isHomog"); |
---|
72 | } |
---|
73 | int s = nrows(phi); |
---|
74 | int i,m,dummy; |
---|
75 | module L; |
---|
76 | for (i=1; i<=s; i++) |
---|
77 | { |
---|
78 | if (d>v[i]) |
---|
79 | { |
---|
80 | L = L+maxideal(d-v[i])*gen(i); |
---|
81 | } |
---|
82 | else |
---|
83 | { |
---|
84 | L = L+gen(i); |
---|
85 | } |
---|
86 | } |
---|
87 | L = modulo(L,phi); |
---|
88 | L = prune(L); |
---|
89 | if (size(L)==0) {return(L);} |
---|
90 | |
---|
91 | // it only remains to set the degrees for L: |
---|
92 | // ------------------------------------------ |
---|
93 | m = v[1]; |
---|
94 | for(i=2; i<=size(v); i++) |
---|
95 | { |
---|
96 | if(v[i]<m) |
---|
97 | { |
---|
98 | m = v[i]; |
---|
99 | } |
---|
100 | } |
---|
101 | dummy = homog(L); |
---|
102 | intvec vv = attrib(L,"isHomog"); |
---|
103 | if (d>m) |
---|
104 | { |
---|
105 | vv = vv+d-m; |
---|
106 | } |
---|
107 | attrib(L,"isHomog",vv); |
---|
108 | return(L); |
---|
109 | } |
---|
110 | |
---|
111 | proc CM_regularity (module phi) |
---|
112 | "USAGE: CM_regularity(phi); phi module |
---|
113 | ASSUME: phi comes assigned with an admissible degree vector as an |
---|
114 | attribute |
---|
115 | RETURN: integer |
---|
116 | NOTE: Output is the Castelnuovo-Mumford regularity of coker(phi). |
---|
117 | " |
---|
118 | { |
---|
119 | if ( typeof(attrib(phi,"isHomog"))=="string" ) |
---|
120 | { |
---|
121 | ERROR("No admissible degree vector assigned"); |
---|
122 | } |
---|
123 | def L = mres(phi,0); |
---|
124 | intmat BeL = betti(L); |
---|
125 | int r = nrows(module(matrix(BeL))); |
---|
126 | int shift = attrib(BeL,"rowShift"); // See Section 3.4 |
---|
127 | return(r+shift-1); |
---|
128 | } |
---|
129 | |
---|
130 | ring R = 0, (w,x,y,z), dp; |
---|
131 | module I = [xz,0,-w,-1,0], [-yz2,y2, 0,-w,0], [y2z,0,-z2,0,-x], |
---|
132 | [y3,0,-yz,-x,0], [-z3,yz,0,0,-w], [-yz2,y2,0,-w,0], |
---|
133 | [0,0,-wy2+xz2,-y2,x2]; |
---|
134 | homog(I); |
---|
135 | CM_regularity(I); |
---|
136 | //-> 3 |
---|
137 | def T2 = mres(truncate(I,2),0); |
---|
138 | print (betti(T2),"betti"); |
---|
139 | //-> 0 1 2 3 |
---|
140 | //-> ------------------------------ |
---|
141 | //-> 2: 19 36 23 6 |
---|
142 | //-> 3: - - 1 - |
---|
143 | //-> ------------------------------ |
---|
144 | //-> total: 19 36 24 6 |
---|
145 | |
---|
146 | def T3 = mres(truncate(I,3),0); |
---|
147 | print (betti(T3),"betti"); |
---|
148 | //-> 0 1 2 3 |
---|
149 | //-> ------------------------------ |
---|
150 | //-> 3: 40 91 71 19 |
---|
151 | //-> ------------------------------ |
---|
152 | //-> total: 40 91 71 19 |
---|
153 | |
---|
154 | |
---|
155 | kill R; |
---|
156 | //====================== Exercise 3.4 ============================= |
---|
157 | //===== Procedures are stored in the library file sol_3_4.lib ====== |
---|
158 | //================================================================== |
---|
159 | LIB "sol_3_4.lib"; |
---|
160 | example ker_Mod; |
---|
161 | example Ext_Mod; |
---|
162 | |
---|
163 | |
---|
164 | //====================== Exercise 3.5 ============================= |
---|
165 | ring S = 32003, x(0..4), dp; |
---|
166 | resolution kos = nres(maxideal(1),0); |
---|
167 | print(betti(kos),"betti"); |
---|
168 | matrix alpha0 = random(32002,10,5); |
---|
169 | matrix pres = module(alpha0)+kos[4]; |
---|
170 | matrix dir = transpose(pres); |
---|
171 | resolution fdir = mres(dir,2); |
---|
172 | print(betti(fdir),"betti"); |
---|
173 | if (not(defined(flatten))) { LIB "matrix.lib"; } |
---|
174 | ideal I = flatten(fdir[2]); |
---|
175 | resolution FI = mres(I,0); |
---|
176 | print(betti(FI),"betti"); |
---|
177 | |
---|
178 | ring S1 = 32003, x(0..4), dp; |
---|
179 | resolution kos = nres(maxideal(1),0); |
---|
180 | betti(kos); |
---|
181 | matrix gammatilde = random(32002,20,19); |
---|
182 | matrix kos1 = matrix(kos[1]); |
---|
183 | matrix kos2 = kos[2]; |
---|
184 | if (not(defined(dsum))){ LIB"matrix.lib"; } |
---|
185 | matrix kos2pluskos1pluskos1 = dsum(kos2,kos1,kos1); |
---|
186 | module delta = kos2pluskos1pluskos1*gammatilde; |
---|
187 | attrib(delta,"isHomog",intvec(-1,-1,-1,-1,-1,-1,-1)); |
---|
188 | resolution fdelta = mres(delta,0); |
---|
189 | print(betti(fdelta),"betti"); |
---|
190 | //-> 0 1 2 3 4 5 |
---|
191 | //-> ------------------------------------------ |
---|
192 | //-> -1: 7 19 25 15 3 - |
---|
193 | //-> 0: - - - 2 3 1 |
---|
194 | //-> ------------------------------------------ |
---|
195 | //-> total: 7 19 25 17 6 1 |
---|
196 | |
---|
197 | matrix psi = matrix(fdelta[3]); |
---|
198 | matrix talpha1 = random(32002,3,15); |
---|
199 | matrix zero[3][2]; |
---|
200 | talpha1 = concat(talpha1,zero); |
---|
201 | matrix kos5 = kos[5]; |
---|
202 | matrix tphi = transpose(dsum(kos5,kos5,kos5)); |
---|
203 | matrix talpha1tilde = talpha1*transpose(psi); |
---|
204 | matrix talpha0 = lift(tphi,talpha1tilde); |
---|
205 | |
---|
206 | matrix dir = transpose(concat(psi,transpose(talpha0))); |
---|
207 | resolution fdir = mres(dir,2); |
---|
208 | print(betti(fdir),"betti"); |
---|
209 | ideal I = groebner(flatten(fdir[2])); |
---|
210 | resolution FI = mres(I,0); |
---|
211 | print(betti(FI),"betti"); |
---|
212 | // ---------- Check Smoothness ------------ |
---|
213 | int codimI = nvars(S1)-dim(I); |
---|
214 | nvars(S1) - dim(groebner(minor(jacob(I),codimI) + I)); |
---|
215 | //-> 5 |
---|
216 | // ---------------------------------------- |
---|
217 | |
---|
218 | tst_status(1);$ |
---|
219 | |
---|