i1 : load "D-modules.m2"
i2 : D = QQ[x,y,z,Dx,Dy,Dz, WeylAlgebra => {x=>Dx, y=>Dy, z=>Dz}]

o2 = D

o2 : PolynomialRing
i3 : Delta = ideal(Dx,Dy,Dz)

o3 = ideal (Dx, Dy, Dz)

o3 : Ideal of D
i4 : (Dx * x)^2

      2  2
o4 = x Dx  + 3x*Dx + 1

o4 : D
i5 : options D

o5 = OptionTable{Adjust => identity                        }
                 Degrees => {{1}, {1}, {1}, {1}, {1}, {1}}
                 Inverses => false
                 MonomialOrder => GRevLex
                 MonomialSize => 8
                 NewMonomialOrder => 
                 Repair => identity
                 SkewCommutative => false
                 VariableBaseName => 
                 VariableOrder => 
                 Variables => {x, y, z, Dx, Dy, Dz}
                 Weights => {}
                 WeylAlgebra => {x => Dx, y => Dy, z => Dz}

o5 : OptionTable
i6 : DeltaBern = inw(Delta,{1,1,1,1,1,1}) 

o6 = ideal (Dz, Dy, Dx)

o6 : Ideal of QQ [x, y, z, Dx, Dy, Dz]
i7 : dim DeltaBern 

o7 = 3
i8 : D = QQ[x,y,z,w,Dx,Dy,Dz,Dw, 
            WeylAlgebra => {x=>Dx, y=>Dy, z=>Dz, w=>Dw}];
i9 : f = x^2+y^2+z^2+w^2

      2    2    2    2
o9 = x  + y  + z  + w

o9 : D
i10 : AnnFs(f)

                                                                                           1        1        1        1
o10 = ideal (w*Dz - z*Dw, w*Dy - y*Dw, z*Dy - y*Dz, w*Dx - x*Dw, z*Dx - x*Dz, y*Dx - x*Dy, -*x*Dx + -*y*Dy + -*z*Dz + -*w*Dw - $s)
                                                                                           2        2        2        2

o10 : Ideal of QQ [x, y, z, w, Dx, Dy, Dz, Dw, $s, WeylAlgebra => {x => Dx, y => Dy, z => Dz, w => Dw}]
i11 : L=ideal(x,y,Dz,Dw)

o11 = ideal (x, y, Dz, Dw)

o11 : Ideal of D
i12 : AnnIFs(L,f)

                                1        1
o12 = ideal (y, x, w*Dz - z*Dw, -*z*Dz + -*w*Dw - $s)
                                2        2

o12 : Ideal of QQ [x, y, z, w, Dx, Dy, Dz, Dw, $s, WeylAlgebra => {x => Dx, y => Dy, z => Dz, w => Dw}]
i13 : f

       2    2    2    2
o13 = x  + y  + z  + w

o13 : D
i14 : globalBFunction(f)

        2
o14 = $s  + 3$s + 2

o14 : QQ [$s]
i15 : g=x^3+y^3+z^3+w^3

       3    3    3    3
o15 = x  + y  + z  + w

o15 : D
i16 : factorBFunction globalBFunction(g)

                    7       8               4       5
o16 = ($s + 1)($s + -)($s + -)($s + 2)($s + -)($s + -)
                    3       3               3       3

o16 : Product
i17 : D1 = QQ[x,Dx,WeylAlgebra => {x=>Dx}];
i18 : I1 = ideal((x*Dx)^2+1)

             2  2
o18 = ideal(x Dx  + x*Dx + 1)

o18 : Ideal of D1
i19 : f1 = x;
i20 : b=globalB(I1, f1)

                                   2
o20 = HashTable{Boperator => - x*Dx  + 2Dx*$s + Dx}
                                 2
                Bpolynomial => $s  + 2$s + 2

o20 : HashTable
i21 : use D

o21 = D

o21 : PolynomialRing
i22 : R = (D^1/ideal(Dx,Dy,Dz,Dw))

o22 = cokernel | Dx Dy Dz Dw |

                             1
o22 : D-module, quotient of D
i23 : ann2 = relations Dlocalize(R,f)

o23 = | wDz-zDw wDy-yDw zDy-yDz wDx-xDw zDx-xDz yDx-xDy xDx+yDy+zDz+wDw+4 x2Dw+y2Dw+z2Dw+w2Dw+4w x2Dz+y2Dz+z2Dz+zwDw+4z x2Dy+y2Dy+yzDz+ywDw+4y |

              1       10
o23 : Matrix D  <--- D
i24 : F = matrix{{f}}

o24 = | x2+y2+z2+w2 |

              1       1
o24 : Matrix D  <--- D
i25 : ann1 = gb modulo(F,ann2)

o25 = {2} | wDz-zDw wDy-yDw zDy-yDz Dx^2+Dy^2+Dz^2+Dw^2 wDx-xDw zDx-xDz yDx-xDy xDx+yDy+zDz+wDw+2 x2Dw+y2Dw+z2Dw+w2Dw+2w x2Dz+y2Dz+z2Dz+zwDw+2z x2Dy+y2Dy+yzDz+ywDw+2y |

o25 : GroebnerBasis
i26 : gb((ideal ann2) + (ideal F))

o26 = | w z y x |

o26 : GroebnerBasis
i27 : D = QQ[x,y,z,Dx,Dy,Dz, WeylAlgebra => {x=>Dx, y=>Dy, z=>Dz}];
i28 : Delta = ideal(Dx,Dy,Dz);

o28 : Ideal of D
i29 : f=x^3+y^3+z^3;
i30 : I1=DlocalizeAll(D^1/Delta,f,Strategy=>Oaku)

                                1        1        1             2      2     2      2     2      2
o30 = HashTable{annFS => ideal (-*x*Dx + -*y*Dy + -*z*Dz - $s, z Dy - y Dz, z Dx - x Dz, y Dx - x Dy)                                                                                                                                                                                                                                                                                           }
                                3        3        3
                                     2      5       4
                Bfunction => ($s + 1) ($s + -)($s + -)($s + 2)
                                            3       3
                              2       3         2       4      1   2  3  2    1   2  3  2    4  2  2  3    8           4    1   2  5    2     3         2     4      2     3         2     3         8        3      2     3      2     4    22     3      14     3      8        3    16     4    1   3  2   1   3  2    2   3  2    5   3     11   3     10   3      62   3    70   3   16   3
                Boperator => --*y*z*Dx Dy*Dz - --*y*z*Dy Dz + ---*z Dx Dz  - ---*z Dy Dz  - --*y Dy Dz  - ---*y*z*Dy*Dz  - ---*z Dz  + --*y*Dx Dy*$s - --*y*Dy $s + --*z*Dx Dz*$s + --*z*Dy Dz*$s + --*y*Dy*Dz $s + --*y*Dx Dy - --*y*Dy  + ---*z*Dx Dz + ---*z*Dy Dz - --*y*Dy*Dz  - ---*z*Dz  + --*Dx $s  + -*Dy $s  + --*Dz $s  + --*Dx $s + --*Dy $s + --*Dz $s + ---*Dx  + ---*Dy  + --*Dz
                             81                81             243            243            81            243              243         81              81           81              27              81              27           27         243           243           81            243         27          9          27          27         27         27         243       243       81
                GeneratorPower => -2
                LocMap => | x6+2x3y3+y6+2x3z3+2y3z3+z6 |
                LocModule => cokernel | 1/3xDx+1/3yDy+1/3zDz+2 z2Dy-y2Dz z2Dx-x2Dz y2Dx-x2Dy |

o30 : HashTable
i31 : I2=DlocalizeAll(D^1/Delta,f)

o31 = HashTable{GeneratorPower => -2                                                                                        }
                                          2        2      2       1
                IntegrateBfunction => ($s) ($s + 1) ($s + -)($s + -)
                                                          3       3
                LocMap => | x6+2x3y3+y6+2x3z3+2y3z3+z6 |
                LocModule => cokernel | xDx+yDy+zDz+6 z2Dy-y2Dz z2Dx-x2Dz y2Dx-x2Dy x3Dz+y3Dz+z3Dz+6z2 x3Dy+y3Dy+y2zDz+6y2 |

o31 : HashTable
i32 : I1.LocModule

o32 = cokernel | 1/3xDx+1/3yDy+1/3zDz+2 z2Dy-y2Dz z2Dx-x2Dz y2Dx-x2Dy |

                             1
o32 : D-module, quotient of D
i33 : D= QQ[x,y,z,u,v,w,Dx,Dy,Dz,Du,Dv,Dw, WeylAlgebra =>
                {x=>Dx, y=>Dy, z=>Dz, u=>Du, v=>Dv, w=>Dw}];
i34 : Delta=ideal(Dx,Dy,Dz,Du,Dv,Dw);

o34 : Ideal of D
i35 : R=D^1/Delta;
i36 : f=x*v-u*y;
i37 : g=x*w-u*z;
i38 : h=y*w-v*z;
i39 : Rf=DlocalizeAll(R,f,Strategy => Oaku)

o39 = HashTable{annFS => ideal (Dw, Dz, x*Du + y*Dv, y*Dy - u*Du, x*Dy + u*Dv, u*Dx + v*Dy, y*Dx + v*Du, x*Dx - v*Dv, u*Du + v*Dv - $s)}
                Bfunction => ($s + 1)($s + 2)
                Boperator => - Dy*Du + Dx*Dv
                GeneratorPower => -2
                LocMap => | y2u2-2xyuv+x2v2 |
                LocModule => cokernel | Dw Dz xDu+yDv yDy-uDu xDy+uDv uDx+vDy yDx+vDu xDx-vDv uDu+vDv+2 |

o39 : HashTable
i40 : Rfg=DlocalizeAll(Rf.LocModule,g, Strategy => Oaku)

                                                                                                                                                                                                                 2                                                                                                        2
o40 = HashTable{annFS => ideal (Dz*Dv - Dy*Dw, x*Du + y*Dv + z*Dw, z*Dz - u*Du - v*Dv - 2, x*Dz + u*Dw, y*Dy + z*Dz - u*Du, x*Dy + u*Dv, u*Dx + v*Dy + w*Dz, x*Dx - v*Dv - w*Dw, z*Dz + w*Dw - $s, u*Du*Dv + v*Dv  - z*Dy*Dw + 3Dv, y*Dx*Dv + v*Du*Dv + z*Dx*Dw + w*Du*Dw + Du, y*u*Dv - x*v*Dv - 2x, v*Dy*Du*Dv - v*Dx*Dv  + z*Dx*Dy*Dw + w*Dy*Du*Dw + Dy*Du - 2Dx*Dv)}
                Bfunction => ($s + 1)($s)
                Boperator => - Dz*Du + Dx*Dw
                GeneratorPower => -1
                LocMap => | -zu+xw |
                LocModule => cokernel | DzDv-DyDw xDu+yDv+zDw zDz-uDu-vDv-2 xDz+uDw yDy+zDz-uDu xDy+uDv uDx+vDy+wDz xDx-vDv-wDw zDz+wDw+1 uDuDv+vDv^2-zDyDw+3Dv yDxDv+vDuDv+zDxDw+wDuDw+Du yuDv-xvDv-2x vDyDuDv-vDxDv^2+zDxDyDw+wDyDuDw+DyDu-2DxDv |

o40 : HashTable
i41 : Rfgh=DlocalizeAll(Rfg.LocModule,h, Strategy => Oaku)

                                                                                                                                                                          2                                               2                2          2       2         2                          2                                                           2    2  2                          2                          2                   2       2                   2                       2                                                             2    2                       2                     2        2  2      2                                      2                       2   2   2                       2          2              2 2        2                         2                       2        2
o41 = HashTable{annFS => ideal (x*Du + y*Dv + z*Dw, z*Dz - u*Du - v*Dv - 2, y*Dy - u*Du - w*Dw - 1, u*Dx + v*Dy + w*Dz, x*Dx + y*Dy - w*Dw + 2, y*Dy + v*Dv - $s + 2, u*Du  - y*Dx*Dv - z*Dx*Dw + 3Du, x*v*Dy + x*w*Dz - u Du - 3u, v*Dy*Du  + w*Dz*Du  + y*Dx Dv + z*Dx Dw - Dx*Du, x*y*w*Dz - y*u Du - y*u*v*Dv - z*u*v*Dw + x*v*w*Dw - 3y*u + x*v, y*w*Dz*Du  + y Dx Dv + y*v*Dx*Du*Dv + y*z*Dx Dw + z*v*Dx*Du*Dw + v*w*Du Dw - y*Dx*Du - v*Du , y*z*u Du + y*z*u*v*Dv + y u*w*Dv - x*y*v*w*Dv + z u*v*Dw + y*z*u*w*Dw - x*z*v*w*Dw + 3y*z*u - x*z*v - 2x*y*w, y z*Dx Dv + y*z*v*Dx*Du*Dv + y w*Dx*Du*Dv + y*v*w*Du Dv + y*z Dx Dw + z v*Dx*Du*Dw + y*z*w*Dx*Du*Dw + z*v*w*Du Dw - y*z*Dx*Du - z*v*Du , y z*u Dv - x*y*z*u*v*Dv - x*y u*w*Dv + x y*v*w*Dv + y*z u Dw - x*z u*v*Dw - x*y*z*u*w*Dw + x z*v*w*Dw - 3x*y*z*u + x z*v + 2x y*w)}
                Bfunction => ($s - 1)($s + 1)
                Boperator => - Dz*Dv + Dy*Dw
                GeneratorPower => -1
                LocMap => | -zv+yw |
                LocModule => cokernel | xDu+yDv+zDw zDz-uDu-vDv-2 yDy-uDu-wDw-1 uDx+vDy+wDz xDx+yDy-wDw+2 yDy+vDv+3 uDu^2-yDxDv-zDxDw+3Du xvDy+xwDz-u2Du-3u vDyDu^2+wDzDu^2+yDx^2Dv+zDx^2Dw-DxDu xywDz-yu2Du-yuvDv-zuvDw+xvwDw-3yu+xv ywDzDu^2+y2Dx^2Dv+yvDxDuDv+yzDx^2Dw+zvDxDuDw+vwDu^2Dw-yDxDu-vDu^2 yzu2Du+yzuvDv+y2uwDv-xyvwDv+z2uvDw+yzuwDw-xzvwDw+3yzu-xzv-2xyw y2zDx^2Dv+yzvDxDuDv+y2wDxDuDv+yvwDu^2Dv+yz2Dx^2Dw+z2vDxDuDw+yzwDxDuDw+zvwDu^2Dw-yzDxDu-zvDu^2 y2zu2Dv-xyzuvDv-xy2uwDv+x2yvwDv+yz2u2Dw-xz2uvDw-xyzuwDw+x2zvwDw-3xyzu+x2zv+2x2yw |

o41 : HashTable
i42 : Rf.GeneratorPower

o42 = -2
i43 : Jfgh=ideal relations Rfgh.LocModule;

o43 : Ideal of D
i44 : JH3=Jfgh+ideal(f^2,g,h);

o44 : Ideal of D
i45 : JH3gb=gb JH3

o45 = | w z uDu+vDv+wDw+4 xDu+yDv+zDw yDy-uDu-wDw-1 xDy+uDv uDx+vDy+wDz yDx+vDu xDx-vDv-wDw-1 v2 uv yv u2 yu+xv xu y2 xy x2 xvDv+2x vDyDu+wDzDu-vDxDv-wDxDw-3Dx |

o45 : GroebnerBasis
i46 : testmTorsion = method();
i47 : testmTorsion Ideal := (L) -> (
           LL = ideal generators gb L;
           n = numgens (ring (LL)) // 2;
           LLL = ideal select(first entries gens LL, f->(
                     l = apply(listForm f, t->drop(t#0,n));
                     all(l, t->t==toList(n:0))       
                     ));
           if dim inw(LLL,toList(apply(1..2*n,t -> 1))) == n
           then true
           else false);
i48 : testmTorsion(JH3)

o48 = true
i49 : D=QQ[x,y,z,w,Dx,Dy,Dz,Dw,WeylAlgebra => {x=>Dx, y=>Dy, z=>Dz,
      w=>Dw}];
i50 : f=y^2-x*z;
i51 : g=z^2-y*w;
i52 : h=x*w-y*z;
i53 : Delta=ideal(Dx,Dy,Dz,Dw);

o53 : Ideal of D
i54 : R=D^1/Delta;
i55 : Rf=DlocalizeAll(R,f,Strategy => Oaku)  

                                                         1                    1
o55 = HashTable{annFS => ideal (Dw, x*Dy + 2y*Dz, y*Dx + -*z*Dy, x*Dx - z*Dz, -*y*Dy + z*Dz - $s)}
                                                         2                    2
                                   3
                Bfunction => ($s + -)($s + 1)
                                   2
                             1   2
                Boperator => -*Dy  - Dx*Dz
                             4
                GeneratorPower => -1
                LocMap => | y2-xz |
                LocModule => cokernel | Dw xDy+2yDz yDx+1/2zDy xDx-zDz 1/2yDy+zDz+1 |

o55 : HashTable
i56 : Rfg=DlocalizeAll(Rf.LocModule,g, Strategy => Oaku);
i57 : Rfgh=DlocalizeAll(Rfg.LocModule,h, Strategy => Oaku);
i58 : Ifgh=ideal relations Rfgh.LocModule;

o58 : Ideal of D
i59 : IH3=Ifgh+ideal(f,g,h);

o59 : Ideal of D
i60 : IH3gb=gb IH3

o60 = | 1 |

o60 : GroebnerBasis
i61 : findSocle = method();
i62 : findSocle(Ideal, RingElement):= (L,P) -> (
           createDpairs(ring(L));
           v=(ring L).dpairVars#0;
           myflag = true;
           while myflag do (
                w = apply(v,temp -> temp*P % L);
                if all(w,temp -> temp == 0) then myflag = false
                else (
                     p = position(w, temp -> temp != 0);
                     P = v#p * P;)
                );
           P);
i63 : D = ring JH3

o63 = D

o63 : PolynomialRing
i64 : findSocle(JH3,1_D)

o64 = x*v

o64 : D
i65 : findLength = method();
i66 : findLength Ideal := (I) -> (   
           l = 0;
           while I != ideal 1_(ring I) do (
                l = l + 1;
                s = findSocle(I,1_(ring I));
                I = I + ideal s;);
           l);
i67 : findLength JH3

o67 = 1
i68 : erase symbol x; erase symbol Dx;
i70 : D = QQ[x_1..x_5, Dx_1..Dx_5, WeylAlgebra =>
           apply(toList(1..5), i -> x_i => Dx_i)];
i71 : f = x_1^2 + x_2^2 + x_3^2 + x_4^2 +x_5^2;
i72 : g = x_1;
i73 : R = D^1/ideal(Dx_1,Dx_2,Dx_3,Dx_4,Dx_5);
i74 : Rf =DlocalizeAll(R,f,Strategy => Oaku);
i75 : Bf = Rf.Bfunction

            5
o75 = ($s + -)($s + 1)
            2

o75 : Product
i76 : Rfg = DlocalizeAll(Rf.LocModule,g,Strategy => Oaku);
i77 : Bfg = Rfg.Bfunction

o77 = ($s + 1)($s + 3)

o77 : Product
i78 : Rg = DlocalizeAll(R,g,Strategy => Oaku);
i79 : Bg = Rg.Bfunction

o79 = ($s + 1)

o79 : Product
i80 : Rgf = DlocalizeAll(Rg.LocModule,f,Strategy => Oaku);
i81 : Bgf = Rgf.Bfunction

                            5
o81 = ($s + 2)($s + 1)($s + -)
                            2

o81 : Product
i82 : erase symbol x;
i83 : R = QQ[x,y,z];
i84 : f=x^3+y^3+z^3;
i85 : H=deRhamAll(f);
i86 : H.CohomologyGroups

                       1
o86 = HashTable{0 => QQ }
                       1
                1 => QQ
                       2
                2 => QQ
                       2
                3 => QQ

o86 : HashTable
i87 : H.LocalizeMap

o87 = | $x_1^6+2$x_1^3$x_2^3+$x_2^6+2$x_1^3$x_3^3+2$x_2^3$x_3^3+$x_3^6 |

o87 : Matrix
i88 : H.TransferCycles

o88 = HashTable{0 => | -1/12$x_1^4$x_2^3$D_1-1/3$x_1$x_2^6$D_1-1/12$x_1^4$x_3^3$D_1-2/3$x_1$x_2^3$x_3^3$D_1-1/3$x_1$x_3^6$D_1+1/12$x_1^6$x_2$D_2+1/3$x_1^3$x_2^4$D_2+1/3$x_1^3$x_2$x_3^3$D_2+1/12$x_1^6$x_3$D_3+1/3$x_1^3$x_2^3$x_3$D_3+1/3$x_1^3$x_3^4$D_3+1/3$x_1^6+2/3$x_1^3$x_2^3+1/3$x_2^6+2/3$x_1^3$x_3^3+2/3$x_2^3$x_3^3+1/3$x_3^6 |}
                1 => | 2/3$x_1^5+2/3$x_1^2$x_2^3+2/3$x_1^2$x_3^3  |
                     | -2/3$x_1^3$x_2^2-2/3$x_2^5-2/3$x_2^2$x_3^3 |
                     | 2/3$x_1^3$x_3^2+2/3$x_2^3$x_3^2+2/3$x_3^5  |
                2 => | 48$x_1$x_2$x_3^2 600$x_3^4     |
                     | 48$x_1$x_2^2$x_3 600$x_2$x_3^3 |
                     | 48$x_1^2$x_2$x_3 600$x_1$x_3^3 |
                3 => | -$x_1$x_2$x_3 -$x_3^3 |

o88 : HashTable
i89 : I = gkz(matrix{{1,2}}, {5})

              2
o89 = ideal (D  - D , x D  + 2x D  - 5)
              1    2   1 1     2 2

o89 : Ideal of QQ [x , x , D , D , WeylAlgebra => {x  => D , x  => D }]
                    1   2   1   2                   1     1   2     2
i90 : PolySols I

        5      3          2
o90 = {x  + 20x x  + 60x x }
        1      1 2      1 2

o90 : List
i91 : 