1 | LIB "tst.lib"; |
---|
2 | tst_init(); |
---|
3 | |
---|
4 | LIB"primdec.lib"; |
---|
5 | |
---|
6 | proc tensorMaps(matrix M, matrix N) |
---|
7 | { |
---|
8 | int r=ncols(M); |
---|
9 | int s=nrows(M); |
---|
10 | int p=ncols(N); |
---|
11 | int q=nrows(N); |
---|
12 | int a,b,c,d; |
---|
13 | matrix R[s*q][r*p]; |
---|
14 | for(b=1;b<=p;b++) |
---|
15 | { |
---|
16 | for(d=1;d<=q;d++) |
---|
17 | { |
---|
18 | for(a=1;a<=r;a++) |
---|
19 | { |
---|
20 | for(c=1;c<=s;c++) |
---|
21 | { |
---|
22 | R[(c-1)*q+d,(a-1)*p+b]=M[c,a]*N[d,b]; |
---|
23 | } |
---|
24 | } |
---|
25 | } |
---|
26 | } |
---|
27 | return(R); |
---|
28 | } |
---|
29 | |
---|
30 | proc binom (int n, int k) |
---|
31 | { |
---|
32 | int l; |
---|
33 | int r=1; |
---|
34 | if ( k > n-k ) |
---|
35 | { k = n-k; |
---|
36 | } |
---|
37 | if ( k<=0 or k>n ) //trivial cases |
---|
38 | { r = (k==0)*r; |
---|
39 | } |
---|
40 | for (l=1; l<=k; l++ ) |
---|
41 | { |
---|
42 | r=r*(n+1-l)/l; |
---|
43 | } |
---|
44 | return(r); |
---|
45 | } |
---|
46 | proc basisNumber(int n,intvec v) |
---|
47 | { |
---|
48 | int p=size(v); |
---|
49 | if(p==1){return(v[1]);} |
---|
50 | int j=n-1; |
---|
51 | int b; |
---|
52 | while(j>=n-v[1]+1) |
---|
53 | { |
---|
54 | b=b+binom(j,p-1); |
---|
55 | j--; |
---|
56 | } |
---|
57 | intvec w=v-v[1]; |
---|
58 | w=w[2..size(w)]; |
---|
59 | b=b+basisNumber(n-v[1],w); |
---|
60 | return(b); |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | proc basisElement(int n,int p,int N) |
---|
65 | { |
---|
66 | if(p==1){return(N);} |
---|
67 | int s,R; |
---|
68 | while(R<N) |
---|
69 | { |
---|
70 | s++; |
---|
71 | R=R+binom(n-s,p-1); |
---|
72 | } |
---|
73 | R=N-R+binom(n-s,p-1); |
---|
74 | intvec v=basisElement(n-s,p-1,R); |
---|
75 | intvec w=s,v+s; |
---|
76 | return(w); |
---|
77 | } |
---|
78 | |
---|
79 | proc KoszulMap(ideal x,int p) |
---|
80 | { |
---|
81 | int n=size(x); |
---|
82 | int a=binom(n,p-1); |
---|
83 | int b=binom(n,p); |
---|
84 | matrix M[a][b]; |
---|
85 | if(p==1){M=x;return(M);} |
---|
86 | int j,k; |
---|
87 | intvec v,w; |
---|
88 | for(j=1;j<=b;j++) |
---|
89 | { |
---|
90 | v=basisElement(n,p,j); |
---|
91 | w=v[2..p]; |
---|
92 | M[basisNumber(n,w),j]=x[v[1]]; |
---|
93 | for(k=2;k<p;k++) |
---|
94 | { |
---|
95 | w=v[1..k-1],v[k+1..p]; |
---|
96 | M[basisNumber(n,w),j]=(-1)^(k-1)*x[v[k]]; |
---|
97 | } |
---|
98 | w=v[1..p-1]; |
---|
99 | M[basisNumber(n,w),j]=(-1)^(p-1)*x[v[p]]; |
---|
100 | } |
---|
101 | return(M); |
---|
102 | } |
---|
103 | |
---|
104 | proc KoszulHomology(ideal x, module M, int p) |
---|
105 | { |
---|
106 | int n = size(x); |
---|
107 | int a = binom(n,p-1); |
---|
108 | int b = binom(n,p); |
---|
109 | matrix N = matrix(M); |
---|
110 | module ker = freemodule(nrows(N)); |
---|
111 | if(p!=0) |
---|
112 | { |
---|
113 | module im = tensorMaps(unitmat(a),N); |
---|
114 | module f = tensorMaps(KoszulMap(x,p),unitmat(nrows(N))); |
---|
115 | ker = modulo(f,im); |
---|
116 | } |
---|
117 | module im1 = tensorMaps(unitmat(b),N); |
---|
118 | module im2 = tensorMaps(KoszulMap(x,p+1),unitmat(nrows(N))); |
---|
119 | module hom = modulo(ker,im1+im2); |
---|
120 | hom = prune(hom); |
---|
121 | return(hom); |
---|
122 | } |
---|
123 | |
---|
124 | proc depth(module M) |
---|
125 | { |
---|
126 | ideal m=maxideal(1); |
---|
127 | int n=size(m); |
---|
128 | int i; |
---|
129 | while(i<n) |
---|
130 | { |
---|
131 | i++; |
---|
132 | if(size(KoszulHomology(m,M,i))==0){return(n-i+1);} |
---|
133 | } |
---|
134 | return(0); |
---|
135 | } |
---|
136 | |
---|
137 | proc CohenMacaulayTest(module M) |
---|
138 | { |
---|
139 | return(depth(M)==dim(std(Ann(M)))); |
---|
140 | } |
---|
141 | |
---|
142 | |
---|
143 | ring R=0,(x,y,z),ds; |
---|
144 | ideal I=xz,yz; |
---|
145 | module M=I*freemodule(1); |
---|
146 | CohenMacaulayTest(M); |
---|
147 | |
---|
148 | I=x2+y2,z7; |
---|
149 | M=I*freemodule(1); |
---|
150 | CohenMacaulayTest(M); |
---|
151 | |
---|
152 | tst_status(1);$ |
---|