version 1.3, 2020/01/22 08:30:40 |
version 1.8, 2020/02/11 01:43:56 |
|
|
module newsyz; |
module newsyz; |
|
|
localf module_syz; |
localf module_syz, module_syz_old; |
localf simplify_syz, icont, mod, remove_cont,ordcheck; |
localf simplify_syz, icont, mod, remove_cont,ordcheck; |
localf complsb, complsb_sd, sortlsb, find_pos, find_pos, reduce, lres_setup, dpm_sort1, comp_pos; |
localf complsb, complsb_sd, sortlsb, find_pos, find_pos, reduce, lres_setup, dpm_sort1, comp_pos; |
localf fres,minres,sres,minsres,lres, create_base_ord, simplify_k, simplify_by_k, remove_k, remove_k1, extract_nonzero; |
localf fres,minres,sres,minsres,lres, create_base_ord, simplify_k, simplify_by_k, remove_k, remove_k1, extract_nonzero; |
localf nonzero, phi, syz_check, renumber_pos, compress, compress_h; |
localf nonzero, phi, syz_check, renumber_pos, compress, compress_h; |
localf syz_check0,phi0,todpmlist,dpmlisttollist; |
localf syz_check0,phi0,todpmlist,dpmlisttollist,comp_lex; |
|
|
/* F : a list of (lists or polynomials), |
/* F : a list of (lists or polynomials), |
V : a variable list, H >1=> over GF(H), H=0,1=> over Q |
V : a variable list, H >1=> over GF(H), H=0,1=> over Q |
Line 64 def module_syz(F,V,H,Ord) |
|
Line 64 def module_syz(F,V,H,Ord) |
|
B = cons(F[I]+dpm_dptodpm(dp_ptod(1,V),N+I+1),B); |
B = cons(F[I]+dpm_dptodpm(dp_ptod(1,V),N+I+1),B); |
} |
} |
B = reverse(B); |
B = reverse(B); |
if ( Weyl ) |
if ( H >= 2 ) { |
G = nd_weyl_gr(B,V,0,[1,Ord]|dp=1,homo=H); |
// finite field |
else if ( F4 ) { |
if ( Weyl ) |
// G = nd_f4(B,V,0,[1,Ord]|dp=1,homo=H,nora=1); |
G = nd_weyl_gr(B,V,H,[1,Ord]|dp=1); |
Ind = 0; |
else if ( F4 ) |
while ( 1 ) { |
G = nd_f4(B,V,H,[1,Ord]|dp=1); |
G = nd_f4_trace(B,V,H,-lprime(Ind),[1,Ord]|dp=1); |
else |
if ( G ) break; |
G = nd_gr(B,V,H,[1,Ord]|dp=1); |
else Ind++; |
} else { |
|
if ( Weyl ) |
|
G = nd_weyl_gr(B,V,0,[1,Ord]|dp=1,homo=H); |
|
else { |
|
Ind = 0; |
|
while ( 1 ) { |
|
if ( F4 ) |
|
G = nd_f4_trace(B,V,H,-lprime(Ind),[1,Ord]|dp=1); |
|
else |
|
G = nd_gr_trace(B,V,H,-lprime(Ind),[1,Ord]|dp=1); |
|
if ( G ) break; |
|
else Ind++; |
|
} |
} |
} |
} else |
} |
G = nd_gr(B,V,0,[1,Ord]|dp=1,homo=H); |
|
G0 = []; S0 = []; Gen0 = []; |
G0 = []; S0 = []; Gen0 = []; |
for ( T = G; T != []; T = cdr(T) ) { |
for ( T = G; T != []; T = cdr(T) ) { |
H = car(T); |
H = car(T); |
Line 96 def module_syz(F,V,H,Ord) |
|
Line 107 def module_syz(F,V,H,Ord) |
|
return [S0,G0,Gen0]; |
return [S0,G0,Gen0]; |
} |
} |
|
|
|
def module_syz_old(F,V,H,O) |
|
{ |
|
Weyl = type(getopt(weyl)) != -1 ? 1 : 0; |
|
K = length(F); |
|
if ( type(F[0]) <= 2 ) { |
|
for ( T = [], S = F; S != []; S = cdr(S) ) |
|
T = cons([car(S)],T); |
|
F = reverse(T); |
|
} |
|
N = length(F[0]); |
|
B = []; |
|
for ( I = 0; I < K; I++ ) { |
|
E = vector(N+K); |
|
for ( J = 0; J < N; J++ ) E[J] = F[I][J]; |
|
E[N+I] = 1; |
|
B = cons(vtol(E),B); |
|
} |
|
B = reverse(B); |
|
if ( H >= 2 ) { |
|
if ( Weyl ) |
|
G = nd_weyl_gr(B,V,H,[1,O]); |
|
else |
|
G = nd_gr(B,V,H,[1,O]); |
|
} else { |
|
if ( Weyl ) |
|
G = nd_weyl_gr_trace(B,V,H,-1,[1,O]); |
|
else |
|
G = nd_gr_trace(B,V,H,-1,[1,O]); |
|
} |
|
G0 = []; S0 = []; Gen0 = []; |
|
for ( T = G; T != []; T = cdr(T) ) { |
|
H = car(T); |
|
for ( J = 0; J < N; J++ ) if ( H[J] ) break; |
|
if ( J == N ) { |
|
H1 = vector(K); |
|
for ( J = 0; J < K; J++ ) H1[J] = H[N+J]; |
|
S0 = cons(vtol(H1),S0); |
|
} else { |
|
H1 = vector(N); |
|
for ( J = 0; J < N; J++ ) H1[J] = H[J]; |
|
G0 = cons(vtol(H1),G0); |
|
H1 = vector(K); |
|
for ( J = 0; J < K; J++ ) H1[J] = H[N+J]; |
|
Gen0 = cons(vtol(H1),Gen0); |
|
} |
|
} |
|
return [S0,G0,Gen0]; |
|
} |
|
|
def fres(F,V,H,O) |
def fres(F,V,H,O) |
{ |
{ |
if ( type(Weyl=getopt(weyl)) == -1 ) Weyl = 0; |
if ( type(Weyl=getopt(weyl)) == -1 ) Weyl = 0; |
Line 111 def fres(F,V,H,O) |
|
Line 171 def fres(F,V,H,O) |
|
L = L[0]; |
L = L[0]; |
L = ordcheck(L,V); |
L = ordcheck(L,V); |
if ( L == [] ) { |
if ( L == [] ) { |
|
R = reverse(R); |
if ( DP ) return R; |
if ( DP ) return R; |
else return map(dpmlisttollist,R,V); |
else return map(dpmlisttollist,R,V); |
} |
} |
Line 142 def minres(F,V,H,O) |
|
Line 203 def minres(F,V,H,O) |
|
R = cdr(R); break; |
R = cdr(R); break; |
} |
} |
} |
} |
|
R = reverse(R); |
if ( DP ) return R; |
if ( DP ) return R; |
else return map(dpmlisttollist,R,V); |
else return map(dpmlisttollist,R,V); |
} |
} |
Line 162 def sres(F,V,H,Ord) |
|
Line 224 def sres(F,V,H,Ord) |
|
if ( I == K ) return [[],[],[]]; |
if ( I == K ) return [[],[],[]]; |
L = todpmlist(F,V); |
L = todpmlist(F,V); |
F = L[0]; N = L[1]; |
F = L[0]; N = L[1]; |
|
#if 0 |
G = nd_gr(F,V,H,[0,Ord]|dp=1); |
G = nd_gr(F,V,H,[0,Ord]|dp=1); |
|
#else |
|
G = nd_gr_trace(F,V,H,1,[0,Ord]|dp=1); |
|
#endif |
G = reverse(G); |
G = reverse(G); |
R = [G]; |
R = [G]; |
dp_ord([0,Ord]); |
dp_ord([0,Ord]); |
while ( 1 ) { |
while ( 1 ) { |
S = dpm_schreyer_base(R[0]); |
S = dpm_schreyer_base(R[0]); |
print(["length",length(S)]); |
if ( dp_gr_print() ) print(["length",length(S)]); |
if ( S == [] ) break; |
if ( S == [] ) break; |
else R = cons(S,R); |
else R = cons(S,R); |
} |
} |
dp_ord([0,0]); |
dp_ord([0,0]); |
|
R = reverse(R); |
if ( DP ) return R; |
if ( DP ) return R; |
else return map(dpmlisttollist,R,V); |
else return map(dpmlisttollist,R,V); |
} |
} |
Line 181 def minsres(F,V,H,Ord) |
|
Line 248 def minsres(F,V,H,Ord) |
|
{ |
{ |
if ( type(DP=getopt(dp)) == -1 ) DP = 0; |
if ( type(DP=getopt(dp)) == -1 ) DP = 0; |
R = sres(F,V,H,Ord|dp=1); |
R = sres(F,V,H,Ord|dp=1); |
R = ltov(R); |
R = ltov(reverse(R)); |
M = length(R); |
M = length(R); |
for ( I = 0; I < M; I++ ) R[I] = map(dpm_sort,R[I]); |
for ( I = 0; I < M; I++ ) R[I] = map(dpm_sort,R[I]); |
R = vtol(R); |
R = vtol(R); |
Line 331 def reduce(D,B,Bpos,C,H,Z,K,Kind,G,One,Top) |
|
Line 398 def reduce(D,B,Bpos,C,H,Z,K,Kind,G,One,Top) |
|
} |
} |
} |
} |
|
|
|
def comp_lex(A,B) |
|
{ |
|
HA = dpm_hc(A); HB = dpm_hc(B); |
|
if ( HA > HB ) return 1; |
|
else if ( HA < HB ) return -1; |
|
else return 0; |
|
} |
|
|
def lres_setup(F,V,H,Ord) |
def lres_setup(F,V,H,Ord) |
{ |
{ |
|
if ( type(Lex=getopt(lex)) == -1 ) Lex = 0; |
dpm_set_schreyer(0); |
dpm_set_schreyer(0); |
dp_ord(Ord); |
dp_ord(Ord); |
K = length(F); |
K = length(F); |
Line 360 def lres_setup(F,V,H,Ord) |
|
Line 436 def lres_setup(F,V,H,Ord) |
|
} else { |
} else { |
error("lres_setup: arugument type is invalid."); |
error("lres_setup: arugument type is invalid."); |
} |
} |
|
dp_ord([0,Ord]); |
|
F = map(dpm_sort,F); |
|
#if 0 |
G = nd_gr(F,V,H,[0,Ord]|dp=1); |
G = nd_gr(F,V,H,[0,Ord]|dp=1); |
|
#else |
|
G = nd_gr_trace(F,V,H,1,[0,Ord]|dp=1); |
|
#endif |
|
if ( Lex ) { |
|
dp_ord(2); |
|
G = qsort(G,newsyz.comp_lex); |
|
} |
G = reverse(G); |
G = reverse(G); |
dp_ord([0,Ord]); |
dp_ord([0,Ord]); |
One = dp_ptod(1,V); |
One = dp_ptod(1,V); |
Line 384 def lres(F,V,H,Ord) |
|
Line 470 def lres(F,V,H,Ord) |
|
{ |
{ |
T0 = time(); |
T0 = time(); |
if ( type(Top=getopt(top)) == -1 ) Top = 0; |
if ( type(Top=getopt(top)) == -1 ) Top = 0; |
|
if ( type(DP=getopt(dp)) == -1 ) DP = 0; |
if ( type(NoSimpK=getopt(nosimpk)) == -1 ) NoSimpK = 0; |
if ( type(NoSimpK=getopt(nosimpk)) == -1 ) NoSimpK = 0; |
if ( type(NoPreProj=getopt(nopreproj)) == -1 ) NoPreProj = 0; |
if ( type(NoPreProj=getopt(nopreproj)) == -1 ) NoPreProj = 0; |
|
if ( type(Lex=getopt(lex)) == -1 ) Lex = 0; |
Rtime = Stime = Ptime = 0; |
Rtime = Stime = Ptime = 0; |
L = lres_setup(F,V,H,Ord); |
L = lres_setup(F,V,H,Ord); |
G = L[0]; |
G = L[0]; |
One = L[1]; |
One = L[1]; |
F = dpm_schreyer_frame(G); |
F = dpm_schreyer_frame(G|lex=Lex); |
G = ltov(cons(0,L[0])); |
G = ltov(cons(0,L[0])); |
F = reverse(F); |
F = reverse(F); |
F = ltov(F); |
F = ltov(F); |
Line 430 def lres(F,V,H,Ord) |
|
Line 518 def lres(F,V,H,Ord) |
|
} |
} |
T1 = time(); Ftime = T1[0]-T0[0]; |
T1 = time(); Ftime = T1[0]-T0[0]; |
R = ltov(R); Len = length(R); |
R = ltov(R); Len = length(R); |
print(["Len",Len]); |
if ( dp_gr_print() ) print(["Len",Len]); |
for ( I = 0, NF = 0; I < Len; I++ ) { |
for ( I = 0, NF = 0; I < Len; I++ ) { |
if ( !((I+1)%100) ) print(".",2); |
if ( dp_gr_print() ) { |
if ( !((I+1)%10000) ) print(I+1); |
if ( !((I+1)%100) ) print(".",2); |
|
if ( !((I+1)%10000) ) print(I+1); |
|
} |
if ( !R[I][3] ) continue; |
if ( !R[I][3] ) continue; |
NF++; |
NF++; |
reduce(R[I],B,Bpos,C,H,Z,K,Kind,G,One,Top); |
reduce(R[I],B,Bpos,C,H,Z,K,Kind,G,One,Top); |
} |
} |
print(""); |
if ( dp_gr_print() ) { |
print(["NF",NF]); |
print(""); |
|
print(["NF",NF]); |
|
} |
T0 = time(); |
T0 = time(); |
dpm_set_schreyer_level(0); |
dpm_set_schreyer_level(0); |
D[1] = map(dpm_sort,H[1]); |
D[1] = map(dpm_sort,H[1]); |
Line 453 def lres(F,V,H,Ord) |
|
Line 545 def lres(F,V,H,Ord) |
|
Tab = map(dpm_sort,Tab); |
Tab = map(dpm_sort,Tab); |
TailTop = dpm_dptodpm(One,TailTopPos); |
TailTop = dpm_dptodpm(One,TailTopPos); |
if ( !NoSimpK ) { |
if ( !NoSimpK ) { |
print("simplify_k "+rtostr(I)+"...",2); |
if ( dp_gr_print() ) print("simplify_k "+rtostr(I)+"...",2); |
simplify_k(Head,Tab,TailTop,One); |
simplify_k(Head,Tab,TailTop,One); |
print("done"); |
if ( dp_gr_print() ) print("done"); |
} |
} |
HI = map(remove_k,map(dpm_sort,H[I]),Kind[I-1]); |
HI = map(remove_k,map(dpm_sort,H[I]),Kind[I-1]); |
Len = length(HI); |
Len = length(HI); |
print("simplify_by_k "+rtostr(I)+"...",2); |
if ( dp_gr_print() ) print("simplify_by_k "+rtostr(I)+"...",2); |
D[I] = vector(Len); |
D[I] = vector(Len); |
for ( J = 0; J < Len; J++ ) { |
for ( J = 0; J < Len; J++ ) { |
D[I][J] = simplify_by_k(HI[J],Tab,TailTop,One); |
D[I][J] = simplify_by_k(HI[J],Tab,TailTop,One); |
if ( NoPreProj ) |
if ( NoPreProj ) |
D[I][J] = remove_k(D[I][J],Kind[I-1]); |
D[I][J] = remove_k(D[I][J],Kind[I-1]); |
} |
} |
print("done"); |
if ( dp_gr_print() ) print("done"); |
} |
} |
dp_ord([1,0]); |
dp_ord([1,0]); |
T1 = time(); |
T1 = time(); |
print(["Frame",Ftime,"Prep",Ptime,"Reduce",Rtime,"Search",Stime,"Minimalize",T1[0]-T0[0]]); |
if ( dp_gr_print() ) print(["Frame",Ftime,"Prep",Ptime,"Reduce",Rtime,"Search",Stime,"Minimalize",T1[0]-T0[0]]); |
// return [C,H,K,Kind,D]; |
// return [C,H,K,Kind,D]; |
D = compress_h(D); |
D = compress_h(D); |
return D; |
if ( DP ) return D; |
|
else return vtol(map(dpmlisttollist,D,V)); |
} |
} |
|
|
def create_base_ord(K,N) |
def create_base_ord(K,N) |
|
|
R = 0; |
R = 0; |
for ( T = F; T; T = dpm_rest(T) ) { |
for ( T = F; T; T = dpm_rest(T) ) { |
Coef = dpm_hc(T); Pos = dpm_hp(T); |
Coef = dpm_hc(T); Pos = dpm_hp(T); |
R += Coef*C[Pos]; |
R += Coef*C[Pos-1]; |
} |
} |
return R; |
return R; |
} |
} |