
# Test ENRICHED W-polynomials of ALL LABELINGS of
# ALL (connected) posets for non-real zeros.
#
# There is no need to check both P and P-dual, but we
# cannot use complementation to eliminate labelings.
#
# Example: testall(8);

read allrealzeros;
read fastW;
read traverse;
read labelings;
read dualsquash;
read ideals;
read orbitsquash;
read `posets2.2.1v.txt`;

# Compute the enriched W-polynomial of a labeled poset P whose
# set of inverted covering edges is V, and test it for real zeros.

test:=proc(ct,P,n,V,ag,t,idls) local g;
  if orbitsquash(P,V,ag) then RETURN(ct) fi;
  g:=fastW(P,n,t,V,idls,'enriched');
#  lprint(P,V,g);
  if not allrealzeros(g,t) then print(`Counterexample:`,P,V) fi;
  ct+1
end;

# If P is connected and not squashed by its dual, compute the enriched
# W-polynomials of all labelings of P (up to isomorphism) and test them
# for non-real zeros. There are exponentially many labelings, so we can
# afford to amortize the cost of computing the automorphism group of P.

labtest:=proc(ct,P,down,n,t) local X,nl,idls,ag;
  if posets['connected'](P,n) and not dualsquash(P,n,'ag') then
    X:={$1..n}; idls:=ideals(down,X);
    nl:=labelings(P,X,0,{},{},test,ag,t,idls);
    RETURN([ct[1]+1,ct[2]+nl])
  fi;
  [ct[1]+1,ct[2]]
end;

# Test all W-polynomials on n points for non-real zeros.

testall:=proc(n) local st,res;
  st:=time(); printf(`\n`);
  res:=traverse(n,[0,0],labtest,t);
  if `+`(0)=0 then st:=time()-st,kernelopts(bytesalloc)
    else st:=time()-st,4*status[2] fi;
  printf(`all_lab_e  n=%-2d  tot=[%6d,%8d]  time=%10.2f  space=%7d\n`,
    n,op(res),st);
end;

