1 /* files by Mathieu Kohli summer 2014*/
4 /* New functions where we write I as a decreasing list, therefore reversing the rows in Info and Sigma for example. The first function allows us to reverse the rows of Sigma*/
7 if equal(Sigma,[]) then
9 else append([reverse(first(Sigma))],Reverserows(rest(Sigma,1)))
12 cut_Sigma1(revSigma,temprow):=
13 block([templ_0,templ_1,templ_s],
14 if equal(revSigma,[]) then
16 elseif equal(first(revSigma),[]) then
18 elseif equal(rest(revSigma,1),[]) then
21 (if equal(rest(first(revSigma)),rest(second(revSigma))) then
22 ([templ_0,templ_1,templ_s] : cut_Sigma1(rest(revSigma,2),temprow+2),
23 [append([temprow],templ_0),append([temprow+1],templ_1),templ_s])
25 ([templ_0,templ_1,templ_s] : cut_Sigma1(rest(revSigma,1),temprow+1),
26 [templ_0,templ_1,append([temprow],templ_s)])
30 cut_Sigma(revSigma):=cut_Sigma1(revSigma,1);
32 extractXiXiprime1(temprevSigma,temprow,templ_0,templ_1,templ_s):=
33 block([tempXiprime,tempXi],
34 if equal(temprevSigma,[]) then
36 elseif notequal(templ_0,[]) and equal(first(templ_0),temprow) then
37 ([tempXiprime,tempXi] : extractXiXiprime1(rest(temprevSigma,1),temprow+1,rest(templ_0,1),templ_1,templ_s),
38 [tempXiprime,append([rest(first(temprevSigma),1)],tempXi)] )
39 elseif notequal(templ_s,[]) and equal(first(templ_s),temprow) then
40 ([tempXiprime,tempXi] : extractXiXiprime1(rest(temprevSigma,1),temprow+1,templ_0,templ_1,rest(templ_s,1)),
41 [tempXiprime,append([rest(first(temprevSigma),1)],tempXi)] )
43 ([tempXiprime,tempXi] : extractXiXiprime1(rest(temprevSigma,1),temprow+1,templ_0,rest(templ_1,1),templ_s),
44 [append([rest(first(temprevSigma),1)],tempXiprime),tempXi]) )
47 extractXiXiprime(revSigma,l_0,l_1,l_s):=extractXiXiprime1(revSigma,1,l_0,l_1,l_s);
49 assembleInfo1(tempInfoXi,tempInfoXiprime,temprow,templ_0,templ_1,templ_s):=
51 if notequal(templ_0,[]) and equal(first(templ_0),temprow) then
52 (append([append([0],first(tempInfoXi))],assembleInfo1(rest(tempInfoXi,1),tempInfoXiprime,temprow+1,rest(templ_0,1),templ_1,templ_s))
54 elseif notequal(templ_s,[]) and equal(first(templ_s),temprow) then
55 (append([append([s],first(tempInfoXi))],assembleInfo1(rest(tempInfoXi,1),tempInfoXiprime,temprow+1,templ_0,templ_1,rest(templ_s,1)))
57 elseif notequal(templ_1,[]) then
58 (append([append([1],first(tempInfoXiprime))],assembleInfo1(tempInfoXi,rest(tempInfoXiprime,1),temprow+1,templ_0,rest(templ_1,1),templ_s))
68 block([l_0,l_1,l_s,Xi,Xiprime],
69 [l_0,l_1,l_s] : cut_Sigma(revSigma),
70 [Xiprime,Xi] : extractXiXiprime(revSigma,l_0,l_1,l_s),
71 assembleInfo1(revInfo(Xi,rest(I,1)),revInfo(Xiprime,rest(I,1)),1,l_0,l_1,l_s)
74 adaptedfamilyrow(rowrevInfo,I):=
75 if equal(rowrevInfo,[]) then
77 elseif first(rowrevInfo)=0 or first(rowrevInfo)=s then
78 adaptedfamilyrow(rest(rowrevInfo,1),rest(I,1))
80 append([first(I)],adaptedfamilyrow(rest(rowrevInfo,1),rest(I,1)))
83 adapted_family(revInfo,I):=
84 if equal(revInfo,[]) then
86 else append([adaptedfamilyrow(first(revInfo),I)],adapted_family(rest(revInfo,1),I)) ;
90 else first(v)*first(w)+scalarproduct(rest(v,1),rest(w,1));
92 evaluation(Mat,vect):=
94 else append([scalarproduct(first(Mat),vect)],evaluation(rest(Mat,1),vect));
96 decreasinginsert(a,decreasinglist):=
97 if equal(decreasinglist,[]) then [a]
98 elseif a>first(decreasinglist) then
99 append([a],decreasinglist)
100 elseif equal(a,first(decreasinglist)) then
103 append([first(decreasinglist)],decreasinginsert(a,rest(decreasinglist,1))) ;
106 if equal(Ada,[]) or equal(Ada,[[]]) then []
107 elseif equal(first(Ada),[]) then
109 else decreasinginsert(first(first(Ada)),comp(append([rest(first(Ada),1)],rest(Ada,1)))) ;
111 rowcompression(row,comp,I):=
112 if equal(comp,[]) then []
113 elseif equal(first(comp),first(I)) then
114 append([first(row)],rowcompression(rest(row,1),rest(comp,1),rest(I,1)))
116 rowcompression(rest(row,1),comp,rest(I,1)) ;
118 Matrixcomp(Mat,comp,I):=
119 if equal(Mat,[]) then []
120 else append([rowcompression(first(Mat),comp,I)],Matrixcomp(rest(Mat,1),comp,I)) ;
122 power(znzcondition,i,I):=
123 if equal(i,first(I)) then first(znzcondition)
124 else power(rest(znzcondition,1),i,rest(I,1)) ;
126 powerlist(znzcondition,J,I):=
127 if equal(J,[]) then 1
128 else power(znzcondition,first(J),I)*powerlist(znzcondition,rest(J,1),I) ;
130 Sigmatopowerlist(revSigma,J,I):=
131 if revSigma=[] then []
133 append([powerlist(first(revSigma),J,I)],Sigmatopowerlist(rest(revSigma,1),J,I)) ;
135 /*the next matrix we are about to define is NOT reversed if we compare it to what is written in the article*/
138 if equal(A,[]) then []
140 append([Sigmatopowerlist(revSigma,first(A),I)],Mat(rest(A,1),revSigma,I));
142 /*Let's notice that in the case where A equals Ada, Mat(Ada,revSigma,I)=Mat(Ada,Matrixcomp(revSigma,comp,I),comp), which is quicker to compute*/
144 extractlines1(Mat,lines,templine):=
145 block([tempresult,temprest],
146 if equal(lines,[]) then [[],Mat]
147 elseif equal(first(lines),templine) then
148 ([tempresult,temprest] : extractlines1(rest(Mat,1),rest(lines,1),templine+1),
149 [append([first(Mat)],tempresult),temprest]
152 ([tempresult,temprest] : extractlines1(rest(Mat,1),lines,templine+1),
153 [tempresult,append([first(Mat)],temprest)]
157 extractlines(Mat,lines):=extractlines1(Mat,lines,1);
159 extractcolumns(Mat,columns):=
160 block([tempresult,temprest,columnsfirstrow,restfirstrow],
161 if equal(Mat,[]) then [[],[]]
163 ([tempresult,temprest] : extractcolumns(rest(Mat,1),columns),
164 [columnsfirstrow,restfirstrow] : extractlines(first(Mat),columns),
165 [append([columnsfirstrow],tempresult),append([restfirstrow],temprest)]
169 assemblevector1(partnb1,partnb2,indexpartnb1,tempindex):=
170 if equal(indexpartnb1,[]) then partnb2
171 elseif equal(tempindex,first(indexpartnb1)) then
172 append([first(partnb1)],assemblevector1(rest(partnb1,1),partnb2,rest(indexpartnb1,1),tempindex+1))
173 else append([first(partnb2)],assemblevector1(partnb1,rest(partnb2,1),indexpartnb1,tempindex+1)) ;
175 assemblevector(partnb1,partnb2,indexpartnb1):=assemblevector1(partnb1,partnb2,indexpartnb1,1);
177 extractinfo1(revInfo,tempindex):=
178 block([l0,l1,ls,l0Uls,InfoXi,InfoXiprime,card0,cards],
179 if equal(revInfo,[]) or equal(first(revInfo),[]) then [[],[],[],[],[],[],0,0]
180 elseif first(first(revInfo))=s then
181 ([l0,l1,ls,l0Uls,InfoXi,InfoXiprime,card0,cards] : extractinfo1(rest(revInfo,1),tempindex+1),
182 [l0,l1,append([tempindex],ls),append([tempindex],l0Uls),append([rest(first(revInfo),1)],InfoXi),InfoXiprime,card0,cards+1]
184 elseif equal(first(first(revInfo)),0) then
185 ([l0,l1,ls,l0Uls,InfoXi,InfoXiprime,card0,cards] : extractinfo1(rest(revInfo,1),tempindex+1),
186 [append([tempindex],l0),l1,ls,append([tempindex],l0Uls),append([rest(first(revInfo),1)],InfoXi),InfoXiprime,card0+1,cards]
189 ([l0,l1,ls,l0Uls,InfoXi,InfoXiprime,card0,cards] : extractinfo1(rest(revInfo,1),tempindex+1),
190 [l0,append([tempindex],l1),ls,l0Uls,InfoXi,append([rest(first(revInfo),1)],InfoXiprime),card0,cards]
194 extractinfo(revInfo):=extractinfo1(revInfo,1);
198 else append([first(v)-first(w)],substract(rest(v,1),rest(w,1))) ;
200 assemble1(cl0,cl1,cls,temprow,templ_0,templ_1,templ_s):=
202 if notequal(templ_0,[]) and equal(first(templ_0),temprow) then
203 (append([first(cl0)],assemble1(rest(cl0,1),cl1,cls,temprow+1,rest(templ_0,1),templ_1,templ_s))
205 elseif notequal(templ_s,[]) and equal(first(templ_s),temprow) then
206 (append([first(cls)],assemble1(cl0,cl1,rest(cls,1),temprow+1,templ_0,templ_1,rest(templ_s,1)))
208 elseif notequal(templ_1,[]) then
209 (append([first(cl1)],assemble1(cl0,rest(cl1,1),cls,temprow+1,templ_0,rest(templ_1,1),templ_s))
214 assemble(cl0,cl1,cls,templ_0,templ_1,templ_s):=assemble1(cl0,cl1,cls,1,templ_0,templ_1,templ_s);
216 linear_solving(Mat,I,revInfo,v):=
217 block([l0,l1,ls,l0Uls,InfoXi,InfoXiprime,card0,cards,A,B,MatXi,M12,M21,MatXiprime,tl,M,w,tl1,cl0,cl1,cls],
220 ([l0,l1,ls,l0Uls,InfoXi,InfoXiprime,card0,cards] : extractinfo(revInfo),
221 [A,B] : extractlines(Mat,l0Uls),
222 [MatXi,M12] : extractcolumns(A,l0Uls),
223 [M21,MatXiprime] : extractcolumns(B,l0Uls),
224 tl : linear_solving(MatXi,rest(I,1),InfoXi,first(extractlines(v,l0Uls))),
225 if equal(ls,[]) then (tl1 : first(extractlines(v,l1)) )
227 (M : Matrixcomp(M21,ls,l0Uls),
228 w : evaluation(M,rowcompression(tl,ls,l0Uls)),
229 tl1 : substract(first(extractlines(v,l1)),w)
231 cl1 : linear_solving(MatXiprime,rest(I,1),InfoXiprime,tl1),
232 cl0 : substract(rowcompression(tl,l0,l0Uls),cl1),
233 cls : rowcompression(tl,ls,l0Uls),
234 assemble(cl0,cl1,cls,l0,l1,ls)
238 /* We are now going to build the inversibility-query */
240 /* In the next function, we suppose that second(gcdfreepartmethod(p,q)) gives the gcd free part of p with respect to q, as the function gcdFreePart (for example) does */
241 keepsimpleroots(P,var,gcdfreepartmethod):=second(gcdfreepartmethod(P,diff(P,var,1),var));
243 gcd1(P,Q,var):=first(gcdFreePart(P,Q,var));
245 gcdInvertibilityQuery(Q,P,var):=degree(expand(P),var)-degree(gcd1(expand(P),expand(diff(P,var,1)*Q),var),var);
247 polynomfamilymult(polylist,multiplyindex,I):=
248 if equal(multiplyindex,[]) then 1
249 elseif equal(first(multiplyindex),first(I)) then
250 first(polylist)*polynomfamilymult(rest(polylist,1),rest(multiplyindex,1),rest(I,1))
252 polynomfamilymult(rest(polylist,1),multiplyindex,rest(I,1))
255 AdaptedQuerylist(Ada,P,usefullpoly,comp,var,Qu):=
256 if equal(Ada,[]) then []
258 append([Qu(polynomfamilymult(usefullpoly,first(Ada),comp),P,var)],AdaptedQuerylist(rest(Ada,1),P,usefullpoly,comp,var,Qu));
260 addfirstcolumn(elem,Mat):=
261 if equal(Mat,[]) then
264 append([append([elem],first(Mat))],addfirstcolumn(elem,rest(Mat,1))) ;
267 if equal(Mat,[]) then []
269 append([append([0],first(Mat))],append([append([1],first(Mat))],add01to(rest(Mat,1))));
271 insert0atevenindex(v):=
272 if equal(v,[]) then []
274 append([first(v)],append([0],insert0atevenindex(rest(v,1))));
277 if equal(v,[]) then []
279 append([first(v)],append([first(v)],double(rest(v,1))));
281 createMatAuxSigma(Mat):=
282 if equal(Mat,[]) then []
284 append([insert0atevenindex(first(Mat))],append([double(first(Mat))],createMatAuxSigma(rest(Mat,1))));
286 alternateelemfrom(v,w):=
287 if equal(v,[]) then []
289 append([first(v)],alternateelemfrom(w,rest(v,1)));
291 computeCiSigmaiLi1(Auxc,AuxSigma,AuxCompSigma,temprow):=
292 if equal(AuxSigma,[]) then [[],[],[],[],[],[],[]]
294 (block([c,Sigma,CompSigma,l0,l1,ls,l]),
295 if notequal(first(Auxc),0) and notequal(second(Auxc),0) then
296 ([c,Sigma,CompSigma,l0,l1,ls,l] : computeCiSigmaiLi1(rest(Auxc,2),rest(AuxSigma,2),rest(AuxCompSigma,2),temprow+2),
297 [append([first(Auxc)],append([second(Auxc)],c)),append([first(AuxSigma)],append([second(AuxSigma)],Sigma)),append([first(AuxCompSigma)],append([second(AuxCompSigma)],CompSigma)),append([temprow],l0),append([temprow+1],l1),ls,append([temprow],l)]
299 elseif notequal(first(Auxc),0) then
300 ([c,Sigma,CompSigma,l0,l1,ls,l] : computeCiSigmaiLi1(rest(Auxc,2),rest(AuxSigma,2),rest(AuxCompSigma,2),temprow+1),
301 [append([first(Auxc)],c),append([first(AuxSigma)],Sigma),append([first(AuxCompSigma)],CompSigma),l0,l1,append([temprow],ls),append([temprow],l)]
304 ([c,Sigma,CompSigma,l0,l1,ls,l] : computeCiSigmaiLi1(rest(Auxc,2),rest(AuxSigma,2),rest(AuxCompSigma,2),temprow+1),
305 [append([second(Auxc)],c),append([second(AuxSigma)],Sigma),append([second(AuxCompSigma)],CompSigma),l0,l1,append([temprow],ls),append([temprow],l)]
309 computeCiSigmaiLi(Auxc,AuxSigma,AuxCompSigma,previouscompsigma):=
310 block([c,Sigma,CompSigma,l0,l1,ls,l],
311 [c,Sigma,CompSigma,l0,l1,ls,l] : computeCiSigmaiLi1(Auxc,AuxSigma,AuxCompSigma,1),
312 if notequal(l0,[]) then
313 [c,Sigma,CompSigma,l0,l1,ls,l]
314 else [c,Sigma,previouscompsigma,l0,l1,ls,l]
317 deletefirstcolumn(Mat):=
318 if equal(Mat,[]) then []
319 else append([rest(first(Mat),1)],deletefirstcolumn(rest(Mat,1)));
321 assembleAda_i1(previousAda,AdaXiprime_i,i,temprow,l0,l1,ls):=
322 if notequal(l0,[]) and equal(first(l0),temprow) then
323 append([first(previousAda)],assembleAda_i1(rest(previousAda,1),AdaXiprime_i,i,temprow+1,rest(l0,1),l1,ls))
324 elseif notequal(ls,[]) and equal(first(ls),temprow) then
325 append([first(previousAda)],assembleAda_i1(rest(previousAda,1),AdaXiprime_i,i,temprow+1,l0,l1,rest(ls,1)))
326 elseif notequal(l1,[]) and equal(first(l1),temprow) then
327 append([append([i],first(AdaXiprime_i))],assembleAda_i1(previousAda,rest(AdaXiprime_i,1),i,temprow+1,l0,rest(l1,1),ls))
330 assembleAda_i(previousAda,AdaXiprime_i,i,l0,l1,ls):=assembleAda_i1(previousAda,AdaXiprime_i,i,1,l0,l1,ls);
332 assembleQulist(AdaQulist,AdaQuPrime,l1,temprow):=
333 if equal(l1,[]) then AdaQulist
334 elseif equal(first(l1),temprow) then
335 append([first(AdaQuPrime)],assembleQulist(AdaQulist,rest(AdaQuPrime,1),rest(l1,1),temprow+1))
337 append([first(AdaQulist)],assembleQulist(rest(AdaQulist,1),AdaQuPrime,l1,temprow+1)) ;
340 if equal(l1,[]) then ls
341 elseif equal(ls,[]) then l1
342 elseif first(l1)<first(ls) then append([first(l1)],listunion(rest(l1,1),ls))
343 else append([first(ls)],listunion(l1,rest(ls))) ;
345 put0atposition(row,l0,tempposition):=
346 if equal(l0,[]) then row
347 elseif equal(first(l0),tempposition) then
348 append([0],put0atposition(row,rest(l0,1),tempposition+1))
350 append([first(row)],put0atposition(rest(row,1),l0,tempposition+1)) ;
352 put0atcolumn(Mat,l0):=
353 if equal(Mat,[]) then []
354 else append([put0atposition(first(Mat),l0,1)],put0atcolumn(rest(Mat,1),l0)) ;
356 extendrow(row,l0,ls):=
357 if equal(l0,[]) then row
358 elseif equal(ls,[]) then double(row)
359 elseif first(l0)<first(ls) then append([first(row),first(row)],extendrow(rest(row,1),rest(l0,1),ls))
360 else append([first(row)],extendrow(rest(row,1),l0,rest(ls,1))) ;
362 extendMat(Mat,l0,ls):=
363 if equal(Mat,[]) then []
364 else append([extendrow(first(Mat),l0,ls)],extendMat(rest(Mat,1),l0,ls));
367 quickZerononzeroDeterminationwithcardinals(polylist,P,Qu,var):=
368 block([r,Sigma_i,CompressedSigma_i,c_i,comp_i,Info_i,Ada_i,Mat_i,AdaQulist,i,temppolylist,usefullpoly,InvQu,cPidiffzero,vprime,AuxSigma,AuxSigma2,InfoAux,AuxMat,v,c,Xiprime_i,InfoXiprime_i,AdaXiprime_i,CompletedAdaXiprime_i,AdaQuPrime,M,N,R,Mat_i],
370 if equal(r,0) then [[],[]]
373 CompressedSigma_i : [[]],
381 temppolylist : polylist,
383 while notequal(temppolylist,[]) do
385 InvQu : Qu(first(temppolylist),P,var),
387 cPiequalzero : r-InvQu,
388 if equal(cPiequalzero,0) then
389 (Sigma_i : addfirstcolumn(1,Sigma_i)
391 elseif equal(cPidiffzero,0) then
392 (Sigma_i : addfirstcolumn(0,Sigma_i)
395 (vprime : AdaptedQuerylist(addfirstcolumn(i,Ada_i),P,append([first(temppolylist)],usefullpoly),append([i],comp_i),var,Qu),
396 AuxSigma : add01to(CompressedSigma_i),
397 AuxSigma2 : add01to(Sigma_i),
398 InfoAux : add01to(Info_i),
399 AuxMat : createMatAuxSigma(Mat_i),
400 v : alternateelemfrom(AdaQulist,vprime),
401 c : linear_solving(AuxMat,append([i],comp_i),InfoAux,v),
402 [c_i,Sigma_i,CompressedSigma_i,l0,l1,ls,l] : computeCiSigmaiLi(c,AuxSigma2,AuxSigma,CompressedSigma_i),
403 if equal(l0,[]) then (1=1)
405 (comp_i : append([i],comp_i),
406 usefullpoly : append([first(temppolylist)],usefullpoly),
407 Xiprime_i : first(extractlines(deletefirstcolumn(CompressedSigma_i),l1)),
408 InfoXiprime_i : revInfo(Xiprime_i,rest(comp_i)),
409 AdaXiprime_i : adapted_family(InfoXiprime_i,rest(comp_i)),
410 CompletedAdaXiprime_i : addfirstcolumn(i,AdaXiprime_i),
411 AdaQuPrime : AdaptedQuerylist(CompletedAdaXiprime_i,P,usefullpoly,comp_i,var,Qu),
412 AdaQulist : assembleQulist(AdaQulist,AdaQuPrime,l1,1),
413 Info_i : assembleInfo1(Info_i,InfoXiprime_i,1,l0,l1,ls),
414 Ada_i : assembleAda_i(Ada_i,AdaXiprime_i,i,l0,l1,ls),
415 M : Mat(CompletedAdaXiprime_i,first(extractlines(CompressedSigma_i,listunion(l1,ls))),comp_i),
416 N : put0atcolumn(M,l0),
417 R : extendMat(Mat_i,l0,ls),
418 Mat_i : assembleQulist(R,N,l1,1)
421 temppolylist : rest(temppolylist,1)
424 [c_i,Reverserows(Sigma_i)]
427 quickZerononzeroDetermination(polylist,P,Qu,var):=
428 second(quickZerononzeroDeterminationwithcardinals(polylist,P,Qu,var));
430 /* __________________________________________________________________________*/
432 deletefirstcolumn(Mat):=
433 if equal(Mat,[]) then []
434 else append([rest(first(Mat),1)],deletefirstcolumn(rest(Mat,1)));
436 extractfirstcolumn(Mat):=
437 if equal(Mat,[]) then []
438 else append([[first(first(Mat))]],extractfirstcolumn(rest(Mt,1)));
440 extractfirstcolumn2(Mat):=
441 if equal(Mat,[]) then [[],[]]
444 [result,left] : extractfirstcolumn2(rest(Mat,1)),
445 [append([[first(first(Mat))]],result),append([rest(first(Mat),1)],left)]
450 if equal(Mat2,[]) then Mat1
451 else append([append(first(Mat1),first(Mat2))],glu(rest(Mat1,1),rest(Mat2,1)));
453 firstcolumnisntusefull(Mat):=
454 if equal(Mat,[]) then true
455 elseif not(first(first(Mat))=s) then
458 firstcolumnisntusefull(rest(Mat,1));
460 compression(Info,Sigma,I):=
461 if equal(Info,[]) or equal(first(Info),[]) then [[],[],[]]
462 elseif firstcolumnisntusefull(Info) then
463 (compression(deletefirstcolumn(Info),deletefirstcolumn(Sigma),rest(I,1))
466 (block([CompInfo,CompSigma,comp,A,B,C,D],
467 [A,B] : extractfirstcolumn2(Info),
468 [C,D] : extractfirstcolumn2(Sigma),
469 [CompInfo,CompSigma,comp] : compression(B,D,rest(I,1)),
470 [glu(A,CompInfo),glu(C,CompSigma),append([first(I)],comp)]
474 extractInfoSign1(Info,temprow):=
475 if equal(Info,[]) then [[],[],[],[],[],[],[],[],[],[],[],[]]
477 block([lp1,lp2,lp3,l0,l01,l0m1,l1m1,ls,l1,l10,lm10,lm11],
478 [lp1,lp2,lp3,l0,l01,l0m1,l1m1,ls,l1,l10,lm10,lm11] : extractInfoSign1(rest(Info,1),temprow+1),
479 if first(first(Info))=0 then
480 [append([temprow],lp1),lp2,lp3,append([temprow],l0),l01,l0m1,l1m1,ls,l1,l10,lm10,lm11]
481 elseif first(first(Info))=e01 then
482 [append([temprow],lp1),lp2,lp3,l0,append([temprow],l01),l0m1,l1m1,ls,l1,l10,lm10,lm11]
483 elseif first(first(Info))=e0m1 then
484 [append([temprow],lp1),lp2,lp3,l0,l01,append([temprow],l0m1),l1m1,ls,l1,l10,lm10,lm11]
485 elseif first(first(Info))=e1m1 then
486 [append([temprow],lp1),lp2,lp3,l0,l01,l0m1,append([temprow],l1m1),ls,l1,l10,lm10,lm11]
487 elseif first(first(Info))=s then
488 [append([temprow],lp1),lp2,lp3,l0,l01,l0m1,l1m1,append([temprow],ls),l1,l10,lm10,lm11]
489 elseif first(first(Info))=1 then
490 [lp1,append([temprow],lp2),lp3,l0,l01,l0m1,l1m1,ls,append([temprow],l1),l10,lm10,lm11]
491 elseif first(first(Info))=e10 then
492 [lp1,append([temprow],lp2),lp3,l0,l01,l0m1,l1m1,ls,l1,append([temprow],l10),lm10,lm11]
493 elseif first(first(Info))=em10 then
494 [lp1,append([temprow],lp2),lp3,l0,l01,l0m1,l1m1,ls,l1,l10,append([temprow],lm10),lm11]
495 elseif first(first(Info))=em11 then
496 [lp1,append([temprow],lp2),lp3,l0,l01,l0m1,l1m1,ls,l1,l10,lm10,append([temprow],lm11)]
498 [lp1,lp2,append([temprow],lp3),l0,l01,l0m1,l1m1,ls,l1,l10,lm10,lm11]
501 extractInfoSign(Info):=extractInfoSign1(Info,1);
503 extractl1l2l3rows1(Mat,l1,l2,l3,templine):=
504 if equal(Mat,[]) then [[],[],[]]
507 if notequal(l1,[]) and equal(first(l1),templine) then
508 ([M1,M2,M3] : extractl1l2l3rows1(rest(Mat,1),rest(l1,1),l2,l3,templine+1),
509 [append([first(Mat)],M1),M2,M3]
511 elseif notequal(l2,[]) and equal(first(l2),templine) then
512 ([M1,M2,M3] : extractl1l2l3rows1(rest(Mat,1),l1,rest(l2,1),l3,templine+1),
513 [M1,append([first(Mat)],M2),M3]
516 ([M1,M2,M3] : extractl1l2l3rows1(rest(Mat,1),l1,l2,rest(l3,1),templine+1),
517 [M1,M2,append([first(Mat)],M3)]
521 extractl1l2l3rows(Mat,l1,l2,l3):=extractl1l2l3rows1(Mat,l1,l2,l3,1);
523 extractl1l2l3columns(Mat,l1,l2,l3):=
524 if equal(Mat,[]) then [[],[],[]]
527 [A,B,C] : extractl1l2l3rows(first(Mat),l1,l2,l3),
528 [D,E,F] : extractl1l2l3columns(rest(Mat),l1,l2,l3),
529 [append([A],D),append([B],E),append([C],F)]
532 add(alpha,v,beta,w):=
533 if equal(v,[]) then []
534 else append([alpha*first(v)+beta*first(w)],add(alpha,rest(v,1),beta,rest(w,1))) ;
536 multiplypartofvect(alpha,indexvect,indexpart,vect):=
537 if equal(indexpart,[]) then vect
538 elseif equal(first(indexpart),first(indexvect)) then
539 append([alpha*first(vect)],multiplypartofvect(alpha,rest(indexvect,1),rest(indexpart,1),rest(vect,1)))
541 append([first(vect)],multiplypartofvect(alpha,rest(indexvect,1),indexpart,rest(vect,1)));
543 listSigma2insideSigma1(lp1,ls):=
544 if equal(ls,[]) then lp1
545 elseif equal(first(lp1),first(ls)) then
546 listSigma2insideSigma1(rest(lp1,1),rest(ls,1))
548 append([first(lp1)],listSigma2insideSigma1(rest(lp1,1),ls)) ;
551 if equal(v,[]) then []
553 append([alpha*first(v)],mult(alpha,rest(v,1)));
555 sumvinsidew(alpha,v,listv,beta,w,listw):=
556 if equal(v,[]) then mult(beta,w)
557 elseif equal(first(listv),first(listw)) then
558 append([alpha*first(v)+beta*first(w)],sumvinsidew(alpha,rest(v,1),rest(listv,1),beta,rest(w,1),rest(listw,1)))
560 append([beta*first(w)],sumvinsidew(alpha,v,listv,beta,rest(w,1),rest(listw,1)));
562 put0atrows(vect,Index,rows):=
563 if equal(rows,[]) then vect
564 elseif equal(first(Index),first(rows)) then
565 append([0],put0atrows(rest(vect,1),rest(Index,1),rest(rows,1)))
567 append([first(vect)],put0atrows(rest(vect,1),rest(Index,1),rows))
570 put0atcolumns(Mat,Index,columns):=
571 if equal(Mat,[]) then []
573 append([put0atrows(first(Mat),Index,columns)],put0atcolumns(rest(Mat,1),Index,columns));
575 assemblec1(clp1,clp2,clp3,lp1,lp2,lp3,temprow):=
576 if equal(clp1,[]) and equal(clp2,[]) and equal(clp3,[]) then []
577 elseif notequal(lp1,[]) and equal(first(lp1),temprow) then
578 append([first(clp1)],assemblec1(rest(clp1,1),clp2,clp3,rest(lp1,1),lp2,lp3,temprow+1))
579 elseif notequal(lp2,[]) and equal(first(lp2),temprow) then
580 append([first(clp2)],assemblec1(clp1,rest(clp2,1),clp3,lp1,rest(lp2,1),lp3,temprow+1))
582 append([first(clp3)],assemblec1(clp1,clp2,rest(clp3,1),lp1,lp2,rest(lp3,1),temprow+1)) ;
584 assemblec(clp1,clp2,clp3,lp1,lp2,lp3):= assemblec1(clp1,clp2,clp3,lp1,lp2,lp3,1);
586 extractthelines(Mat,linesMat,extractedlines):=
587 if equal(extractedlines,[]) then [[],Mat]
588 else block([extr,restmat],
589 if equal(first(linesMat),first(extractedlines)) then
590 ([extr,restmat] : extractthelines(rest(Mat,1),rest(linesMat,1),rest(extractedlines,1)),
591 [append([first(Mat)],extr),restmat])
593 ([extr,restmat] : extractthelines(rest(Mat,1),rest(linesMat,1),extractedlines),
594 [extr,append([first(Mat)],restmat)])
597 Special_linear_solving(Sigma,Q,Info,Mat,v):=
598 if equal(Q,[]) then v
600 block([lp1,lp2,lp3,l0,l01,l0m1,l1m1,ls,l1,l10,lm10,lm11,M1,M2,M3,M11,M12,M13,M21,M22,M23,M31,M32,M33,A,B,C,D,Sigma1,Sigma2,Sigma3,restSigma1,restSigma2,restSigma3,Info1,Info2,Info3,restInfo1,restInfo2,restInfo3,vlp1,vlp2,vlp3,t1lp1,t1lp2,t1lp3,t2lp2,t2lp1,t2lp3,N32,CompInfo3,CompSigma3,Comp3,clp1,clp2,clp3, CompInfo2,CompSigma2,Comp2],
601 [lp1,lp2,lp3,l0,l01,l0m1,l1m1,ls,l1,l10,lm10,lm11] : extractInfoSign(Info),
602 [M1,M2,M3] : extractl1l2l3rows(Mat,lp1,lp2,lp3),
603 [M11,M12,M13] : extractl1l2l3columns(M1,lp1,lp2,lp3),
604 [M21,M22,M23] : extractl1l2l3columns(M2,lp1,lp2,lp3),
605 [M31,M32,M33] : extractl1l2l3columns(M3,lp1,lp2,lp3),
606 [A,B] : extractthelines(M12,lp1,ls),
607 [C,D] : extractthelines(M13,lp1,l0),
608 [Sigma1,Sigma2,Sigma3] : extractl1l2l3rows(Sigma,lp1,lp2,lp3),
609 [restSigma1,restSigma2,restSigma3] :[deletefirstcolumn(Sigma1),deletefirstcolumn(Sigma2),deletefirstcolumn(Sigma3)],
610 [Info1,Info2,Info3] : extractl1l2l3rows(Info,lp1,lp2,lp3),
611 [restInfo1,restInfo2,restInfo3] :[deletefirstcolumn(Info1),deletefirstcolumn(Info2),deletefirstcolumn(Info3)],
612 [vlp1,vlp2,vlp3] : extractl1l2l3rows(v,lp1,lp2,lp3),
613 t1lp1 : Special_linear_solving(restSigma1,rest(Q,1),restInfo1,M11,vlp1),
614 t1lp2 : add(-1,evaluation(M21,t1lp1),1,vlp2),
615 (if notequal(lp3,[]) then
616 t1lp3 : add(-1,evaluation(M31,t1lp1),1,vlp3)
619 [CompInfo2,CompSigma2,Comp2] : compression(restInfo2,restSigma2,rest(Q,1)),
620 t2lp2 : Special_linear_solving(CompSigma2,Comp2,CompInfo2,newMat(CompSigma2,CompInfo2),t1lp2),
621 t2lp2 : multiplypartofvect(-1,lp2,lm10,t2lp2),
622 t2lp2 : multiplypartofvect(-(1/2),lp2,lm11,t2lp2),
623 t2lp1 : sumvinsidew(-1,t2lp2,listSigma2insideSigma1(lp1,ls),1,t1lp1,lp1),
624 N32 : put0atcolumns(M32,lp2,lm11),
625 t2lp3 : add(-1,evaluation(N32,t2lp2),1,t1lp3),
626 if notequal(lp3,[]) then
627 ([CompInfo3,CompSigma3,Comp3] : compression(restInfo3,restSigma3,rest(Q,1)),
628 clp3 : mult(1/2,Special_linear_solving(CompSigma3,Comp3,CompInfo3,newMat(CompSigma3,CompInfo3),t2lp3)),
629 clp1 : sumvinsidew(-2,clp3,l0,1,t2lp1,lp1),
630 clp2 : sumvinsidew(1,clp3,l1,1,t2lp2,lp2)
637 assemblec(clp1,clp2,clp3,lp1,lp2,lp3)
640 extractSig1Sig2Sig3lp1lp2lp3firstcolumnInfo1(Sigma,temprow):=
641 block([size,R1,R2,R3,Sig1,Sig2,Sig3,lp1,lp2,lp3,firstcolumnInfo],
642 if equal(Sigma,[]) then size : 0
643 elseif equal(rest(Sigma,1),[]) then (size : 1 , R1 : first(Sigma))
644 elseif equal(rest(rest(Sigma,1),1),[]) then
645 (size :2, R1 : first(Sigma), R2 : second(Sigma))
651 if equal(size,0) or equal(first(Sigma),[]) then [[],[],[],[],[],[],[]]
652 elseif equal(size,1) or not(rest(R1,1)=rest(R2,1)) then
653 ([Sig1,Sig2,Sig3,lp1,lp2,lp3,firstcolumnInfo] : extractSig1Sig2Sig3lp1lp2lp3firstcolumnInfo1(rest(Sigma,1),temprow+1),
654 [append([rest(R1)],Sig1),Sig2,Sig3,append([temprow],lp1),lp2,lp3,append([[s]],firstcolumnInfo)]
656 elseif equal(size,2) or not(rest(R2,1)=rest(R3,1)) then
657 ([Sig1,Sig2,Sig3,lp1,lp2,lp3,firstcolumnInfo] : extractSig1Sig2Sig3lp1lp2lp3firstcolumnInfo1(rest(Sigma,2),temprow+2),
658 if equal(first(R1),0) and equal(first(R2),1) then
659 [append([rest(R1)],Sig1),append([rest(R1)],Sig2),Sig3,append([temprow],lp1),append([temprow+1],lp2),lp3,append([[e01],[e10]],firstcolumnInfo)]
660 elseif equal(first(R1),0) and equal(first(R2),-1) then
661 [append([rest(R1)],Sig1),append([rest(R1)],Sig2),Sig3,append([temprow],lp1),append([temprow+1],lp2),lp3,append([[e0m1],[em10]],firstcolumnInfo)]
663 [append([rest(R1)],Sig1),append([rest(R1)],Sig2),Sig3,append([temprow],lp1),append([temprow+1],lp2),lp3,append([[e1m1],[em11]],firstcolumnInfo)]
666 ([Sig1,Sig2,Sig3,lp1,lp2,lp3,firstcolumnInfo] : extractSig1Sig2Sig3lp1lp2lp3firstcolumnInfo1(rest(Sigma,3),temprow+3),
667 [append([rest(R1)],Sig1),append([rest(R1)],Sig2),append([rest(R1)],Sig3),append([temprow],lp1),append([temprow+1],lp2),append([temprow+2],lp3),append([[0],[1],[m1]],firstcolumnInfo)]
672 newassembleInfo(Info1,Info2,Info3,lp1,lp2,lp3,firstcolumnInfo,temprow):=
673 if equal(Info1,[]) and equal(Info2,[]) and equal(Info3,[]) then firstcolumnInfo
674 elseif notequal(lp1,[]) and equal(first(lp1),temprow) then
677 append([append(first(firstcolumnInfo),first(Info1))],newassembleInfo(rest(Info1,1),Info2,Info3,rest(lp1,1),lp2,lp3,rest(firstcolumnInfo,1),temprow+1)) )
678 elseif notequal(lp2,[]) and equal(first(lp2),temprow) then
680 append([append(first(firstcolumnInfo),first(Info2))],newassembleInfo(Info1,rest(Info2,1),Info3,lp1,rest(lp2,1),lp3,rest(firstcolumnInfo,1),temprow+1))
684 append([append(first(firstcolumnInfo),first(Info3))],newassembleInfo(Info1,Info2,rest(Info3,1),lp1,lp2,rest(lp3,1),rest(firstcolumnInfo,1),temprow+1)) ) ;
689 if equal(Sigma,[]) or equal(first(Sigma),[]) then Sigma
691 block([Sig1,Sig2,Sig3,lp1,lp2,lp3,firstcolumnInfo,Info1,Info2,Info3],
692 [Sig1,Sig2,Sig3,lp1,lp2,lp3,firstcolumnInfo] : extractSig1Sig2Sig3lp1lp2lp3firstcolumnInfo1(Sigma,1),
693 Info1 : newInfo(Sig1),
694 Info2 : newInfo(Sig2),
695 Info3 : newInfo(Sig3),
696 newassembleInfo(Info1,Info2,Info3,lp1,lp2,lp3,firstcolumnInfo,1)
699 newAdarow(temppolylist,rowInfo):=
700 if equal(temppolylist,[]) then 1
703 P : newAdarow(rest(temppolylist,1),rest(rowInfo,1)),
704 if first(rowInfo)=1 or first(rowInfo)=e10 or first(rowInfo)=em10 or first(rowInfo)=em11 then
705 first(temppolylist)*P
706 elseif first(rowInfo)=m1 then
707 first(temppolylist)^2*P
711 newAda(Info,polylist):=
712 if equal(Info,[]) then []
713 else append([newAdarow(polylist,first(Info))],newAda(rest(Info,1),polylist));
716 if equal(v,[]) then []
717 else append([[first(v)]],makecolumn(rest(v,1)));
719 newfirstcolumn(v,Mat):=
720 if equal(Mat,[]) then makecolumn(v)
721 else append([append([first(v)],first(Mat))],newfirstcolumn(rest(v,1),rest(Mat,1)));
724 if equal(Sigma,[]) then []
725 else newfirstcolumn(newAda(Info,first(Sigma)),newMat(rest(Sigma,1),Info)) ;
726 multlistby(list,elem) :=
727 if equal(list,[]) then []
728 else append([elem*first(list)],multlistby(rest(list,1),elem));
730 Tarskiquerylist(P,polylist,TaQu,var):=
731 if equal(polylist,[]) then []
733 append([TaQu(first(polylist),P,var)],Tarskiquerylist(P,rest(polylist,1),TaQu,var)) ;
736 if equal(row,[]) then []
737 else append([first(row),first(row),first(row)],rowNewAuxMat1(rest(row,1)));
740 if equal(row,[]) then []
741 else append([0,first(row),-first(row)],rowNewAuxMat2(rest(row,1)));
744 if equal(row,[]) then []
745 else append([0,first(row),first(row)],rowNewAuxMat3(rest(row,1)));
748 if equal(oldMat,[]) then []
749 else append([rowNewAuxMat1(first(oldMat)),rowNewAuxMat2(first(oldMat)),rowNewAuxMat3(first(oldMat))],NewAuxMat(rest(oldMat,1))) ;
751 createvector(v1,v2,v3):=
752 if equal(v1,[]) then []
753 else append([first(v1),first(v2),first(v3)],createvector(rest(v1,1),rest(v2,1),rest(v3,1)));
755 makeauxSigma(Sigma):=
756 if equal(Sigma,[]) then []
758 append([append([0],first(Sigma)),append([1],first(Sigma)),append([-1],first(Sigma))],makeauxSigma(rest(Sigma,1))) ;
760 makenewSigma(c,AuxSigma,AuxCompSigma,temprow):=
761 if equal(c,[]) then [[],[],[],[],[],[],[],[],[],[],[],[],[],[]]
763 block([tempc,tempSigma,tempSigma1,tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3],
764 if notequal(first(c),0) and notequal(second(c),0) and notequal(third(c),0) then
765 ([tempc,tempSigma,tempCompSigma,tempSigma1,tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] :
766 makenewSigma(rest(c,3),rest(AuxSigma,3),rest(AuxCompSigma,3),temprow+3),
767 [append([first(c),second(c),third(c)],tempc),append([first(AuxSigma),second(AuxSigma),third(AuxSigma)],tempSigma),append([first(AuxCompSigma),second(AuxCompSigma),third(AuxCompSigma)],tempCompSigma),append([first(AuxCompSigma)],tempSigma1),append([second(AuxCompSigma)],tempSigma2),append([third(AuxCompSigma)],tempSigma3),append([temprow],l0),l01,l0m1,l1m1,ls,append([temprow],lp1),append([temprow+1],lp2),append([temprow+2],lp3)] )
768 elseif notequal(first(c),0) and notequal(second(c),0) then
769 ([tempc,tempSigma,tempCompSigma,tempSigma1,tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] :
770 makenewSigma(rest(c,3),rest(AuxSigma,3),rest(AuxCompSigma,3),temprow+2),
771 [append([first(c),second(c)],tempc),append([first(AuxSigma),second(AuxSigma)],tempSigma),append([first(AuxCompSigma),second(AuxCompSigma)],tempCompSigma),append([first(AuxCompSigma)],tempSigma1),append([second(AuxCompSigma)],tempSigma2),tempSigma3,l0,append([temprow],l01),l0m1,l1m1,ls,append([temprow],lp1),append([temprow+1],lp2),lp3])
772 elseif notequal(first(c),0) and notequal(third(c),0) then
773 ([tempc,tempSigma,tempCompSigma,tempSigma1,tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] :
774 makenewSigma(rest(c,3),rest(AuxSigma,3),rest(AuxCompSigma,3),temprow+2),
775 [append([first(c),third(c)],tempc),append([first(AuxSigma),third(AuxSigma)],tempSigma),append([first(AuxCompSigma),third(AuxCompSigma)],tempCompSigma),append([first(AuxCompSigma)],tempSigma1),append([third(AuxCompSigma)],tempSigma2),tempSigma3,l0,l01,append([temprow],l0m1),l1m1,ls,append([temprow],lp1),append([temprow+1],lp2),lp3])
776 elseif notequal(second(c),0) and notequal(third(c),0) then
777 ([tempc,tempSigma,tempCompSigma,tempSigma1,tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] :
778 makenewSigma(rest(c,3),rest(AuxSigma,3),rest(AuxCompSigma,3),temprow+2),
779 [append([second(c),third(c)],tempc),append([second(AuxSigma),third(AuxSigma)],tempSigma),append([second(AuxCompSigma),third(AuxCompSigma)],tempCompSigma),append([second(AuxCompSigma)],tempSigma1),append([third(AuxCompSigma)],tempSigma2),tempSigma3,l0,l01,l0m1,append([temprow],l1m1),ls,append([temprow],lp1),append([temprow+1],lp2),lp3])
780 elseif notequal(first(c),0) then
781 ([tempc,tempSigma,tempCompSigma,tempSigma1,tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] :
782 makenewSigma(rest(c,3),rest(AuxSigma,3),rest(AuxCompSigma,3),temprow+1),
783 [append([first(c)],tempc),append([first(AuxSigma)],tempSigma),append([first(AuxCompSigma)],tempCompSigma),append([first(AuxCompSigma)],tempSigma1),tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,append([temprow],ls),append([temprow],lp1),lp2,lp3])
784 elseif notequal(second(c),0) then
785 ([tempc,tempSigma,tempCompSigma,tempSigma1,tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] :
786 makenewSigma(rest(c,3),rest(AuxSigma,3),rest(AuxCompSigma,3),temprow+1),
787 [append([second(c)],tempc),append([second(AuxSigma)],tempSigma),append([second(AuxCompSigma)],tempCompSigma),append([second(AuxCompSigma)],tempSigma1),tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,append([temprow],ls),append([temprow],lp1),lp2,lp3])
789 ([tempc,tempSigma,tempCompSigma,tempSigma1,tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] :
790 makenewSigma(rest(c,3),rest(AuxSigma,3),rest(AuxCompSigma,3),temprow+1),
791 [append([third(c)],tempc),append([third(AuxSigma)],tempSigma),append([third(AuxCompSigma)],tempCompSigma),append([third(AuxCompSigma)],tempSigma1),tempSigma2,tempSigma3,l0,l01,l0m1,l1m1,append([temprow],ls),append([temprow],lp1),lp2,lp3])
794 rowpart1ofNewMat(rowoldMat,l0,l01,l0m1,l1m1,ls,tempplace):=
795 if equal(rowoldMat,[]) then []
796 elseif notequal(l0,[]) and equal(tempplace,first(l0)) then
797 append([first(rowoldMat),first(rowoldMat),first(rowoldMat)],rowpart1ofNewMat(rest(rowoldMat,1),rest(l0,1),l01,l0m1,l1m1,ls,tempplace+3))
798 elseif notequal(l01,[]) and equal(tempplace,first(l01)) then
799 append([first(rowoldMat),first(rowoldMat)],rowpart1ofNewMat(rest(rowoldMat,1),l0,rest(l01,1),l0m1,l1m1,ls,tempplace+2))
800 elseif notequal(l0m1,[]) and equal(tempplace,first(l0m1)) then
801 append([first(rowoldMat),first(rowoldMat)],rowpart1ofNewMat(rest(rowoldMat,1),l0,l01,rest(l0m1,1),l1m1,ls,tempplace+2))
802 elseif notequal(l1m1,[]) and equal(tempplace,first(l1m1)) then
803 append([first(rowoldMat),first(rowoldMat)],rowpart1ofNewMat(rest(rowoldMat,1),l0,l01,l0m1,rest(l1m1,1),ls,tempplace+2))
804 elseif notequal(rowoldMat,[]) then
805 append([first(rowoldMat)],rowpart1ofNewMat(rest(rowoldMat,1),l0,l01,l0m1,l1m1,rest(ls,1),tempplace+1))
808 part1ofNewMat(oldMat,l0,l01,l0m1,l1m1,ls):=
809 if equal(oldMat,[]) then []
810 else append([rowpart1ofNewMat(first(oldMat),l0,l01,l0m1,l1m1,ls,1)],part1ofNewMat(rest(oldMat,1),l0,l01,l0m1,l1m1,ls));
812 assembletwoparts(part1,part2,lp1,lp2):=
813 if equal(lp2,[]) then part1
814 elseif equal(lp1,[]) then part2
815 elseif first(lp1)<first(lp2) then
816 append([first(part1)],assembletwoparts(rest(part1,1),part2,rest(lp1,1),lp2))
818 append([first(part2)],assembletwoparts(part1,rest(part2,1),lp1,rest(lp2,1)))
821 assemblethreeparts(part1,part2,part3,lp1,lp2,lp3):=
822 if equal(lp2,[]) and equal(lp3,[]) then part1
823 elseif equal(lp2,[]) then append(part3,part1)
824 elseif equal(lp3,[]) then assembletwoparts(part1,part2,lp1,lp2)
825 elseif equal(lp1,[]) then append(part2,part3)
826 elseif first(lp1)<first(lp2) and first(lp1)<first(lp3) then
827 append([first(part1)],assemblethreeparts(rest(part1,1),part2,part3,rest(lp1,1),lp2,lp3))
828 elseif first(lp2)<first(lp1) and first(lp2)<first(lp3) then
829 append([first(part2)],assemblethreeparts(part1,rest(part2,1),part3,lp1,rest(lp2,1),lp3))
831 append([first(part3)],assemblethreeparts(part1,part2,rest(part3),lp1,lp2,rest(lp3,1))) ;
833 createfirstcolumnInfomat(l0,l01,l0m1,l1m1,ls,temprow):=
834 if notequal(l0,[]) and equal(first(l0),temprow) then
835 append([0,1,m1],createfirstcolumnInfomat(rest(l0,1),l01,l0m1,l1m1,ls,temprow+3))
836 elseif notequal(l01,[]) and equal(first(l01),temprow) then
837 append([e01,e10],createfirstcolumnInfomat(l0,rest(l01,1),l0m1,l1m1,ls,temprow+2))
838 elseif notequal(l0m1,[]) and equal(first(l0m1),temprow) then
839 append([e0m1,em10],createfirstcolumnInfomat(l0,l01,rest(l0m1,1),l1m1,ls,temprow+2))
840 elseif notequal(l1m1,[]) and equal(first(l1m1),temprow) then
841 append([e1m1,em11],createfirstcolumnInfomat(l0,l01,l0m1,rest(l1m1,1),ls,temprow+2))
842 elseif notequal(ls,[]) and equal(first(ls),temprow) then
843 append([s],createfirstcolumnInfomat(l0,l01,l0m1,l1m1,rest(ls),temprow+1))
848 createInformationmat(Info1,Info2,Info3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3):=
850 column : createfirstcolumnInfomat(l0,l01,l0m1,l1m1,ls,1),
851 M : assemblethreeparts(Info1,Info2,Info3,lp1,lp2,lp3),
852 newfirstcolumn(column,M)
855 addnewfirstcolumn(elem,Mat):=
856 if equal(Mat,[]) then []
857 else append([append([elem],first(Mat))],addnewfirstcolumn(elem,rest(Mat,1)));
861 rowpart2ofNewMat(rowoldMat,l0,l01,l0m1,l1m1,ls,tempplace,Sigma):=
862 if equal(rowoldMat,[]) then []
863 elseif notequal(l0,[]) and equal(tempplace,first(l0)) then
864 append([0,first(rowoldMat),-first(rowoldMat)],rowpart2ofNewMat(rest(rowoldMat,1),rest(l0,1),l01,l0m1,l1m1,ls,tempplace+3,rest(Sigma,3)))
865 elseif notequal(l01,[]) and equal(tempplace,first(l01)) then
866 append([0,first(rowoldMat)],rowpart2ofNewMat(rest(rowoldMat,1),l0,rest(l01,1),l0m1,l1m1,ls,tempplace+2,rest(Sigma,2)))
867 elseif notequal(l0m1,[]) and equal(tempplace,first(l0m1)) then
868 append([0,-first(rowoldMat)],rowpart2ofNewMat(rest(rowoldMat,1),l0,l01,rest(l0m1,1),l1m1,ls,tempplace+2,rest(Sigma,2)))
869 elseif notequal(l1m1,[]) and equal(tempplace,first(l1m1)) then
870 append([first(rowoldMat),-first(rowoldMat)],rowpart2ofNewMat(rest(rowoldMat,1),l0,l01,l0m1,rest(l1m1,1),ls,tempplace+2,rest(Sigma,2)))
871 elseif notequal(rowoldMat,[]) then
872 append([first(rowoldMat)*first(first(Sigma))],rowpart2ofNewMat(rest(rowoldMat,1),l0,l01,l0m1,l1m1,rest(ls,1),tempplace+1,rest(Sigma,1)))
875 part2ofNewMat(oldMat,l0,l01,l0m1,l1m1,ls,Sigma):=
876 if equal(oldMat,[]) then []
877 else append([rowpart2ofNewMat(first(oldMat),l0,l01,l0m1,l1m1,ls,1,Sigma)],part2ofNewMat(rest(oldMat,1),l0,l01,l0m1,l1m1,ls,Sigma));
879 rowpart3ofNewMat(rowoldMat,l0,l01,l0m1,l1m1,ls,tempplace,Sigma):=
880 if equal(rowoldMat,[]) then []
881 elseif notequal(l0,[]) and equal(tempplace,first(l0)) then
882 append([0,first(rowoldMat),first(rowoldMat)],rowpart3ofNewMat(rest(rowoldMat,1),rest(l0,1),l01,l0m1,l1m1,ls,tempplace+3,rest(Sigma,3)))
883 elseif notequal(l01,[]) and equal(tempplace,first(l01)) then
884 append([0,first(rowoldMat)],rowpart3ofNewMat(rest(rowoldMat,1),l0,rest(l01,1),l0m1,l1m1,ls,tempplace+2,rest(Sigma,2)))
885 elseif notequal(l0m1,[]) and equal(tempplace,first(l0m1)) then
886 append([0,first(rowoldMat)],rowpart3ofNewMat(rest(rowoldMat,1),l0,l01,rest(l0m1,1),l1m1,ls,tempplace+2,rest(Sigma,2)))
887 elseif notequal(l1m1,[]) and equal(tempplace,first(l1m1)) then
888 append([first(rowoldMat),first(rowoldMat)],rowpart3ofNewMat(rest(rowoldMat,1),l0,l01,l0m1,rest(l1m1,1),ls,tempplace+2,rest(Sigma,2)))
889 elseif notequal(rowoldMat,[]) then
890 append([first(rowoldMat)*(first(first(Sigma)))^2],rowpart2ofNewMat(rest(rowoldMat,1),l0,l01,l0m1,l1m1,rest(ls,1),tempplace+1,rest(Sigma,1)))
893 part3ofNewMat(oldMat,l0,l01,l0m1,l1m1,ls,Sigma):=
894 if equal(oldMat,[]) then []
895 else append([rowpart3ofNewMat(first(oldMat),l0,l01,l0m1,l1m1,ls,1,Sigma)],part3ofNewMat(rest(oldMat,1),l0,l01,l0m1,l1m1,ls,Sigma));
898 Special_linear_solvingstep1(Sigma,Q,Info,Mat,v,oldc):=
899 if equal(Q,[]) then v
901 block([lp1,lp2,lp3,l0,l01,l0m1,l1m1,ls,l1,l10,lm10,lm11,M1,M2,M3,M11,M12,M13,M21,M22,M23,M31,M32,M33,Sigma1,Sigma2,Sigma3,restSigma1,restSigma2,restSigma3,Info1,Info2,Info3,restInfo1,restInfo2,restInfo3,vlp1,vlp2,vlp3,t1lp1,t1lp2,t1lp3,t2lp2,t2lp1,t2lp3,N32,CompInfo3,CompSigma3,Comp3,clp1,clp2,clp3],
902 [lp1,lp2,lp3,l0,l01,l0m1,l1m1,ls,l1,l10,lm10,lm11] : extractInfoSign(Info),
903 [M1,M2,M3] : extractl1l2l3rows(Mat,lp1,lp2,lp3),
904 [M11,M12,M13] : extractl1l2l3columns(M1,lp1,lp2,lp3),
905 [M21,M22,M23] : extractl1l2l3columns(M2,lp1,lp2,lp3),
906 [M31,M32,M33] : extractl1l2l3columns(M3,lp1,lp2,lp3),
907 [Sigma1,Sigma2,Sigma3] : extractl1l2l3rows(Sigma,lp1,lp2,lp3),
908 [restSigma1,restSigma2,restSigma3] :[deletefirstcolumn(Sigma1),deletefirstcolumn(Sigma2),deletefirstcolumn(Sigma3)],
909 [Info1,Info2,Info3] : extractl1l2l3rows(Info,lp1,lp2,lp3),
910 [restInfo1,restInfo2,restInfo3] :[deletefirstcolumn(Info1),deletefirstcolumn(Info2),deletefirstcolumn(Info3)],
911 [vlp1,vlp2,vlp3] : extractl1l2l3rows(v,lp1,lp2,lp3),
913 t1lp2 : add(-1,evaluation(M21,t1lp1),1,vlp2),
914 (if notequal(lp3,[]) then
915 t1lp3 : add(-1,evaluation(M31,t1lp1),1,vlp3)
918 [CompInfo2,CompSigma2,Comp2] : compression(restInfo2,restSigma2,rest(Q,1)),
919 t2lp2 : Special_linear_solving(CompSigma2,Comp2,CompInfo2,newMat(CompSigma2,CompInfo2),t1lp2),
920 t2lp2 : multiplypartofvect(-1,lp2,lm10,t2lp2),
921 t2lp2 : multiplypartofvect(-(1/2),lp2,lm11,t2lp2),
922 t2lp1 : sumvinsidew(-1,t2lp2,listSigma2insideSigma1(lp1,ls),1,t1lp1,lp1),
923 N32 : put0atcolumns(M32,lp2,lm11),
924 t2lp3 : add(-1,evaluation(N32,t2lp2),1,t1lp3),
925 if notequal(lp3,[]) then
926 ([CompInfo3,CompSigma3,Comp3] : compression(restInfo3,restSigma3,rest(Q,1)),
927 clp3 : mult(1/2,Special_linear_solving(CompSigma3,Comp3,CompInfo3,newMat(CompSigma3,CompInfo3),t2lp3)),
928 clp1 : sumvinsidew(-2,clp3,l0,1,t2lp1,lp1),
929 clp2 : sumvinsidew(1,clp3,l1,1,t2lp2,lp2)
936 assemblec(clp1,clp2,clp3,lp1,lp2,lp3)
940 if equal(c,[]) then []
941 else append([0,first(c),second(c)],newc1m1(rest(c,2)));
944 if equal(c,[]) then []
945 else append([first(c),0,second(c)],newc0m1(rest(c,2)));
948 if equal(c,[]) then []
949 else append([first(c),second(c),0],newc01(rest(c,2)));
951 threepartvect(a,b,c):=
952 if equal(a,[]) then []
953 else append([first(a),first(b),first(c)],threepartvect(rest(a,1),rest(b,1),rest(c,1)));
955 Special_linear_solvingthreesigns(CompSigma,Q,Info,Mat,v0,v1,v2,c_i):=
956 block([tprime,t2prime,cl2,cl3,cl1],
957 tprime : Special_linear_solving(CompSigma,Q,Info,Mat,v1),
958 t2prime : Special_linear_solving(CompSigma,Q,Info,Mat,v2),
959 cl2 : add(1/2,tprime,1/2,t2prime),
960 cl3 : add(-1/2,tprime,1/2,t2prime),
961 cl1 : add(1,c_i,-1,t2prime),
962 threepartvect(cl1,cl2,cl3)
965 Special_linear_solving01(CompSigma,Q,Info,Mat,v0,v1,c_i):=
967 cl2 : Special_linear_solving(CompSigma,Q,Info,Mat,v1),
968 cl1 : add(1,c_i,-1,cl2),
972 Special_linear_solving0m1(CompSigma,Q,Info,Mat,v0,v1,c_i):=
974 cl2 : multlistby(Special_linear_solving(CompSigma,Q,Info,Mat,v1),-1),
975 cl1 : add(1,c_i,-1,cl2),
979 Special_linear_solving1m1(CompSigma,Q,Info,Mat,v0,v1,c_i):=
980 block([c2prime,cl1,cl2],
981 c2prime : Special_linear_solving(CompSigma,Q,Info,Mat,v1),
982 cl1 : add(1/2,c_i,1/2,c2prime),
983 cl2 : add(1/2,c_i,-1/2,c2prime),
987 quickSignDeterminationwithcardinals(polylist,P,TaQu,var):=
988 block([r,Sigma_i,CompressedSigma_i,c_i,comp_i,Info_i,Ada_i,Mat_i,AdaQulist,i,temppolylist,usefullpoly,cdet,cplus,cminus,czero,v1,v2,AuxCompSigma,AuxSigma,InfoAux,AuxMat,v,c,tempCompSigma,Sigma1,Sigma2,Sigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3,Info1,Info2,Info3,Ada1,Ada2,Ada3,TaQu1,TaQu2,TaQu3,Mat1,Mat2,Mat3, Mat2prime, Mat3prime],
990 if equal(r,0) then [[],[]]
993 CompressedSigma_i : [[]],
1001 temppolylist : polylist,
1003 while notequal(temppolylist,[]) do
1005 cdet : evaluation([[1/2,1/2],[-1/2,1/2]],[TaQu(first(temppolylist),P,var),TaQu((first(temppolylist))^2,P,var)]),
1006 [cplus,cminus] : cdet,
1007 czero : r-(cplus+cminus),
1008 if notequal(cplus,0) and notequal(cminus,0) and notequal(czero,0) then
1009 (v1 : Tarskiquerylist(P,multlistby(Ada_i,first(temppolylist)),TaQu,var),
1010 v2 : Tarskiquerylist(P,multlistby(Ada_i,(first(temppolylist))^2),TaQu,var),
1011 c :Special_linear_solvingthreesigns(CompressedSigma_i,comp_i,Info_i,Mat_i,AdaQulist,v1,v2,c_i),
1012 [c_i,Sigma_i,tempCompSigma,Sigma1,Sigma2,Sigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] : makenewSigma(c,makeauxSigma(Sigma_i),makeauxSigma(CompressedSigma_i),1) )
1013 elseif equal(cplus,0) and equal(cminus,0) then
1014 (Sigma_i : addnewfirstcolumn(0,Sigma_i),
1016 elseif equal(czero,0) and equal(cminus,0) then
1017 (Sigma_i : addnewfirstcolumn(1,Sigma_i),
1019 elseif equal(cplus,0) and equal(czero,0) then
1020 (Sigma_i : addnewfirstcolumn(-1,Sigma_i),
1022 elseif equal(czero,0) then
1023 (v1 : Tarskiquerylist(P,multlistby(Ada_i,first(temppolylist)),TaQu,var),
1024 c : Special_linear_solving1m1(CompressedSigma_i,comp_i,Info_i,Mat_i,AdaQulist,v1,c_i),
1026 [c_i,Sigma_i,tempCompSigma,Sigma1,Sigma2,Sigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] : makenewSigma(c,makeauxSigma(Sigma_i),makeauxSigma(CompressedSigma_i),1)
1028 elseif equal(cplus,0) then
1029 (v1 : Tarskiquerylist(P,multlistby(Ada_i,first(temppolylist)),TaQu,var),
1030 c : Special_linear_solving0m1(CompressedSigma_i,comp_i,Info_i,Mat,AdaQulist,v1,c_i),
1032 [c_i,Sigma_i,tempCompSigma,Sigma1,Sigma2,Sigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] : makenewSigma(c,makeauxSigma(Sigma_i),makeauxSigma(CompressedSigma_i),1)
1035 (v1 : Tarskiquerylist(P,multlistby(Ada_i,first(temppolylist)),TaQu,var),
1036 c : Special_linear_solving01(CompressedSigma_i,comp_i,Info_i,Mat_i,AdaQulist,v1,c_i),
1038 [c_i,Sigma_i,tempCompSigma,Sigma1,Sigma2,Sigma3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3] : makenewSigma(c,makeauxSigma(Sigma_i),makeauxSigma(CompressedSigma_i),1)
1040 if equal(lp2,[]) then (1=1)
1042 (CompressedSigma_i : tempCompSigma,
1043 comp_i : append([i],comp_i),
1044 usefullpoly : append([first(temppolylist)],usefullpoly),
1046 Info2 : newInfo(deletefirstcolumn(Sigma2)),
1047 Info3 : newInfo(deletefirstcolumn(Sigma3)),
1048 Info_i : createInformationmat(Info1,Info2,Info3,l0,l01,l0m1,l1m1,ls,lp1,lp2,lp3),
1049 Mat1 : part1ofNewMat(Mat_i,l0,l01,l0m1,l1m1,ls),
1050 Mat2prime : newMat(deletefirstcolumn(Sigma1),Info2),
1051 Mat2 : part2ofNewMat(Mat2prime,l0,l01,l0m1,l1m1,ls,CompressedSigma_i),
1052 Mat3prime : newMat(deletefirstcolumn(Sigma1),Info3),
1053 Mat3 : part3ofNewMat(Mat3prime,l0,l01,l0m1,l1m1,ls,CompressedSigma_i),
1054 Mat_i : assemblethreeparts(Mat1,Mat2,Mat3,lp1,lp2,lp3),
1055 Info2 : addnewfirstcolumn(1,Info2),
1056 Info3 : addnewfirstcolumn(m1,Info3),
1058 Ada2 : newAda(Info2,usefullpoly),
1059 Ada3 : newAda(Info3,usefullpoly),
1060 Ada_i : assemblethreeparts(Ada1,Ada2,Ada3,lp1,lp2,lp3),
1062 TaQu2 : Tarskiquerylist(P,Ada2,TaQu,var),
1063 TaQu3 : Tarskiquerylist(P,Ada3,TaQu,var),
1064 AdaQulist : assemblethreeparts(TaQu1,TaQu2,TaQu3,lp1,lp2,lp3)
1068 temppolylist : rest(temppolylist,1)
1070 [c_i,Reverserows(Sigma_i)]
1075 quickSignDetermination(polylist,P,TaQu,var):=
1076 second(quickSignDeterminationwithcardinals(polylist,P,TaQu,var));