=================================================================== RCS file: /home/cvs/OpenXM/src/asir-contrib/testing/noro/Attic/new_pd.rr,v retrieving revision 1.2 retrieving revision 1.9 diff -u -p -r1.2 -r1.9 --- OpenXM/src/asir-contrib/testing/noro/Attic/new_pd.rr 2011/01/19 00:51:38 1.2 +++ OpenXM/src/asir-contrib/testing/noro/Attic/new_pd.rr 2014/09/05 11:55:19 1.9 @@ -1,23 +1,25 @@ -/* $OpenXM$ */ +/* $OpenXM: OpenXM/src/asir-contrib/testing/noro/new_pd.rr,v 1.8 2011/11/01 00:35:56 noro Exp $ */ import("gr")$ module noro_pd$ -static GBCheck,F4,EProcs,Procs,SatHomo,GBRat$ +static GBCheck,F4,EProcs,Procs,SatHomo,GBRat,SuccSat,RepColon$ -localf get_lc,tomonic$ -localf para_exec,nd_gr_rat,competitive_exec,call_func$ +localf radical_membership_sat$ +localf witness$ +localf get_lc,tomonic,aa,ideal_intersection_m,redbase$ +localf para_exec,nd_gr_rat,competitive_exec,call_func,call_func_serial$ localf call_ideal_list_intersection$ +localf call_colon,call_prime_dec$ +localf prime_dec2, prime_dec_main2$ localf first_second$ localf third$ localf locsat,iso_comp_para,extract_qj,colon_prime_dec,extract_comp$ -localf colon_prime_dec1$ localf separator$ -localf member,mingen,compute_gbsyz,redcoef,recompute_trace3,dtop,topnum$ -localf ideal_colon1$ +localf member,mingen,compute_gbsyz,redcoef,recompute_trace,dtop,topnum$ localf prepost$ localf monodec0,monodec,prod$ localf extract_qd,primary_check$ localf second$ -localf gbrat,comp_third_tdeg,comp_tord$ +localf gbrat,succsat,repcolon,comp_third_tdeg,comp_tord$ localf power$ localf syci_dec, syc_dec$ @@ -35,12 +37,12 @@ localf complete_qdecomp, partial_qdecomp, partial_qdec localf partial_decomp, partial_decomp0, zprimacomp, zprimecomp$ localf fast_gb, incremental_gb, elim_gb, ldim, make_mod_subst$ localf rsgn, find_npos, gen_minipoly, indepset$ -localf maxindep, contraction, ideal_list_intersection, ideal_intersection$ +localf maxindep, maxindep2, contraction, contraction_m, ideal_list_intersection, ideal_intersection$ localf radical_membership, modular_radical_membership$ localf radical_membership_rep, ideal_product, saturation$ -localf sat, satind, sat_ind, colon$ +localf sat, satind, sat_ind, colon, isat$ localf ideal_colon, ideal_sat, ideal_inclusion, qd_simp_comp, qd_remove_redundant_comp$ -localf pd_simp_comp$ +localf pd_simp_comp, remove_identical_comp$ localf pd_remove_redundant_comp, ppart, sq, gen_fctr, gen_nf, gen_gb_comp$ localf gen_mptop, lcfactor, compute_deg0, compute_deg, member$ localf elimination, setintersection, setminus, sep_list$ @@ -50,16 +52,27 @@ localf gbcheck,f4,sathomo,qd_check,qdb_check$ SatHomo=0$ GBCheck=1$ GBRat=0$ +SuccSat=0$ +RepColon=0$ #define MAX(a,b) ((a)>(b)?(a):(b)) #define ACCUM_TIME(C,R) {T1 = time(); C += (T1[0]-T0[0])+(T1[1]-T0[1]); R += (T1[3]-T0[3]); } def gbrat(A) { - if ( A ) GBRat = 1; - else GBRat = 0; + GBRat = A; } +def succsat(A) +{ + SuccSat = A; +} + +def repcolon(A) +{ + RepColon = A; +} + def gbcheck(A) { if ( A ) GBCheck = 1; @@ -165,7 +178,8 @@ def qdb_check(B,V,QD) for ( I = 0, Q = [1]; I < N; I++ ) for ( J = 0, QL = map(first,QD[I]), L = length(QL); J < L; J++ ) - Q = ideal_intersection(Q,QL[J],V,0|mod=Mod); + Q = ideal_intersection_m(Q,QL[J],V,0|mod=Mod); + Q = nd_gr(Q,V,0,0); if ( !gen_gb_comp(G,Q,Mod) ) return 0; for ( I = 0; I < N; I++ ) { @@ -273,16 +287,18 @@ def syci_dec(B,V) if ( type(Ass=getopt(ass)) == -1 ) Ass = 0; if ( type(Colon=getopt(colon)) == -1 ) Colon = 0; if ( type(Para=getopt(para)) == -1 ) Para = 0; + if ( type(Trace=getopt(trace)) == -1 ) Trace = 0; Ord = 0; Tiso = Tint = Tpd = Text = Tint2 = 0; RTiso = RTint = RTpd = RText = RTint2 = 0; T00 = time(); - G = fast_gb(B,V,Mod,Ord|trace=1); + G = fast_gb(B,V,Mod,Ord|trace=Trace); IntQ = [1]; QL = RL = []; First = 1; for ( Level = 0; ; Level++ ) { T0 = time(); - if ( First ) { + if ( !Level ) { PtR = prime_dec(G,V|indep=1,lexdec=Lexdec,mod=Mod,radical=1); +ACCUM_TIME(Tfpd,RTfpd) Pt = PtR[0]; IntPt = PtR[1]; Rad = IntPt; if ( gen_gb_comp(G,Rad,Mod) ) { /* Gt is radical and Gt = cap Pt */ @@ -295,25 +311,91 @@ T0 = time(); ACCUM_TIME(Tpd,RTpd) T0 = time(); Rt = iso_comp(G,Pt,V,Ord|mod=Mod,iso=Iso,para=Para,intq=IntQ); - RL = append(RL,[Rt]); ACCUM_TIME(Tiso,RTiso) + if ( !Level ) { + if ( Iso == 3 ) { + NI = length(Rt); + Q = IntQ; T0 = time(); - IntQ = ideal_list_intersection(map(first,Rt),V,Ord|mod=Mod,para=Para); - QL = append(QL,[IntQ]); + if ( Para ) { + for ( J = 0, Task = []; J < NI; J++ ) { + T = ["noro_pd.extract_qj",Q,V,Rt[J],Rad,Mod,SI,Colon,-1]; + Task = cons(T,Task); + } + Task = reverse(Task); + print("comps:",2); print(length(Task),2); + Rt = para_exec(Para,Task); + } else { + for ( J = 0, T = []; J < NI; J++ ) { + TJ = extract_qj(Q,V,Rt[J],Rad,Mod,SI,Colon,-1); + T = cons(TJ,T); + } + Rt = reverse(T); + } +ACCUM_TIME(Text,RText) + } + print(""); +T0 = time(); + Int = Rad; + for ( T = Rt; T != []; T = cdr(T) ) + if ( !gb_comp(car(T)[0],car(T)[1]) ) + Int = ideal_intersection_m(Int,car(T)[0],V,Ord|mod=Mod); + IntQ = nd_gr(Int,V,Mod,Ord); ACCUM_TIME(Tint,RTint) + RL = append(RL,[Rt]); + } else if ( Iso != 3 ) { +T0 = time(); + IntQ = ideal_list_intersection(map(first,Rt),V,Ord|mod=Mod,isgb=1); + RL = append(RL,[Rt]); +ACCUM_TIME(Tint,RTint) + } else { + NI = length(Rt); + Q = IntQ; + if ( Para ) { + for ( J = 0, Task = []; J < NI; J++ ) { + T = ["noro_pd.extract_qj",Q,V,Rt[J],Rad,Mod,SI,Colon,-1]; + Task = cons(T,Task); + } + Task = reverse(Task); + print("comps:",2); print(length(Task),2); +T0 = time(); + R = para_exec(Para,Task); +ACCUM_TIME(Text,RText) + print(""); +T0 = time(); + IntQ = ideal_list_intersection(cons(IntQ,map(first,R)),V,Ord|mod=Mod); +ACCUM_TIME(Tint,RTint) + RL = append(RL,[R]); + } else { + for ( J = 0, T = []; J < NI; J++ ) { +T0 = time(); + TJ = extract_qj(Q,V,Rt[J],Rad,Mod,SI,Colon,-1); +ACCUM_TIME(Text,RText) + T = cons(TJ,T); +T0 = time(); + IntQ = ideal_intersection_m(IntQ,TJ[0],V,Ord|mod=Mod); +ACCUM_TIME(Tint,RTint) + } + print(""); +T0 = time(); + IntQ = nd_gr(IntQ,V,Mod,Ord); +ACCUM_TIME(Tint,RTint) + T = reverse(T); RL = append(RL,[T]); + } + } + QL = append(QL,[IntQ]); if ( gen_gb_comp(IntQ,G,Mod) ) break; - First = 0; } T0 = time(); - if ( !Ass ) + if ( Iso != 3 && !Ass ) RL = extract_comp(QL,RL,V,Rad|mod=Mod,para=Para,si=SI,colon=Colon,ass=Ass); ACCUM_TIME(Text,RText) if ( Time ) { T1 = time(); Tall = T1[0]-T00[0]+T1[1]-T00[1]; RTall += T1[3]-T00[3]; Tass = Tall-Text; RTass = RTall-RText; - print(["total",Tall,"ass",Tass,"pd",Tpd,"iso",Tiso,"int",Tint,"ext",Text]); - print(["elapsed",RTall,"ass",RTass,"pd",RTpd,"iso",RTiso,"int",RTint,"ext",RText]); + print(["total",Tall,"ass",Tass,"pd",Tpd,"(fpd)",Tfpd,"iso",Tiso,"int",Tint,"ext",Text]); + print(["elapsed",RTall,"ass",RTass,"pd",RTpd,"(fpd)",RTfpd,"iso",RTiso,"int",RTint,"ext",RText]); } return RL; } @@ -334,6 +416,7 @@ def extract_comp(QL,RL,V,Rad) { Task = cons(T,Task); } } + Task = reverse(Task); print("comps:",2); print(length(Task),2); print(""); R = para_exec(Para,Task); S = vector(L); @@ -365,33 +448,63 @@ def colon_prime_dec(G,IntQ,V) { if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; if ( type(Lexdec=getopt(lexdec)) == -1 ) Lexdec = 0; if ( type(Para=getopt(para)) == -1 ) Para = 0; + if ( !Para ) { + print("colon_pd:",2); print(length(IntQ),2); + } if ( !Mod ) M = mingen(IntQ,V); else M = IntQ; if ( Para ) { L = length(M); - for ( Task = [], J = 0, RI = []; J < L; J++ ) + for ( Task = [], J = 0; J < L; J++ ) if ( gen_nf(M[J],G,V,Ord,Mod) ) { - T = ["noro_pd.colon_prime_dec1",G,M[J],Mod,V]; + T = ["noro_pd.call_colon",G,M[J],V,Mod,1]; Task = cons(T,Task); } Task = reverse(Task); R = para_exec(Para,Task); + R = pd_simp_comp(R,V|mod=Mod); L = length(R); + + for ( Task = [], J = 0; J < L; J++ ) { + T = ["noro_pd.call_prime_dec",R[J],V,1,Lexdec,Mod]; + Task = cons(T,Task); + } + Task = reverse(Task); + R = para_exec(Para,Task); + for ( Pt = [], T = R; T != []; T = cdr(T) ) Pt = append(Pt,car(T)); } else { - for ( Pt = [], T = M; T != []; T = cdr(T) ) { - Pi = colon_prime_dec1(G,car(T),Mod,V); + for ( R = [], T = M; T != []; T = cdr(T) ) { + Ci = colon(G,car(T),V|isgb=1,mod=Mod); + R = cons(Ci,R); + } + print("->",2); print(length(M),2); + R = pd_simp_comp(R,V|mod=Mod); + print("->",2); print(length(R)); +#if 1 + for ( Pt = [], T = R; T != []; T = cdr(T) ) { + Pi = prime_dec(car(T),V|indep=1,lexdec=Lexdec,mod=Mod); Pt = append(Pt,Pi); } +#else + J = ideal_list_intersection(R,V,0|mod=Mod); + Pt = prime_dec(J,V|indep=1,lexdec=Lexdec,mod=Mod); +#endif } +#if 1 Pt = pd_simp_comp(Pt,V|first=1,mod=Mod); +#endif return Pt; } -def colon_prime_dec1(G,F,Mod,V) +def call_colon(G,F,V,Mod,IsGB) { - Ci = colon(G,F,V|isgb=1,mod=Mod); - if ( type(Ci[0]) != 1 ) - Pi = prime_dec(Ci,V|indep=1,lexdec=Lexdec,mod=Mod); + return colon(G,F,V|isgb=1,mod=Mod); +} + +def call_prime_dec(G,V,Indep,Lexdec,Mod) +{ + if ( type(G[0]) != 1 ) + Pi = prime_dec(G,V|indep=Indep,lexdec=Lexdec,mod=Mod); else Pi = []; return Pi; @@ -402,8 +515,11 @@ def extract_qj(Q,V,QL,Rad,Mod,SI,Colon,Level) SIFList=[find_ssi0, find_ssi1,find_ssi2]; SIF = SIFList[SI]; G = QL[0]; P = QL[1]; PV = QL[2]; - C = Colon ? ideal_colon(G,Q,V|mod=Mod) : P; - Ok = (*SIF)(C,G,Q,Rad,V,0|mod=Mod); + if ( Q != [1] ) { + C = Colon ? ideal_colon(G,Q,V|mod=Mod) : P; + Ok = (*SIF)(C,G,Q,Rad,V,0|mod=Mod); + } else + Ok = []; V0 = setminus(V,PV); HJ = elim_gb(append(Ok,G),V0,PV,Mod,[[0,length(V0)],[0,length(PV)]]); HJ = contraction(HJ,V0|mod=Mod); @@ -596,7 +712,7 @@ def find_si1(C,G,Q,Rad,V,Ord) { /* check whether (Q cap (G+S)) = G */ if ( gen_gb_comp(Int,G,Mod) ) { print([0]); return reverse(S); } - C = qsort(C,comp_tdeg); + C = qsort(C,noro_pd.comp_tdeg); Tmp = ttttt; TV = cons(Tmp,V); Ord1 = [[0,1],[Ord,length(V)]]; Int0 = incremental_gb(append(vtol(ltov(G)*Tmp),vtol(ltov(Q)*(1-Tmp))), @@ -639,7 +755,7 @@ def find_si2(C,G,Q,Rad,V,Ord) { /* check whether (Q cap (G+S)) = G */ if ( gen_gb_comp(Int,G,Mod) ) { print([0]); return reverse(S); } - C = qsort(C,comp_tdeg); + C = qsort(C,noro_pd.comp_tdeg); Dp = dp_gr_print(); dp_gr_print(0); Tmp = ttttt; TV = cons(Tmp,V); Ord1 = [[0,1],[Ord,length(V)]]; @@ -659,7 +775,7 @@ def find_si2(C,G,Q,Rad,V,Ord) { print([length(T),I],2); S = cons(Ui,S); } - S = qsort(S,comp_tdeg); + S = qsort(S,noro_pd.comp_tdeg); print(""); End = Len = length(S); @@ -750,7 +866,7 @@ def find_ssi1(C,G,Q,Rad,V,Ord) { if ( gen_gb_comp(Int,G,Mod) ) { print([0]); return reverse(S); } dp_ord(Ord); DC = map(dp_ptod,C,V); - DC = qsort(DC,comp_tord); C = map(dp_dtop,DC,V); + DC = qsort(DC,noro_pd.comp_tord); C = map(dp_dtop,DC,V); print(length(C),2); if ( Reduce ) { SC = map(sq,C,Mod); @@ -808,14 +924,14 @@ def find_ssi2(C,G,Q,Rad,V,Ord) { #if 0 dp_ord(Ord); DC = map(dp_ptod,C,V); - DC = qsort(DC,comp_tord); C = map(dp_dtop,DC,V); + DC = qsort(DC,noro_pd.comp_tord); C = map(dp_dtop,DC,V); #else - C = qsort(C,comp_tdeg); + C = qsort(C,noro_pd.comp_tdeg); #endif if ( Reduce ) { for ( T = C, C1 = [], R1 = Rad; T != []; T = cdr(T) ) { if ( !gen_nf(car(T),Rad,V,Ord,Mod) ) continue; - if ( radical_membership(car(T),R1,V) ) { + if ( radical_membership(car(T),R1,V|mod=Mod) ) { C1 = cons(car(T),C1); R1 = cons(sq(car(T),Mod),R1); } @@ -828,7 +944,7 @@ def find_ssi2(C,G,Q,Rad,V,Ord) { Ui = U = car(T); S = cons([Ui,U],S); } - S = qsort(S,comp_tdeg_first); + S = qsort(S,noro_pd.comp_tdeg_first); print(""); Dp = dp_gr_print(); dp_gr_print(0); @@ -927,7 +1043,7 @@ def pseudo_dec(G,L,V,Ord) for ( I = 0; I < N; I++ ) { LI = setminus(L0,[L0[I]]); PI = ideal_list_intersection(LI,V,Ord|mod=Mod); - PI = qsort(PI,comp_tdeg); + PI = qsort(PI,noro_pd.comp_tdeg); for ( T = PI; T != []; T = cdr(T) ) if ( gen_nf(car(T),L0[I],V,Ord,Mod) ) break; if ( T == [] ) error("separator : cannot happen"); @@ -961,8 +1077,9 @@ def iso_comp(G,L,V,Ord) if ( type(Iso=getopt(iso)) == -1 ) Iso = 0; if ( type(Para=getopt(para)) == -1 ) Para = 0; if ( type(Q=getopt(intq)) == -1 ) Q = 0; + if ( type(S=getopt(sep)) == -1 ) S = 0; - S = separator(L,V|mod=Mod); + if ( !S ) S = separator(L,V|mod=Mod); N = length(L); print("comps : ",2); print(N); print("",2); if ( Para ) { @@ -993,10 +1110,10 @@ def locsat(G,V,L,S,Mod,IsGB,Iso,Q) if ( Iso==1 ) { QI = sat(G,S,V|isgb=IsGB,mod=Mod); GI = elim_gb(QI,V0,PV,Mod,[[0,length(V0)],[0,length(PV)]]); - GI = nd_gr(contraction(GI,V0|mod=Mod),V,Mod,0); + GI = nd_gr(contraction(GI,V0|mod=Mod,allv=V),V,Mod,0); } else if ( Iso==0 ) { HI = elim_gb(G,V0,PV,Mod,[[0,length(V0)],[0,length(PV)]]); - GI = nd_gr(contraction(HI,V0|mod=Mod),V,Mod,0); + GI = nd_gr(contraction(HI,V0|mod=Mod,allv=V),V,Mod,0); GI = sat(GI,S,V|isgb=IsGB,mod=Mod); } else if ( Iso==2 ) { HI = elim_gb(G,V0,PV,Mod,[[0,length(V0)],[0,length(PV)]]); @@ -1007,7 +1124,9 @@ def locsat(G,V,L,S,Mod,IsGB,Iso,Q) GI = nd_gr_trace(append(HI,[TV*S-1]),cons(TV,V0), 1,1,[[0,1],[0,length(V0)]]|gbblock=[[0,length(HI)]]); GI = elimination(GI,V); - GI = nd_gr(contraction(GI,V0|mod=Mod),V,Mod,0); + GI = nd_gr(contraction(GI,V0|mod=Mod,allv=V),V,Mod,0); + } else if ( Iso==3 ) { + GI = sat(G,S,V|isgb=IsGB,mod=Mod); } if ( Q ) GI = ideal_intersection(Q,GI,V,0|mod=Mod); @@ -1056,7 +1175,7 @@ def prime_dec(B,V) { if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; if ( type(Indep=getopt(indep)) == -1 ) Indep = 0; - if ( type(NoLexDec=getopt(lexdec)) == -1 ) LexDec = 0; + if ( type(LexDec=getopt(lexdec)) == -1 ) LexDec = 0; if ( type(Rad=getopt(radical)) == -1 ) Rad = 0; B = map(sq,B,Mod); if ( LexDec ) @@ -1067,55 +1186,162 @@ def prime_dec(B,V) G = ideal_list_intersection(PD,V,0|mod=Mod); PD = pd_remove_redundant_comp(G,PD,V,0|mod=Mod); } + R = []; RL = []; + for ( T = PD; T != []; T = cdr(T) ) { + PDT = prime_dec_main(car(T),V|indep=Indep,mod=Mod); + R = append(R,PDT[0]); + GT = nd_gr(PDT[1],V,Mod,0); + RL = append(RL,[GT]); + } + if ( LexDec ) R = pd_simp_comp(R,V|first=Indep,mod=Mod); + if ( Rad ) { + G = ideal_list_intersection(RL,V,0|mod=Mod); + return [R,G]; + } else return R; +} + +def prime_dec2(B,V) +{ + if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; + if ( type(Indep=getopt(indep)) == -1 ) Indep = 0; + if ( type(LexDec=getopt(lexdec)) == -1 ) LexDec = 0; + if ( type(Rad=getopt(radical)) == -1 ) Rad = 0; + if ( type(Para=getopt(para)) == -1 || type(Para) != 4 ) Para = []; + B = map(sq,B,Mod); + if ( LexDec ) + PD = lex_predec1(B,V|mod=Mod); + else + PD = [B]; + if ( length(PD) > 1 ) { + G = ideal_list_intersection(PD,V,0|mod=Mod); + PD = pd_remove_redundant_comp(G,PD,V,0|mod=Mod); + } R = []; for ( T = PD; T != []; T = cdr(T) ) - R = append(prime_dec_main(car(T),V|indep=Indep,mod=Mod),R); + R = append(prime_dec_main2(car(T),V|indep=Indep,mod=Mod,para=Para),R); if ( Indep ) { G = ideal_list_intersection(map(first,R),V,0|mod=Mod); - if ( LexDec ) R = pd_simp_comp(R,V|first=1,mod=Mod); + R = pd_simp_comp(R,V|first=1,mod=Mod); } else { G = ideal_list_intersection(R,V,0|mod=Mod); - if ( LexDec ) R = pd_simp_comp(R,V|first=1,mod=Mod); + R = pd_simp_comp(R,V|mod=Mod); } return Rad ? [R,G] : R; } +/* returns [PD,rad(I)] */ + def prime_dec_main(B,V) { + Tpint = RTpint = 0; if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; if ( type(Indep=getopt(indep)) == -1 ) Indep = 0; G = fast_gb(B,V,Mod,0); IntP = [1]; PD = []; + DG = ltov(map(dp_ptod,G,V)); + for ( Ind = [], I = length(G)-1; I >= 0; I-- ) Ind = cons(I,Ind); + if ( Mod ) DG = map(dp_mod,DG,Mod,[]); while ( 1 ) { + print([length(PD)],2); /* rad(G) subset IntP */ /* check if IntP subset rad(G) */ - for ( T = IntP; T != []; T = cdr(T) ) { - if ( (GNV = radical_membership(car(T),G,V|mod=Mod,isgb=1)) ) { + /* print([length(PD),length(IntP)],2); */ + for ( T = IntP; T != []; T = cdr(T) ) + if ( (G0 = radical_membership_sat(car(T),G,V|mod=Mod,isgb=1,dg=[DG,Ind])) ) { F = car(T); break; } + if ( T == [] ) { + print(["pint",Tpint,"rpint",RTpint]); + return [PD,IntP]; } - if ( T == [] ) return PD; - - /* GNV = [GB(),NV] */ - G1 = fast_gb(GNV[0],cons(GNV[1],V),Mod,[[0,1],[0,length(V)]]); - G0 = elimination(G1,V); PD0 = zprimecomp(G0,V,Indep|mod=Mod); - if ( Indep ) { - Int = ideal_list_intersection(PD0[0],V,0|mod=Mod); - IndepSet = PD0[1]; - for ( PD1 = [], T = PD0[0]; T != []; T = cdr(T) ) - PD1 = cons([car(T),IndepSet],PD1); - PD = append(PD,reverse(PD1)); - } else { - Int = ideal_list_intersection(PD0,V,0|mod=Mod); - PD = append(PD,PD0); - } - IntP = ideal_intersection(IntP,Int,V,0|mod=Mod); + Int = ideal_list_intersection(Indep?map(first,PD0):PD0,V,0|mod=Mod); + PD = append(PD,PD0); +#if 1 +T0=time(); + IntP = ideal_intersection_m(IntP,Int,V,0|mod=Mod); + dp_ord(0); DC = map(dp_ptod,IntP,V); + DC = qsort(DC,noro_pd.comp_tord); IntP = map(dp_dtop,DC,V); +ACCUM_TIME(Tpint,RTpint) +#else + IntP = ideal_intersection(IntP,Int,V,0|mod=Mod,gbblock=[[0,length(IntP)]]); +#endif } } +localf callsat,callzcomp; + +def callsat(F,G,V,Mod,DG) +{ + return radical_membership(F,G,V|mod=Mod,isgb=1,dg=DG,sat=1); +} + +def callzcomp(F,V,Indep,Mod) +{ + PD0 = zprimecomp(F,V,Indep|mod=Mod); + Int = ideal_list_intersection(Indep?map(first,PD0):PD0,V,0|mod=Mod); + return [PD0,Int]; +} + +def prime_dec_main2(B,V) +{ + if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; + if ( type(Indep=getopt(indep)) == -1 ) Indep = 0; + if ( type(Para=getopt(para)) == -1 || type(Para) != 4 ) Para = []; + NPara = length(Para); + + G = fast_gb(B,V,Mod,0); + IntP = [1]; + PD = []; + DG = ltov(map(dp_ptod,G,V)); + for ( Ind = [], I = length(G)-1; I >= 0; I-- ) Ind = cons(I,Ind); + if ( Mod ) DG = map(dp_mod,DG,Mod,[]); + if ( NPara ) + while ( 1 ) { + IntPM = mingen(IntP,V); + for ( T = IntPM, CallSat = []; T != []; T = cdr(T) ) + CallSat = cons(["noro_pd.callsat",car(T),G,V,Mod,[DG,Ind]],CallSat); + CallSat = reverse(CallSat); + /* SatL = [[..],0,[...],...] */ + SatL = para_exec(Para,CallSat); + for ( T = SatL, Sat = []; T != []; T = cdr(T) ) if ( car(T) ) Sat = cons(car(T),Sat); + if ( Sat == [] ) return PD; + print(length(Sat),2); print("->",2); + Sat = remove_identical_comp(Sat|mod=Mod); + print(length(Sat)); + for ( T = Sat, CallComp = []; T != []; T = cdr(T) ) + CallComp = cons(["noro_pd.callzcomp",car(T),V,Indep,Mod],CallComp); + CallComp = reverse(CallComp); + /* PDL = [[PD0,Int],...] */ + PDL = para_exec(Para,CallComp); + for ( T = PDL; T != []; T = cdr(T) ) PD = append(PD,car(T)[0]); + Int = ideal_list_intersection(map(second,PDL),V,0|mod=Mod); + IntP = ideal_intersection(IntP,Int,V,0|mod=Mod,gbblock=[[0,length(IntP)]]); + } + else + while ( 1 ) { + /* rad(G) subset IntP */ + /* check if IntP subset rad(G) */ + /* print([length(PD),length(IntP)],2); */ + Sat = []; + IntPM = mingen(IntP,V); + for ( T = IntPM; T != [] && length(Sat) < 16; T = cdr(T) ) + if ( G0 = radical_membership(car(T),G,V|mod=Mod,isgb=1,dg=[DG,Ind],sat=1) ) + Sat = cons(G0,Sat); + if ( Sat == [] ) return PD; + print(length(Sat),2); print("->",2); + Sat = remove_identical_comp(Sat|mod=Mod); + print(length(Sat)); + for ( T = Sat; T != []; T = cdr(T) ) { + PD0 = zprimecomp(car(T),V,Indep|mod=Mod); PD = append(PD,PD0); + Int = ideal_list_intersection(Indep?map(first,PD0):PD0,V,0|mod=Mod); + IntP = ideal_intersection(IntP,Int,V,0|mod=Mod,gbblock=[[0,length(IntP)]]); + } + } +} + /* pre-decomposition */ def lex_predec1(B,V) @@ -1177,7 +1403,7 @@ def complete_qdecomp(GD,V,Mod) NV = ttttt; M = gen_minipoly(cons(NV-U,GQ),cons(NV,V),PV,0,NV,Mod); M = ppart(M,NV,Mod); - MF = Mod ? modfctr(M) : fctr(M); + MF = Mod ? modfctr(M,Mod) : fctr(M); R = []; for ( T = cdr(MF); T != []; T = cdr(T) ) { S = car(T); @@ -1274,7 +1500,7 @@ def complete_decomp(GD,V,Mod) NV = ttttt; M = gen_minipoly(cons(NV-U,G),cons(NV,V),PV,0,NV,Mod); M = ppart(M,NV,Mod); - MF = Mod ? modfctr(M) : fctr(M); + MF = Mod ? modfctr(M,Mod) : fctr(M); if ( length(MF) == 2 ) return [G]; R = []; for ( T = cdr(MF); T != []; T = cdr(T) ) { @@ -1390,10 +1616,9 @@ def zprimecomp(G,V,Indep) { for ( T = PD; T != []; T = cdr(T) ) { U = contraction(car(T),V0|mod=Mod); U = nd_gr(U,V,Mod,0); - R = cons(U,R); + R = cons(Indep?[U,W]:U,R); } - if ( Indep ) return [R,W]; - else return R; + return R; } def fast_gb(B,V,Mod,Ord) @@ -1460,7 +1685,8 @@ def elim_gb(G,V,PV,Mod,Ord) G = competitive_exec(EProcs,Arg0,Arg1); } else if ( GBRat ) { G1 = nd_gr(G,append(V,PV),0,O1); - G1 = nd_gr_postproc(G1,V,0,Ord,0); + if ( GBRat == 1 ) + G1 = nd_gr_postproc(G1,V,0,Ord,0|nora=1); return G1; } else #if 1 @@ -1518,6 +1744,7 @@ def find_npos(GD,V,PV,Mod) { N = length(V); PN = length(PV); G = GD[0]; D = GD[1]; LD = D[N]; + DH = map(dp_dtop,map(dp_ht,map(dp_ptod,D,V)),V); Ord0 = dp_ord(); dp_ord(0); HC = map(dp_hc,map(dp_ptod,G,V)); dp_ord(Ord0); @@ -1531,9 +1758,15 @@ def find_npos(GD,V,PV,Mod) NV = ttttt; for ( B = 2; ; B++ ) { for ( J = N-2; J >= 0; J-- ) { - for ( U = 0, K = J; K < N; K++ ) + for ( U = 0, K = J; K < N; K++ ) { + if ( DH[K] == V[K] ) continue; U += rsgn()*((random()%B+1))*V[K]; + } +#if 0 M = minipolym(G,V,0,U,NV,Mod); +#else + M = gen_minipoly(cons(NV-U,G),cons(NV,V),PV,0,NV,Mod); +#endif if ( deg(M,NV) == LD ) return U; } } @@ -1541,12 +1774,14 @@ def find_npos(GD,V,PV,Mod) def gen_minipoly(G,V,PV,Ord,VI,Mod) { + O0 = dp_ord(); if ( PV == [] ) { NV = sssss; if ( Mod ) M = minipolym(G,V,Ord,VI,NV,Mod); else M = minipoly(G,V,Ord,VI,NV); + dp_ord(O0); return subst(M,NV,VI); } W = setminus(V,[VI]); @@ -1589,6 +1824,7 @@ def gen_minipoly(G,V,PV,Ord,VI,Mod) G = nd_gr_trace(G,PV1,1,GBCheck,[[0,1],[0,length(PV)]]|nora=1); for ( M = car(G), T = cdr(G); T != []; T = cdr(T) ) if ( deg(car(T),VI) < deg(M,VI) ) M = car(T); + dp_ord(O0); return M; } @@ -1634,10 +1870,42 @@ def maxindep(B,V,O) return R; } +def maxindep2(B,V,O) +{ + if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; + G = fast_gb(B,V,Mod,O); + Old = dp_ord(); + dp_ord(O); + H = map(dp_dtop,map(dp_ht,map(dp_ptod,G,V)),V); + H = map(sq,H,0); + H = nd_gr(H,V,0,0); + H = monodec0(H,V); + N = length(V); + Dep = []; + for ( T = H, Len = N+1; T != []; T = cdr(T) ) { + M = length(car(T)); + if ( M < Len ) { + Dep = [car(T)]; + Len = M; + } else if ( M == Len ) + Dep = cons(car(T),Dep); + } + R = []; + for ( T = Dep; T != []; T = cdr(T) ) + R = cons(setminus(V,car(T)),R); + dp_ord(Old); + return reverse(R); +} + + /* ideal operations */ def contraction(G,V) { + if ( type(AllV=getopt(allv)) == -1 ) AllV = 0; if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; + + if ( RepColon ) return contraction_m(G,V|allv=AllV,mod=Mod); + C = []; for ( T = G; T != []; T = cdr(T) ) { C1 = dp_hc(dp_ptod(car(T),V)); @@ -1647,49 +1915,71 @@ def contraction(G,V) } W = vars(G); PV = setminus(W,V); - W = append(V,PV); + if ( AllV ) W = AllV; + else W = append(V,PV); NV = ttttt; - for ( T = C, S = 1; T != []; T = cdr(T) ) - S *= car(T); - G = saturation([G,NV],S,W|mod=Mod); + if ( SuccSat ) { + W1 = cons(NV,W); + O1 = [[0,1],[0,length(W)]]; + Block = []; + for ( T = C; T != []; T = cdr(T) ) { + G1 = nd_gr(append(G,[NV*car(T)-1]),W1,Mod,O1|gbblock=Block); + G = elimination(G1,W); + Block = [[0,length(G)]]; + } + } else { + for ( T = C, S = 1; T != []; T = cdr(T) ) + S *= car(T); + G = saturation([G,NV],S,W|mod=Mod); + } return G; } +def contraction_m(G,V) +{ + if ( type(AllV=getopt(allv)) == -1 ) AllV = 0; + if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; + C = []; + for ( T = G; T != []; T = cdr(T) ) { + C1 = dp_hc(dp_ptod(car(T),V)); + S = gen_fctr(C1,Mod); + for ( S = cdr(S); S != []; S = cdr(S) ) + if ( !member(S[0][0],C) ) C = cons(S[0][0],C); + } + W = vars(G); + PV = setminus(W,V); + if ( AllV ) W = AllV; + else W = append(V,PV); + H = H0 = G; + while ( 1 ) { + for ( T = C; T != []; T = cdr(T) ) + H = map(sdiv,ideal_intersection_m([car(T)],H,W,0),car(T)); + H = nd_gr(H,W,0,0); + if ( gb_comp(H0,H) ) break; + else H0 = H; + } + return H; +} + def ideal_list_intersection(L,V,Ord) { if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; - if ( type(Para=getopt(para)) == -1 || type(Para) != 4 ) Para = []; + if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0; N = length(L); if ( N == 0 ) return [1]; - if ( N == 1 ) return fast_gb(L[0],V,Mod,Ord); - if ( N > 2 && (Len = length(Para)) >= 2 ) { - Div = N >= 2*Len ? Len : 2; - QR = iqr(N,Div); Q = QR[0]; R = QR[1]; - T = []; K = 0; - for ( I = 0; I < Div; I++ ) { - LenI = I= 0; I-- ) Ind = cons(I,Ind); + for ( T = DA, C = []; T != []; T = cdr(T) ) { + L = Mod?dp_true_nf_mod(Ind,car(T),DB,1,Mod):dp_true_nf(Ind,car(T),DB,1); + R = dp_dtop(L[0],V); Q = dp_dtop(car(T)*L[1]-L[0],V); + C = cons([R,-Q],C); + } + G = nd_gr(append(C,map(aa,B)),V,Mod,[1,Ord]|intersect=1); + G = map(second,G); + return G; +} + /* returns GB if F notin rad(G) */ def radical_membership(F,G,V) { if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0; - F = gen_nf(F,G,V,0,Mod); - if ( !F ) return 0; - F2 = gen_nf(F*F,G,V,0,Mod); - if ( !F2 ) return 0; - F3 = gen_nf(F2*F,G,V,0,Mod); - if ( !F3 ) return 0; + if ( type(L=getopt(dg)) == -1 ) L = 0; + if ( type(Sat=getopt(sat)) == -1 ) Sat = 0; + dp_ord(0); + if ( L ) { DG = L[0]; Ind = L[1]; } + else { + DG = ltov(map(dp_ptod,G,V)); + if ( Mod ) DG = map(dp_mod,DG,Mod,[]); + for ( Ind = [], I = length(G)-1; I >= 0; I-- ) Ind = cons(I,Ind); + } + DF = dp_ptod(F,V); DFI = dp_ptod(1,V); + if ( Mod ) { + DF = dp_mod(DF,Mod,[]); DFI = dp_mod(DFI,Mod,[]); + setmod(Mod); + } + for ( I = 0; I < 3; I++ ) { + DFI = Mod?dp_nf_mod(Ind,DF*DFI,DG,0,Mod):dp_nf(Ind,DF*DFI,DG,0); + if ( !DFI ) return 0; + } NV = ttttt; if ( IsGB ) T = nd_gr(append(G,[NV*F-1]),cons(NV,V),Mod,0 |gbblock=[[0,length(G)]]); else T = nd_gr(append(G,[NV*F-1]),cons(NV,V),Mod,0); - if ( type(car(T)) != 1 ) return [T,NV]; - else return 0; + if ( type(car(T)) == 1 ) return 0; + else if ( Sat ) { + G1 = fast_gb(T,cons(NV,V),Mod,[[0,1],[0,length(V)]]); + G0 = elimination(G1,V); + return G0; + } else return [T,NV]; } +def radical_membership_sat(F,G,V) { + if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; + if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0; + if ( type(L=getopt(dg)) == -1 ) L = 0; + dp_ord(0); + if ( L ) { DG = L[0]; Ind = L[1]; } + else { + DG = ltov(map(dp_ptod,G,V)); + if ( Mod ) DG = map(dp_mod,DG,Mod,[]); + for ( Ind = [], I = length(G)-1; I >= 0; I-- ) Ind = cons(I,Ind); + } + DF = dp_ptod(F,V); DFI = dp_ptod(1,V); + if ( Mod ) { + DF = dp_mod(DF,Mod,[]); DFI = dp_mod(DFI,Mod,[]); + setmod(Mod); + } + for ( I = 0; I < 3; I++ ) { + DFI = Mod?dp_nf_mod(Ind,DF*DFI,DG,0,Mod):dp_nf(Ind,DF*DFI,DG,0); + if ( !DFI ) return 0; + } + NV = ttttt; + if ( IsGB ) + T = nd_gr(append(G,[NV*F-1]),cons(NV,V),Mod,[[0,1],[0,length(V)]] + |gbblock=[[0,length(G)]]); + else + T = nd_gr(append(G,[NV*F-1]),cons(NV,V),Mod,[[0,1],[0,length(V)]]); + if ( type(car(T)) == 1 ) return 0; + G0 = elimination(T,V); + return G0; +} + def modular_radical_membership(F,G,V) { if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; if ( Mod ) @@ -1802,7 +2164,7 @@ def ideal_product(A,B,V) for ( T = PA; T != []; T = cdr(T) ) for ( S = PB; S != []; S = cdr(S) ) R = cons([car(T)[0]*car(S)[0],car(T)[1]+car(S)[1]],R); - T = qsort(R,comp_by_second); + T = qsort(R,noro_pd.comp_by_second); T = map(first,T); Len = length(A)>length(B)?length(A):length(B); Len *= 2; @@ -1859,6 +2221,17 @@ def sat(G,F,V) return elimination(G1,V); } +def isat(B,S,V) +{ + if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; + if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0; + F = cdr(fctr(S)); + R = B; + for ( T = F; T != []; T = cdr(T) ) + R = sat(R,car(T)[0],V|mod=Mod,isgb=IsGB); + return R; +} + def satind(G,F,V) { if ( type(Block=getopt(gbblock)) == -1 ) Block = 0; @@ -1922,7 +2295,8 @@ def colon(G,F,V) T = ideal_intersection(G,[F],V,Ord|gbblock=[[0,length(G)]],mod=Mod); else T = ideal_intersection(G,[F],V,Ord|mod=Mod); - return Mod?map(sdivm,T,F,Mod):map(ptozp,map(sdiv,T,F)); + Gen = Mod?map(sdivm,T,F,Mod):map(ptozp,map(sdiv,T,F)); + return nd_gr(Gen,V,Mod,Ord); } #if 1 @@ -1932,7 +2306,7 @@ def ideal_colon(G,F,V) G = nd_gr(G,V,Mod,0); C = [1]; TV = ttttt; - F = qsort(F,comp_tdeg); + F = qsort(F,noro_pd.comp_tdeg); for ( T = F; T != []; T = cdr(T) ) { S = colon(G,car(T),V|isgb=1,mod=Mod); if ( type(S[0])!= 1 ) { @@ -1958,14 +2332,6 @@ def ideal_colon(G,F,V) #endif -def ideal_colon1(G,F,V) -{ - if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; - F = qsort(F,comp_tdeg); - T = mingen(F,V|mod=Mod); - return ideal_colon(G,T,V|mod=Mod); -} - def member(A,L) { for ( ; L != []; L = cdr(L) ) @@ -1976,85 +2342,41 @@ def member(A,L) def mingen(B,V) { if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; Data = nd_gr(B,V,Mod,O|gentrace=1,gensyz=1); - G = Data[0]; - S = compute_gbsyz(V,Data); - S = dtop(S,V); - R = topnum(S); + G = Data[0]; STrace = Data[6]; N = length(G); - U = []; - for ( I = 0; I < N; I++ ) - if ( !member(I,R) ) U = cons(G[I],U); + S = compute_gbsyz(N,V,STrace,Mod); + for ( T = S, R = []; T != []; T = cdr(T) ) { + for ( A = car(T); A1 = dp_rest(A); A = A1); + if ( type(dp_hc(A)) ==1 ) R = cons(dp_etov(A)[0],R); + } + for ( I = 0, U = []; I < N; I++ ) if ( !member(I,R) ) U = cons(G[I],U); return U; } -def compute_gbsyz(V,Data) +def compute_gbsyz(N,V,Trace,Mod) { - G = Data[0]; - Homo = Data[1]; - Trace = Data[2]; - IntRed = Data[3]; - Ind = Data[4]; - InputRed = Data[5]; - SpairTrace = Data[6]; - DB = map(dp_ptod,G,V); - N = length(G); P = vector(N); - for ( I = 0; I < N; I++ ) { - C = vector(N); C[I] = 1; P[I] = C; - } - U = []; - for ( T = SpairTrace; T != []; T = cdr(T) ) { + for ( I = 0; I < N; I++ ) P[I] = dp_ptod(x^I,[x]); + for ( U = [], T = Trace; T != []; T = cdr(T) ) { Ti = car(T); if ( Ti[0] != -1 ) error("Input is not a GB"); - R = recompute_trace3(Ti[1],P,0); - U = cons(redcoef(R)[0],U); + R = recompute_trace(Ti[1],P,V,Mod); + U = cons(R,U); } return reverse(U); } -def redcoef(L) { - N =L[0]$ D = L[1]$ Len = length(N)$ - for ( I = 0; I < Len; I++ ) if ( N[I] ) break; - if ( I == Len ) return [N,0]; - for ( I = 0, G = D; I < Len; I++ ) - if ( N[I] ) G = igcd(G,dp_hc(N[I])/dp_hc(dp_ptozp(N[I]))); - return [N/G,D/G]; -} - -def recompute_trace3(Ti,P,C) +def recompute_trace(Ti,P,V,Mod) { for ( Num = 0, Den = 1; Ti != []; Ti = cdr(Ti) ) { - Sj = car(Ti); Dj = Sj[0]; Ij =Sj[1]; Mj = Sj[2]; Cj = Sj[3]; - /* Num/Den <- (Dj*(Num/Den)+Mj*P[Ij])/Cj */ + Sj = car(Ti); Dj = Sj[0]; Ij =Sj[1]; Mj = dp_dtop(Sj[2],V); Cj = Sj[3]; /* Num/Den <- (Dj*Num+Den*Mj*P[Ij])/(Den*Cj) */ - if ( Dj ) - Num = (Dj*Num+Den*Mj*P[Ij]); + if ( Dj ) Num = (Dj*Num+Den*Mj*P[Ij]); Den *= Cj; - if ( C ) C *= Dj; } - return [Num,C]; + return Num; } -def dtop(A,V) -{ - T = type(A); - if ( T == 4 || T == 5 || T == 6 ) - return map(dtop,A,V); - else if ( T == 9 ) return dp_dtop(A,V); - else return A; -} - -def topnum(L) -{ - for ( R = [], T = L; T != []; T = cdr(T) ) { - V = car(T); - N = length(V); - for ( I = 0; I < N && !V[I]; I++ ); - if ( type(V[I])==1 ) R = cons(I,R); - } - return reverse(R); -} - def ideal_sat(G,F,V) { if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; @@ -2166,6 +2488,22 @@ def pd_remove_redundant_comp(G,P,V,Ord) return reverse(T); } +def remove_identical_comp(L) +{ + if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; + if ( length(L) == 1 ) return L; + + A = ltov(L); N = length(A); + for ( I = 0; I < N; I++ ) { + if ( !A[I] ) continue; + for ( J = I+1; J < N; J++ ) + if ( A[J] && + gen_gb_comp(A[I],A[J],Mod) ) A[J] = 0; + } + for ( I = 0, T = []; I < N; I++ ) if ( A[I] ) T = cons(A[I],T); + return reverse(T); +} + /* polynomial operations */ def ppart(F,V,Mod) @@ -2479,11 +2817,15 @@ def monodec(B,V) T0 = map(dp_ptod,D0,W); D1 = monodec(map(subst,B,X,1),W); T1 = map(dp_ptod,D1,W); +#if 0 for ( T = T1; T != []; T = cdr(T) ) { for ( M = car(T), S1 = [], S = T0; S != []; S = cdr(S) ) if ( !dp_redble(car(S),M) ) S1= cons(car(S),S1); T0 = S1; } +#else + T0 = dp_mono_reduce(T0,T1); +#endif D0 = map(dp_dtop,T0,W); D0 = vtol(X*ltov(D0)); return append(D0,D1); @@ -2493,30 +2835,40 @@ def separator(P,V) { if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; N = length(P); - M = matrix(N,N); + dp_ord(0); + DP = vector(N); + for ( I = 0; I < N; I++ ) DP[I] = qsort(ltov(map(dp_ptod,P[I][0],V)),noro_pd.comp_tord); + if ( Mod ) + for ( I = 0; I < N; I++ ) DP[I] = map(dp_mod,DP[I],Mod,[]); + Ind = vector(N); for ( I = 0; I < N; I++ ) { - /* M[I][J] is an element of P[I]-P[J] */ - PI = qsort(P[I][0],comp_tdeg); + for ( K = [], J = length(DP[I])-1; J >= 0; J-- ) K = cons(J,K); + Ind[I] = K; + } + S = vector(N); + for ( I = 0; I < N; I++ ) S[I] = 1; + for ( I = 0; I < N; I++ ) { + print(".",2); for ( J = 0; J < N; J++ ) { if ( J == I ) continue; - for ( T = PI; T != []; T = cdr(T) ) - if ( gen_nf(car(T),P[J][0],V,0,Mod) ) break; - M[I][J] = sq(car(T),Mod); + T = DP[I]; L = length(T); + if ( Mod ) { + for ( K = 0; K < L; K++ ) + if ( dp_nf_mod(Ind[J],T[K],DP[J],0,Mod) ) break; + } else { + for ( K = 0; K < L; K++ ) + if ( dp_nf(Ind[J],T[K],DP[J],0) ) break; + } + S[J] = lcm(S[J],dp_dtop(T[K],V)); } } - S = vector(N); - for ( J = 0; J < N; J++ ) { - for ( I = 0, T = 1; I < N; I++ ) { - if ( I == J ) continue; - T = sq(T*M[I][J],Mod); - } - S[J] = T; - } + print(""); return S; } def prepost(PL,V) -{ +{ + if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; A = ltov(PL); N = length(A); Pre = vector(N); Post = vector(N); @@ -2524,20 +2876,16 @@ def prepost(PL,V) Pre[0] = [1]; print("pre ",2); for ( I = 1; I < N; I++, print(".",2) ) - Pre[I] = ideal_intersection(Pre[I-1],A[I-1][0],V,0 - |gbblock=[[0,length(Pre[I-1])]],mod=Mod); + Pre[I] = ideal_intersection_m(Pre[I-1],A[I-1],V,0|mod=Mod); print("done"); print("post ",2); Post[N-1] = [1]; for ( I = N-2; I >= 0; I--, print(".",2) ) - Post[I] = ideal_intersection(Post[I+1],A[I+1][0],V,0 - |gbblock=[[0,length(Post[I+1])]],mod=Mod); + Post[I] = ideal_intersection_m(Post[I+1],A[I+1],V,0|mod=Mod); print("done"); print("int ",2); for ( I = 0; I < N; I++, print(".",2) ) - R[I] = ideal_intersection(Pre[I],Post[I],V,0 - |gbblock=[[0,length(Pre[I])],[length(Pre[I]),length(Post[I])]], - mod=Mod); + R[I] = ideal_intersection_m(Pre[I],Post[I],V,0|mod=Mod); print("done"); return R; } @@ -2550,6 +2898,12 @@ def call_func(Arg) return call(strtov(F),cdr(Arg)); } +def call_func_serial(Arg,Serial) +{ + F = car(Arg); + return [call(strtov(F),cdr(Arg)),Serial]; +} + def competitive_exec(P,Arg0,Arg1) { P0 = P[0]; P1 = P[1]; @@ -2580,10 +2934,12 @@ def para_exec(Proc,Task) { Free = Proc; N = length(Task); R = []; + print([N],2); print("->",2); + Serial = 0; while ( N ) { while ( Task != [] && Free != [] ) { T = car(Task); Task = cdr(Task); - ox_cmo_rpc(car(Free),"noro_pd.call_func",T); + ox_rpc(car(Free),"noro_pd.call_func_serial",T,Serial++); ox_push_cmd(car(Free),258); Free = cdr(Free); } Finish0 = Finish = ox_select(Proc); @@ -2593,10 +2949,64 @@ def para_exec(Proc,Task) { R = cons(L,R); N--; } + print([N],2); Free = append(Free,Finish0); } print(""); - return reverse(R); + R = qsort(R,noro_pd.comp_by_second); + R = map(first,R); + return R; +} + +def redbase(B,V,Mod,Ord) +{ + M = nd_gr_postproc(B,V,Mod,Ord,0); + dp_ord(Ord); + DM = ltov(map(dp_ptod,M,V)); + if ( Mod ) DM = map(dp_mod,DM,Mod,[]); + N = length(DM); + for ( Ind = [], I = N-1; I >= 0; I-- ) Ind = cons(I,Ind); + for ( T = B, R = vtol(DM); T != []; T = cdr(T) ) { + D = dp_ptod(car(T),V); + if ( Mod ) D = dp_mod(D,Mod,[]); + D = Mod?dp_nf_mod(Ind,D,DM,1,Mod):dp_nf(Ind,D,DM,1); + if ( D ) R = cons(D,R); + } + D = qsort(R,noro_pd.comp_tord); + return map(dp_dtop,D,V); +} + +def witness(A,B,V) +{ + G = nd_gr(B,V,0,Mod); + L = length(A); + QL = []; PL = []; + for ( I = L-1; I >= 0; I-- ) { + QL = append(map(first,A[I]),QL); + PL = append(map(second,A[I]),PL); + } + N = length(QL); + Qhat = prepost(QL,V); + for ( I = 0, W = []; I < N; I++ ) { + for ( T = Qhat[I]; T != []; T = cdr(T) ) + if ( gen_nf(car(T),QL[I],V,0,Mod) ) break; + Ai = car(T); + Ji = colon(G,Ai,V|isgb=1,mod=Mod); + Ji = nd_gr(Ji,V,Mod,0); + if ( gen_gb_comp(Ji,PL[I],Mod) ) Bi = 1; + else { + Ki = ideal_colon(Ji,PL[I],V|mod=Mod); + for ( T = Ki; T != []; T = cdr(T) ) + if ( gen_nf(car(T),Ji,V,0,Mod) ) break; + Bi = car(T); + } + W = cons(Ai*Bi,W); + Li = colon(G,W[0],V|isgb=1,mod=Mod); + Li = nd_gr(Li,V,Mod,0); + if ( !gen_gb_comp(Li,PL[I],Mod) ) + error("afo"); + } + return reverse(W); } endmodule$ end$