Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1X2 [33X[0;0YCones and semigroups[133X[101X234[1X2.1 [33X[0;0YCones[133X[101X56[33X[0;0YThis section introduces the [5Xtoric[105X commands which deal with cones and related7combinatorial-geometric objects. Recall, a [12Xcone[112X is a strongly convex8polyhedral cone ([Ful93], page 4).[133X910[1X2.1-1 InsideCone[101X1112[29X[2XInsideCone[102X( [3Xv[103X, [3XL[103X ) [32X function1314[33X[0;0YThis command returns `true` if the vector [3Xv[103X belongs to the interior of the15(strongly convex polyhedral) cone generated by the vectors in [3XL[103X.[133X1617[33X[0;0YThis procedure does not check if [3XL[103X generates a strongly convex polyhedral18cone.[133X1920[4X[32X Example [32X[104X21[4X[25Xgap>[125X [27XL:=[[1,0,0],[1,1,0],[1,1,1],[1,0,1]];; v:=[0,0,1];;[127X[104X22[4X[25Xgap>[125X [27XInsideCone(v,L);[127X[104X23[4X[28Xfalse[128X[104X24[4X[25Xgap>[125X [27XL:=[[1,0],[3,4]];;[127X[104X25[4X[25Xgap>[125X [27Xv:=[1,-7]; InsideCone(v,L);[127X[104X26[4X[28X[ 1, -7 ][128X[104X27[4X[28Xfalse[128X[104X28[4X[25Xgap>[125X [27Xv:=[4,-3]; InsideCone(v,L);[127X[104X29[4X[28X[ 4, -3 ][128X[104X30[4X[28Xfalse[128X[104X31[4X[25Xgap>[125X [27Xv:=[4,-4]; InsideCone(v,L);[127X[104X32[4X[28X[ 4, -4 ][128X[104X33[4X[28Xfalse[128X[104X34[4X[25Xgap>[125X [27Xv:=[4,1]; InsideCone(v,L);[127X[104X35[4X[28X[ 4, 1 ][128X[104X36[4X[28Xtrue[128X[104X37[4X[32X[104X3839[1X2.1-2 InDualCone[101X4041[29X[2XInDualCone[102X( [3Xv[103X, [3XL[103X ) [32X function4243[33X[0;0YThis command returns `true` if [3Xv[103X belongs to the dual of the cone generated44by the vectors in [3XL[103X.[133X4546[4X[32X Example [32X[104X47[4X[25Xgap>[125X [27XL:=[[1,0,0],[1,1,0],[1,1,1],[1,0,1]];; v:=[0,0,1];;[127X[104X48[4X[25Xgap>[125X [27XInDualCone(v,L);[127X[104X49[4X[28Xtrue[128X[104X50[4X[25Xgap>[125X [27XL:=[[1,0],[3,4]];[127X[104X51[4X[28X[ [ 1, 0 ], [ 3, 4 ] ][128X[104X52[4X[25Xgap>[125X [27Xv:=[1,-7]; InDualCone(v,L);[127X[104X53[4X[28X[ 1, -7 ][128X[104X54[4X[28Xfalse[128X[104X55[4X[25Xgap>[125X [27Xv:=[4,-3]; InDualCone(v,L);[127X[104X56[4X[28X[ 4, -3 ][128X[104X57[4X[28Xtrue[128X[104X58[4X[25Xgap>[125X [27Xv:=[4,-4]; InDualCone(v,L);[127X[104X59[4X[28X[ 4, -4 ][128X[104X60[4X[28Xfalse[128X[104X61[4X[25Xgap>[125X [27Xv:=[4,1]; InDualCone(v,L);[127X[104X62[4X[28X[ 4, 1 ][128X[104X63[4X[28Xtrue[128X[104X64[4X[32X[104X6566[1X2.1-3 PolytopeLatticePoints[101X6768[29X[2XPolytopeLatticePoints[102X( [3XA[103X, [3XPerps[103X ) [32X function6970[33X[0;0Y[13XInput[113X: [3XPerps[103X[22X=[v_1,...,v_k][122X is the list of ``inward normal" vectors71perpendicular to the walls of a polytope [22XP[122X in the vector space [22XL_0^*⊗ Q[122X,[133X72[33X[0;0Y[3XA[103X[22X=[a_1,...,a_k][122X is a k-tuple of integers, where [22Xa_i[122X denotes the amount the73i-th ``wall" (defined by the normal [22Xv_i[122X) is shifted from the origin (each74[22Xa_i[122X is assumed non-negative).[133X75[33X[0;0YFor example, the polytope [22XP[122X with faces [10X[x=0, x=a, y=0, y=b][110X has76[3XPerps[103X[22X=[[1,0],[-1,0],[0,1],[0,-1]][122X and [3XA[103X[22X=[0,a,0,b][122X.[133X77[33X[0;0Y[13XOutput[113X: the list of points in [22XP ∩ L_0^*[122X.[133X7879[4X[32X Example [32X[104X80[4X[25Xgap>[125X [27XPerps:=[[1,0],[-1,0],[0,1],[0,-1]];[127X[104X81[4X[28X[ [ 1, 0 ], [ -1, 0 ], [ 0, 1 ], [ 0, -1 ] ][128X[104X82[4X[25Xgap>[125X [27XA:=[0,4,0,3];[127X[104X83[4X[28X[ 0, 4, 0, 3 ][128X[104X84[4X[25Xgap>[125X [27XPolytopeLatticePoints(A,Perps);[127X[104X85[4X[28X[ [ 0, 0 ], [ 0, 1 ], [ 0, 2 ], [ 0, 3 ], [ 1, 0 ], [ 1, 1 ], [ 1, 2 ],[128X[104X86[4X[28X [ 1, 3 ], [ 2, 0 ], [ 2, 1 ], [ 2, 2 ], [ 2, 3 ], [ 3, 0 ], [ 3, 1 ],[128X[104X87[4X[28X [ 3, 2 ], [ 3, 3 ], [ 4, 0 ], [ 4, 1 ], [ 4, 2 ], [ 4, 3 ] ][128X[104X88[4X[25Xgap>[125X [27XLength(last);[127X[104X89[4X[28X20[128X[104X90[4X[32X[104X9192[1X2.1-4 Faces[101X9394[29X[2XFaces[102X( [3XRays[103X ) [32X function9596[33X[0;0Y[13XInput[113X: [3XRays[103X is a list of rays for the fan [22X∆[122X[133X97[33X[0;0Y[13XOutput[113X: All the normals to the faces (hyperplanes of the cone).[133X9899[4X[32X Example [32X[104X100[4X[25Xgap>[125X [27XCones1:=[[[2,-1],[-1,2]],[[-1,2],[-1,-1]],[[-1,-1],[2,-1]]];;[127X[104X101[4X[25Xgap>[125X [27XFaces(Cones1[1]);[127X[104X102[4X[28X[ [ 1/2, 1 ], [ 2, 1 ] ][128X[104X103[4X[25Xgap>[125X [27XFaces(Cones1[2]);[127X[104X104[4X[28X[ [ -2, -1 ], [ -1, 1 ] ][128X[104X105[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[104X106[4X[25Xgap>[125X [27XFaces(Cones2[1]);[127X[104X107[4X[28X[ [ 0, 0, 1 ], [ 0, 1, 0 ], [ 1, 0, 0 ] ][128X[104X108[4X[25Xgap>[125X [27XFaces(Cones2[2]);[127X[104X109[4X[28X[ [ 1/3, 5/6, 1 ], [ 1/2, 0, -1 ], [ 2, 0, 1 ] ][128X[104X110[4X[32X[104X111112[1X2.1-5 ConesOfFan[101X113114[29X[2XConesOfFan[102X( [3XDelta[103X, [3Xk[103X ) [32X function115116[33X[0;0Y[13XInput[113X: [3XDelta[103X is the fan of cones,[133X117[33X[0;0Y[3Xk[103X is the dimension of the cones desired.[133X118[33X[0;0Y[13XOutput[113X: The [3Xk[103X-dimensional cones in the fan.[133X119120[1X2.1-6 NumberOfConesOfFan[101X121122[29X[2XNumberOfConesOfFan[102X( [3XDelta[103X, [3Xk[103X ) [32X function123124[33X[0;0Y[13XInput[113X: [3XDelta[103X is the fan of cones in [22XV=Q^n[122X,[133X125[33X[0;0Y[3Xk[103X is the dimension of the cones counted.[133X126[33X[0;0Y[13XOutput[113X: The number of [3Xk[103X-dimensional cones in the fan.[133X127128[33X[0;0YIdea: The fan [3XDelta[103X is represented as a set of maximal cones. For each129maximal cone, look at the [3Xk[103X-dimensional faces obtained by taking [22Xn[122X choose [3Xk[103X130subsets of the rays describing the cone. Certain of these [3Xk[103X-subsets yield131the desired cones.[133X132133[4X[32X Example [32X[104X134[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[104X135[4X[25Xgap>[125X [27XNumberOfConesOfFan(Delta0,2);[127X[104X136[4X[28X6[128X[104X137[4X[25Xgap>[125X [27XConesOfFan(Delta0,2);[127X[104X138[4X[28X[ [ [ 0, 0, 2 ], [ 0, 2, 0 ] ], [ [ 0, 0, 2 ], [ 2, 0, 0 ] ], [128X[104X139[4X[28X [ [ 0, 2, 0 ], [ 1, 2, -2 ] ], [ [ 0, 2, 0 ], [ 2, -2, 1 ] ],[128X[104X140[4X[28X [ [ 0, 2, 0 ], [ 2, 0, 0 ] ], [ [ 1, 2, -2 ], [ 2, -2, 1 ] ] ][128X[104X141[4X[25Xgap>[125X [27XConesOfFan(Delta0,1);[127X[104X142[4X[28X[ [ [ 0, 0, 2 ] ], [ [ 0, 2, 0 ] ], [ [ 1, 2, -2 ] ], [128X[104X143[4X[28X [ [ 2, -2, 1 ] ], [ [ 2, 0, 0 ] ] ][128X[104X144[4X[25Xgap>[125X [27XNumberOfConesOfFan(Delta0,1);[127X[104X145[4X[28X5[128X[104X146[4X[32X[104X147148[1X2.1-7 ToricStar[101X149150[29X[2XToricStar[102X( [3Xsigma[103X, [3XDelta[103X ) [32X function151152[33X[0;0Y[13XInput[113X: [3Xsigma[103X is a cone in the fan, represented by its set of maximal (i.e.,153highest dimensional) cones.[133X154[33X[0;0Y[3XDelta[103X is the fan of cones in [22XV=Q^n[122X.[133X155[33X[0;0Y[13XOutput[113X: The star of the cone [3Xsigma[103X in [3XDelta[103X, i.e., the cones [22Xτ[122X which have156[3Xsigma[103X as a face.[133X157158[4X[32X Example [32X[104X159[4X[25Xgap>[125X [27XMaxCones:=[ [ [2,0,0],[0,2,0],[0,0,2] ], [127X[104X160[4X[25X>[125X [27X [ [2,0,0],[0,2,0],[2,-2,1],[1,2,-2] ] ];;[127X[104X161[4X[25Xgap>[125X [27X#this is the set of maximal cones in the fan Delta[127X[104X162[4X[25Xgap>[125X [27XToricStar([[1,0]],MaxCones);[127X[104X163[4X[28X[ ][128X[104X164[4X[25Xgap>[125X [27XToricStar([[2,0,0],[0,2,0]],MaxCones);[127X[104X165[4X[28X[ [ [ 0, 2, 0 ], [ 2, 0, 0 ] ], [ [ 2, 0, 0 ], [ 0, 2, 0 ], [ 0, 0, 2 ] ],[128X[104X166[4X[28X [ [ 2, 0, 0 ], [ 0, 2, 0 ], [ 2, -2, 1 ], [ 1, 2, -2 ] ] ][128X[104X167[4X[25Xgap>[125X [27XMaxCones:=[ [ [2,0,0],[0,2,0],[0,0,2] ], [ [2,0,0],[0,2,0],[1,1,-2] ] ];;[127X[104X168[4X[25Xgap>[125X [27XToricStar([[2,0,0],[0,2,0]],MaxCones);[127X[104X169[4X[28X[ [ [ 0, 2, 0 ], [ 2, 0, 0 ] ], [ [ 2, 0, 0 ], [ 0, 2, 0 ], [ 0, 0, 2 ] ],[128X[104X170[4X[28X [ [ 2, 0, 0 ], [ 0, 2, 0 ], [ 1, 1, -2 ] ] ][128X[104X171[4X[25Xgap>[125X [27XToricStar([[1,0]],MaxCones);[127X[104X172[4X[28X[ ][128X[104X173[4X[32X[104X174175176[1X2.2 [33X[0;0YSemigroups[133X[101X177178[1X2.2-1 DualSemigroupGenerators[101X179180[29X[2XDualSemigroupGenerators[102X( [3XL[103X ) [32X function181182[33X[0;0Y[13XInput[113X: [3XL[103X is a list of integral [22Xn[122X-vectors generating a cone [22Xσ[122X.[133X183[33X[0;0Y[13XOutput[113X: the generators of [22XS_σ[122X,[133X184185[33X[0;0YIdea: let [22XM[122X be the maximum of the absolute values of the coordinates of the186[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. If187so, add [22Xv[122X to list of possible generators. Once this for loop is finished,188one can check this list for redundant generators. The trick is to simply189omit those elements which are of the form [22Xd_1+d_2[122X, where [22Xd_1[122X and [22Xd_2[122X are190``small" elements in the integral dual cone.[133X191192[33X[0;0YThis program is not very efficient and should not be used in ``large193examples'' involving semigroups with ``many'' generators. For example, if194you take [3XL:=[[1,2,3,4],[0,1,0,7],[3,1,0,2],[0,0,1,0]];[103X then195[10XDualSemigroupGenerators(L);[110X can exhaust GAP's memory allocation.[133X196197[4X[32X Example [32X[104X198[4X[25Xgap>[125X [27XL:=[[1,0],[3,4]];; DualSemigroupGenerators([[1,0],[3,4]]);[127X[104X199[4X[28X[ [ 0, 0 ], [ 0, 1 ], [ 1, 0 ], [ 2, -1 ], [ 3, -2 ], [ 4, -3 ] ][128X[104X200[4X[25Xgap>[125X [27XL:=[[1,0,0],[1,1,0],[1,1,1],[1,0,1]];;[127X[104X201[4X[25Xgap>[125X [27XDualSemigroupGenerators(L);[127X[104X202[4X[28X[ [ 0, 0, 0 ], [ 0, 0, 1 ], [ 0, 1, 0 ], [ 1, -1, 0 ], [ 1, 0, -1 ] ][128X[104X203[4X[32X[104X204205206207