  
  [1X2 [33X[0;0YCones and semigroups[133X[101X
  
  
  [1X2.1 [33X[0;0YCones[133X[101X
  
  [33X[0;0YThis section introduces the [5Xtoric[105X commands which deal with cones and related
  combinatorial-geometric  objects.  Recall,  a  [12Xcone[112X  is  a  strongly  convex
  polyhedral cone ([Ful93], page 4).[133X
  
  [1X2.1-1 InsideCone[101X
  
  [33X[1;0Y[29X[2XInsideCone[102X( [3Xv[103X, [3XL[103X ) [32X function[133X
  
  [33X[0;0YThis  command  returns `true` if the vector [3Xv[103X belongs to the interior of the
  (strongly convex polyhedral) cone generated by the vectors in [3XL[103X.[133X
  
  [33X[0;0YThis  procedure  does  not check if [3XL[103X generates a strongly convex polyhedral
  cone.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XL:=[[1,0,0],[1,1,0],[1,1,1],[1,0,1]];; v:=[0,0,1];;[127X[104X
    [4X[25Xgap>[125X [27XInsideCone(v,L);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27XL:=[[1,0],[3,4]];;[127X[104X
    [4X[25Xgap>[125X [27Xv:=[1,-7]; InsideCone(v,L);[127X[104X
    [4X[28X[ 1, -7 ][128X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xv:=[4,-3]; InsideCone(v,L);[127X[104X
    [4X[28X[ 4, -3 ][128X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xv:=[4,-4]; InsideCone(v,L);[127X[104X
    [4X[28X[ 4, -4 ][128X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xv:=[4,1]; InsideCone(v,L);[127X[104X
    [4X[28X[ 4, 1 ][128X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [1X2.1-2 InDualCone[101X
  
  [33X[1;0Y[29X[2XInDualCone[102X( [3Xv[103X, [3XL[103X ) [32X function[133X
  
  [33X[0;0YThis  command  returns `true` if [3Xv[103X belongs to the dual of the cone generated
  by the vectors in [3XL[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XL:=[[1,0,0],[1,1,0],[1,1,1],[1,0,1]];; v:=[0,0,1];;[127X[104X
    [4X[25Xgap>[125X [27XInDualCone(v,L);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XL:=[[1,0],[3,4]];[127X[104X
    [4X[28X[ [ 1, 0 ], [ 3, 4 ] ][128X[104X
    [4X[25Xgap>[125X [27Xv:=[1,-7]; InDualCone(v,L);[127X[104X
    [4X[28X[ 1, -7 ][128X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xv:=[4,-3]; InDualCone(v,L);[127X[104X
    [4X[28X[ 4, -3 ][128X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xv:=[4,-4]; InDualCone(v,L);[127X[104X
    [4X[28X[ 4, -4 ][128X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xv:=[4,1]; InDualCone(v,L);[127X[104X
    [4X[28X[ 4, 1 ][128X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [1X2.1-3 PolytopeLatticePoints[101X
  
  [33X[1;0Y[29X[2XPolytopeLatticePoints[102X( [3XA[103X, [3XPerps[103X ) [32X function[133X
  
  [33X[0;0Y[13XInput[113X:   [3XPerps[103X[22X=[v_1,...,v_k][122X   is  the  list  of  ``inward  normal"  vectors
  perpendicular to the walls of a polytope [22XP[122X in the vector space [22XL_0^*⊗ Q[122X,[133X
  [33X[0;0Y[3XA[103X[22X=[a_1,...,a_k][122X  is  a k-tuple of integers, where [22Xa_i[122X denotes the amount the
  i-th  ``wall"  (defined  by the normal [22Xv_i[122X) is shifted from the origin (each
  [22Xa_i[122X is assumed non-negative).[133X
  [33X[0;0YFor   example,   the  polytope  [22XP[122X  with  faces  [10X[x=0,  x=a,  y=0,  y=b][110X  has
  [3XPerps[103X[22X=[[1,0],[-1,0],[0,1],[0,-1]][122X and [3XA[103X[22X=[0,a,0,b][122X.[133X
  [33X[0;0Y[13XOutput[113X: the list of points in [22XP ∩ L_0^*[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XPerps:=[[1,0],[-1,0],[0,1],[0,-1]];[127X[104X
    [4X[28X[ [ 1, 0 ], [ -1, 0 ], [ 0, 1 ], [ 0, -1 ] ][128X[104X
    [4X[25Xgap>[125X [27XA:=[0,4,0,3];[127X[104X
    [4X[28X[ 0, 4, 0, 3 ][128X[104X
    [4X[25Xgap>[125X [27XPolytopeLatticePoints(A,Perps);[127X[104X
    [4X[28X[ [ 0, 0 ], [ 0, 1 ], [ 0, 2 ], [ 0, 3 ], [ 1, 0 ], [ 1, 1 ], [ 1, 2 ],[128X[104X
    [4X[28X  [ 1, 3 ], [ 2, 0 ], [ 2, 1 ], [ 2, 2 ], [ 2, 3 ], [ 3, 0 ], [ 3, 1 ],[128X[104X
    [4X[28X  [ 3, 2 ], [ 3, 3 ], [ 4, 0 ], [ 4, 1 ], [ 4, 2 ], [ 4, 3 ] ][128X[104X
    [4X[25Xgap>[125X [27XLength(last);[127X[104X
    [4X[28X20[128X[104X
  [4X[32X[104X
  
  [1X2.1-4 Faces[101X
  
  [33X[1;0Y[29X[2XFaces[102X( [3XRays[103X ) [32X function[133X
  
  [33X[0;0Y[13XInput[113X: [3XRays[103X is a list of rays for the fan [22X∆[122X[133X
  [33X[0;0Y[13XOutput[113X: All the normals to the faces (hyperplanes of the cone).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XCones1:=[[[2,-1],[-1,2]],[[-1,2],[-1,-1]],[[-1,-1],[2,-1]]];;[127X[104X
    [4X[25Xgap>[125X [27XFaces(Cones1[1]);[127X[104X
    [4X[28X[ [ 1/2, 1 ], [ 2, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27XFaces(Cones1[2]);[127X[104X
    [4X[28X[ [ -2, -1 ], [ -1, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27XCones2:=[[[ 2,0,0],[0,2,0],[0,0,2]], [[2,0,0], [0,2,0], [2,-2,1],[1,2,-2]]];;[127X[104X
    [4X[25Xgap>[125X [27XFaces(Cones2[1]);[127X[104X
    [4X[28X[ [ 0, 0, 1 ], [ 0, 1, 0 ], [ 1, 0, 0 ] ][128X[104X
    [4X[25Xgap>[125X [27XFaces(Cones2[2]);[127X[104X
    [4X[28X[ [ 1/3, 5/6, 1 ], [ 1/2, 0, -1 ], [ 2, 0, 1 ] ][128X[104X
  [4X[32X[104X
  
  [1X2.1-5 ConesOfFan[101X
  
  [33X[1;0Y[29X[2XConesOfFan[102X( [3XDelta[103X, [3Xk[103X ) [32X function[133X
  
  [33X[0;0Y[13XInput[113X: [3XDelta[103X is the fan of cones,[133X
  [33X[0;0Y[3Xk[103X is the dimension of the cones desired.[133X
  [33X[0;0Y[13XOutput[113X: The [3Xk[103X-dimensional cones in the fan.[133X
  
  [1X2.1-6 NumberOfConesOfFan[101X
  
  [33X[1;0Y[29X[2XNumberOfConesOfFan[102X( [3XDelta[103X, [3Xk[103X ) [32X function[133X
  
  [33X[0;0Y[13XInput[113X: [3XDelta[103X is the fan of cones in [22XV=Q^n[122X,[133X
  [33X[0;0Y[3Xk[103X is the dimension of the cones counted.[133X
  [33X[0;0Y[13XOutput[113X: The number of [3Xk[103X-dimensional cones in the fan.[133X
  
  [33X[0;0YIdea:  The  fan  [3XDelta[103X  is  represented  as a set of maximal cones. For each
  maximal  cone, look at the [3Xk[103X-dimensional faces obtained by taking [22Xn[122X choose [3Xk[103X
  subsets  of  the  rays describing the cone. Certain of these [3Xk[103X-subsets yield
  the desired cones.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XDelta0:=[ [ [2,0,0],[0,2,0],[0,0,2] ], [ [2,0,0],[0,2,0],[2,-2,1],[1,2,-2] ] ];;[127X[104X
    [4X[25Xgap>[125X [27XNumberOfConesOfFan(Delta0,2);[127X[104X
    [4X[28X6[128X[104X
    [4X[25Xgap>[125X [27XConesOfFan(Delta0,2);[127X[104X
    [4X[28X[ [ [ 0, 0, 2 ], [ 0, 2, 0 ] ], [ [ 0, 0, 2 ], [ 2, 0, 0 ] ], [128X[104X
    [4X[28X  [ [ 0, 2, 0 ], [ 1, 2, -2 ] ], [ [ 0, 2, 0 ], [ 2, -2, 1 ] ],[128X[104X
    [4X[28X  [ [ 0, 2, 0 ], [ 2, 0, 0 ] ], [ [ 1, 2, -2 ], [ 2, -2, 1 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XConesOfFan(Delta0,1);[127X[104X
    [4X[28X[ [ [ 0, 0, 2 ] ], [ [ 0, 2, 0 ] ], [ [ 1, 2, -2 ] ], [128X[104X
    [4X[28X  [ [ 2, -2, 1 ] ], [ [ 2, 0, 0 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XNumberOfConesOfFan(Delta0,1);[127X[104X
    [4X[28X5[128X[104X
  [4X[32X[104X
  
  [1X2.1-7 ToricStar[101X
  
  [33X[1;0Y[29X[2XToricStar[102X( [3Xsigma[103X, [3XDelta[103X ) [32X function[133X
  
  [33X[0;0Y[13XInput[113X:  [3Xsigma[103X is a cone in the fan, represented by its set of maximal (i.e.,
  highest dimensional) cones.[133X
  [33X[0;0Y[3XDelta[103X is the fan of cones in [22XV=Q^n[122X.[133X
  [33X[0;0Y[13XOutput[113X:  The  star  of the cone [3Xsigma[103X in [3XDelta[103X, i.e., the cones [22Xτ[122X which have
  [3Xsigma[103X as a face.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XMaxCones:=[ [ [2,0,0],[0,2,0],[0,0,2] ], [127X[104X
    [4X[25X>[125X [27X                [ [2,0,0],[0,2,0],[2,-2,1],[1,2,-2] ] ];;[127X[104X
    [4X[25Xgap>[125X [27X#this is the set of maximal cones in the fan Delta[127X[104X
    [4X[25Xgap>[125X [27XToricStar([[1,0]],MaxCones);[127X[104X
    [4X[28X[  ][128X[104X
    [4X[25Xgap>[125X [27XToricStar([[2,0,0],[0,2,0]],MaxCones);[127X[104X
    [4X[28X[ [ [ 0, 2, 0 ], [ 2, 0, 0 ] ], [ [ 2, 0, 0 ], [ 0, 2, 0 ], [ 0, 0, 2 ] ],[128X[104X
    [4X[28X  [ [ 2, 0, 0 ], [ 0, 2, 0 ], [ 2, -2, 1 ], [ 1, 2, -2 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XMaxCones:=[ [ [2,0,0],[0,2,0],[0,0,2] ], [ [2,0,0],[0,2,0],[1,1,-2] ] ];;[127X[104X
    [4X[25Xgap>[125X [27XToricStar([[2,0,0],[0,2,0]],MaxCones);[127X[104X
    [4X[28X[ [ [ 0, 2, 0 ], [ 2, 0, 0 ] ], [ [ 2, 0, 0 ], [ 0, 2, 0 ], [ 0, 0, 2 ] ],[128X[104X
    [4X[28X  [ [ 2, 0, 0 ], [ 0, 2, 0 ], [ 1, 1, -2 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XToricStar([[1,0]],MaxCones);[127X[104X
    [4X[28X[  ][128X[104X
  [4X[32X[104X
  
  
  [1X2.2 [33X[0;0YSemigroups[133X[101X
  
  [1X2.2-1 DualSemigroupGenerators[101X
  
  [33X[1;0Y[29X[2XDualSemigroupGenerators[102X( [3XL[103X ) [32X function[133X
  
  [33X[0;0Y[13XInput[113X: [3XL[103X is a list of integral [22Xn[122X-vectors generating a cone [22Xσ[122X.[133X
  [33X[0;0Y[13XOutput[113X: the generators of [22XS_σ[122X,[133X
  
  [33X[0;0YIdea:  let [22XM[122X be the maximum of the absolute values of the coordinates of the
  [3XL[103X[i]'s, for each vector [22Xv[122X in [22X[1..M]^n[122X, test if [22Xv[122X is in the dual cone [22Xσ^*[122X. If
  so,  add  [22Xv[122X  to list of possible generators. Once this for loop is finished,
  one  can  check  this  list for redundant generators. The trick is to simply
  omit  those  elements  which  are of the form [22Xd_1+d_2[122X, where [22Xd_1[122X and [22Xd_2[122X are
  ``small" elements in the integral dual cone.[133X
  
  [33X[0;0YThis  program  is  not  very  efficient  and  should  not be used in ``large
  examples''  involving  semigroups  with ``many'' generators. For example, if
  you       take       [3XL:=[[1,2,3,4],[0,1,0,7],[3,1,0,2],[0,0,1,0]];[103X      then
  [10XDualSemigroupGenerators(L);[110X can exhaust GAP's memory allocation.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XL:=[[1,0],[3,4]];; DualSemigroupGenerators([[1,0],[3,4]]);[127X[104X
    [4X[28X[ [ 0, 0 ], [ 0, 1 ], [ 1, 0 ], [ 2, -1 ], [ 3, -2 ], [ 4, -3 ] ][128X[104X
    [4X[25Xgap>[125X [27XL:=[[1,0,0],[1,1,0],[1,1,1],[1,0,1]];;[127X[104X
    [4X[25Xgap>[125X [27XDualSemigroupGenerators(L);[127X[104X
    [4X[28X[ [ 0, 0, 0 ], [ 0, 0, 1 ], [ 0, 1, 0 ], [ 1, -1, 0 ], [ 1, 0, -1 ] ][128X[104X
  [4X[32X[104X
  
