Skip to content

Commit

Permalink
transversals working better, still trailing 1s in GCExpressions...
Browse files Browse the repository at this point in the history
  • Loading branch information
timduff35 committed Jun 3, 2024
1 parent 1a56d85 commit 7115d85
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 21 deletions.
46 changes: 33 additions & 13 deletions Brackets/Brackets.m2
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ AbstractGCRing Array := (G, A) -> (
-- class declaration for BracketRing
BracketRing = new Type of AbstractGCRing
-- constructor
bracketRing = method(Options => {Strategy => GroebnerBasis,CoefficientRing => QQ})
bracketRing = method(Options => {Strategy => GroebnerBasis,CoefficientRing => QQ,Variables=>{}})
bracketRing AbstractGCRing := G -> error "not implemented"
bracketRing (VisibleList, ZZ) := o -> (vectorSymbols, d) -> (
n := length vectorSymbols;
if not (n >= d) then error("The first argument n in bracketRing(n, d) (representing the number of rows) is assumed to be at least the second argument d (representing the number of columns)");
x := symbol x;
R := o.CoefficientRing[x_(1,1)..x_(n,d)];
X := matrix for i from 1 to n list for j from 1 to d list x_(i,j);
n'choose'd := rsort(sort \ subsets(vectorSymbols, d)); -- important for "Tableux order"
n'choose'd'Indices := rsort(sort \ subsets(#vectorSymbols, d));
minorsX := apply(n'choose'd'Indices, R -> det X^R);
nBrackets := rsort(sort \ subsets(vectorSymbols, d)); -- important for "Tableux order"
bracketIndices := rsort(sort \ subsets(#vectorSymbols, d));
minorsX := apply(bracketIndices, R -> det X^R);
y := symbol y;
bracketVariables := apply(n'choose'd, S -> y_("["|fold(S, (a, b) -> toString(a)|toString(b))|"]"));
bracketVariables := apply(nBrackets, S -> y_("["|fold(S, (a, b) -> toString(a)|toString(b))|"]"));
S := o.CoefficientRing[gens R, bracketVariables, MonomialOrder => {Eliminate(numgens R), GRevLex}]; -- important for "Tableaux order"
lookupTable := new HashTable from apply(binomial(n, d), i -> increment n'choose'd'Indices#i => (gens S)#(numgens R+i));
lookupTable := new HashTable from apply(binomial(n, d), i -> increment bracketIndices#i => (gens S)#(numgens R+i));
I := ideal apply(minorsX, bracketVariables, (m, b) -> sub(m, S) - b_S);
ret := new BracketRing from {numrows => n, numcols => d, ring => S, ideal => I, table => lookupTable, cache => new CacheTable from {}};
if o#Strategy === GroebnerBasis then (
Expand Down Expand Up @@ -112,7 +112,7 @@ matrix BracketRing := o -> B -> transpose genericMatrix(ring B,numcols B, numrow

-- class declaration for GCAlgebra
GCAlgebra = new Type of AbstractGCRing
gc = method(Options => {Strategy => GroebnerBasis,CoefficientRing => QQ,Variables=>{}})
gc = method(Options => {Strategy => GroebnerBasis,CoefficientRing => QQ})
-- constructor
gc (VisibleList, ZZ) := o -> (vectorSymbols, d) -> (
n := # vectorSymbols;
Expand All @@ -122,9 +122,9 @@ gc (VisibleList, ZZ) := o -> (vectorSymbols, d) -> (
else error "incorrect input"
);
Bnd := bracketRing(toList vectorSymbols, d, Strategy => o.Strategy, CoefficientRing => o.CoefficientRing);
n'Choose'd'plus1 := subsets(n,d+1);
R := (ring Bnd)[o.Variables][vectorVariables, SkewCommutative => true];
S := R/(ideal apply(n'Choose'd'plus1, S -> product(S, s -> (vectorVariables#s)_R)));
nBrackets := subsets(n,d+1);
R := (ring Bnd)[vectorVariables, SkewCommutative => true];
S := R/(ideal apply(nBrackets, S -> product(S, s -> (vectorVariables#s)_R)));
new GCAlgebra from {bracketRing => Bnd, ring => S, "num_pts" => #vectorSymbols}
)

Expand Down Expand Up @@ -166,11 +166,20 @@ Array _ AbstractGCRing := (A, R) -> (
)

coefficients GCExpression := o -> a -> (
R1 := ring ring a;
G := ring a;
if instance(G, BracketRing) then (
R1 := ring G;
R2 := coefficientRing R1;
(m, c) := coefficients sub(a#RingElement, (coefficientRing R2)[gens R1][gens R2]);
(m, matrix(G, apply(flatten entries c, e -> {e_G})))
) else error "not implemented"
-*
R2 := coefficientRing R1;
R3 := coefficientRing R2;
if not isPolynomialRing R3 then error "expected GC ring with extra variables";
coefficients sub(a#RingElement, R3[gens R1, SkewCommutative=>true][gens R2])
(m, c) := flatten \ entries \ coefficients sub(a#RingElement, R3[gens R1, SkewCommutative=>true][gens R2]);
(m, c)
*-
)

bracketRing GCExpression := o -> b -> bracketRing ring b
Expand Down Expand Up @@ -199,7 +208,7 @@ GCExpression * GCExpression := (b1, b2) -> (
b := b1#RingElement * b2#RingElement;
bR := b_R;
bRTerms := terms bR;
if (instance(R, GCAlgebra) and (all(bRTerms, isTopDegree) or all(bRTerms, isBottomDegree))) then sum(bRTerms, t -> t_(bracketRing R)) else bR
if (instance(R, GCAlgebra) and (all(bRTerms, t -> (isTopDegree t or isBottomDegree t)))) then sum(bRTerms, t -> t_(bracketRing R)) else bR
)
GCExpression - GCExpression := (b1, b2) -> (
R := commonRing(b1, b2);
Expand Down Expand Up @@ -276,12 +285,19 @@ shuffleProduct = (A, B) -> (
)
)

GCExpression _ GCAlgebra := (b, G) -> (
if not instance(G, BracketRing) then ( -- else, see next function
if ring b === G then b else error "GCExpression belongs to a different ring"
)
)

GCExpression _ BracketRing := (b, B) -> (
assert(B === bracketRing b);
bBracket := if (isTopDegree b) then sum(terms b, bterm -> lift(extensorToBracket bterm, ring B)) else if (isBottomDegree b) then lift(b#RingElement, ring B) else error "must be an extensor of step 0 or d";
bBracket_B
)


GCExpression ^ GCExpression := (f, g) -> (
G := ring f;
assert(instance(G, GCAlgebra) and G === ring g);
Expand Down Expand Up @@ -342,6 +358,10 @@ RingElement * GCMatrix := (r, M) -> (
GCMatrix * RingElement := (M, r) -> (
new GCMatrix from {matrix => (r * M#matrix), bracketRing => M#bracketRing})

ring GCMatrix := M -> M#bracketRing

GCMatrix _ Sequence := (M, twoIndices) -> ((M#matrix)_twoIndices)_(ring M)

det GCMatrix := o -> M -> (det M#matrix)_(M#bracketRing)

GCExpression * GCMatrix := (e, M) -> (
Expand Down
19 changes: 11 additions & 8 deletions Brackets/Tim/transversals.m2
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ check "Brackets"

restart
needsPackage "Brackets"
debug Brackets
G = gc(toList(a..h),4,Variables=>{l,u})
pt = l*a + u * b--1 * a + 1 * b
(pt * c * d)_G ^ (e*f)
ell = ((pt * c * d)_G ^ (e*f)) * pt
formula = ell * (g * h)
coefficients formula
(m,c) = apply(coefficients bb_(bracketRing G)
G = gc(toList(a..h),4,CoefficientRing=>QQ[l,u])
ell1 = (a*b)_G
ell2 = (c*d)_G
ell3 = (e*f)_G
ell4 = (g*h)_G
pt = (l*a + u * b)_G
ell = ((pt * ell2) ^ ell3) * pt
formula = ell * ell3
-- for some reason, "c" still has floating 1s...
(m, c) = coefficients formula
disc = c_(2,0) * c_(0,0) - 4 * c_(1,0)

0 comments on commit 7115d85

Please sign in to comment.