restart
loadPackage "Dmodules"

-------------------------------------------------------------------------
-- Computation of the local cohomology CCs at the ideal
-- generated by the minors of 2x3 matrix of indeterminates
W =  QQ[x_1..x_6, a_1..a_6];
I = minors(2, matrix{{x_1, x_2, x_3}, {x_4, x_5, x_6}});
cc = {ideal W => 1};
B = populateCechComplexCC(I,cc)
scan(keys B, k->print (k=>B#k)) -- CCs of Cech complex BEFORE pruning
pruneCechComplexCC B 
scan(keys B, k->if #B#k>0 then print (k=>B#k)) -- ................... AFTER ........


W =  QQ[x_1..x_4, a_1..a_4];
I = minors(2, matrix{{x_1, x_2, x_3}, {x_2, x_3, x_4}});
cc = {ideal W => 1};
B = populateCechComplexCC(I,cc)
scan(keys B, k->print (k=>B#k)) -- CCs of Cech complex BEFORE pruning                                                                 
pruneCechComplexCC B
scan(keys B, k->if #B#k>0 then print (k=>B#k)) -- ................... AFTER ........                                                  

-----------------------------------------------------------------------------
-- Lyubeznik numbers

CCH2 = B#{0,1} -- CC(H^2_I(R))
I = ideal (x_1..x_6)
ssets = (toList subsets set(0..5)) / sort@@toList; -- subsets of {0,...,5}
Dtrace 2
B = populateCechComplexCC(I,CCH2)
scan(keys B, k->print (k=>B#k))
pruneCechComplexCC B 
scan(keys B, k->if #B#k>0 then print (k=>B#k))

------------------------------------
-- Brianson-Maisonobe-Merle formula
S = QQ[x,y,z,a,b,c]
cc = BMM({ideal S=>1},x^3+y^3+z^3)

