4ti2gap package for GAP

Description

Another 4ti2 interface (4ti2Interface)

Authors

Status

Development and test

4ti2

Provides among other programs:

4ti2gap

First attempt:

Facts:

Structure of 4ti2gap (i)

Currently:

lib4ti2[int32, int64, gmp]: groebner

libzsolve: hilbert, graver, zsolve

Structure of 4ti2gap (ii)

Data conversion

ZSolve4ti2

zsolve.gi 4ti2zsolve.cc ZSolve.hpp
ZSolve4ti2 _4ti2_zsolve_ZSolve4ti2 _4ti2_zsolve_::ZSolveAPI<T>

Interface access:

ZSolve4ti2 (syntax)

ZSolve4ti2(problem);

problem=[type_mat, gap_matrix1, type_mat2, gap_matrix2, ... ]

where

type_mat = "mat" | "lat" | "sign" | "rel" | ....

ZSolve4ti2 (example)

From 4ti2_manual:

\[ \begin{array}{rrrrl} x & - & y & \leq & 2,\\ -3x & + & y & \leq & 1,\\ x & + & y & \geq & 1,\\ & & y & \geq & 0 \end{array} \]

gap> ZSolve4ti2(["mat",[[1, -1], [-3, 1], [1, 1]],
  "rel", ["<", "<", ">"],
  "rhs", [[2, 1, 1]],
  "sign", [0, 1]]);

rec( zhom := [ [ 1, 3 ], [ 1, 1 ], [ 1, 2 ] ],
  zinhom := [ [ 2, 0 ], [ 0, 1 ], [ 1, 0 ], [ 1, 1 ] ] )

So the set of solutions of the above system is

\[\{ (2,0),(0,1), (1,0), (1,1)\} +\langle (1,3),(1,1), (12)\rangle\]

ZSolve4ti2 (code example)

Computing the factorizations of v in terms of the elements in l

FactorizationsVectorWRTList_eje:=function(v,l)
  local  matrix ,mat, rhs, sign, problem, n;

  mat := TransposedMat(Concatenation(l,[-v]));
  sign := [List(l,_->1)];
  rhs := [v];
  problem := ["mat",TransposedMat(l),"sign",sign,"rhs",rhs];
  matrix := ZSolve4ti2(problem);
  return matrix.zinhom;
end;
gap> FactorizationsVectorWRTList_eje([5,5],[[2,0],[0,2],[1,1]]);
[ [ 2, 2, 1 ], [ 1, 1, 3 ], [ 0, 0, 5 ] ]

GraverBasis4ti2

graver.gi 4ti2zsolve.cc GraverAPI.hpp
GraverBasis4ti2 _4ti2_zsolve_GraverBasis4ti2 _4ti2_zsolve_::GraverAPI<T>

GraverBasis4ti2(problem);

PrimitiveElementsOfAffineSemigroup_eje:=function(s)
  local l, n, facs, mat, trunc;

  trunc:=function(ls)
    return List(ls, y->Maximum(y,0));
  end;

  l:=GeneratorsOfAffineSemigroup(s);
  n:=Length(l);
  mat:=List(TransposedMat(l));
  facs:=GraverBasis4ti2(["mat", mat]);
  facs:=Set(facs,trunc);
  return Set(facs, f->f*l);
end;
gap> a:=AffineSemigroup([[2,0],[0,2],[1,1]]);
<Affine semigroup in 2 dimensional space, with 3 generators>
gap> PrimitiveElementsOfAffineSemigroup(a);
[ [ 2, 2 ] ]

HilbertBasis4ti2

hilbert.gi 4ti2zsolve.cc HilbertAPI.hpp
HilbertBasis4ti2 _4ti2_zsolve_HilbertBasis4ti2 _4ti2_zsolve_::HilbertAPI<T>

HibertBasis4ti2(problem);

with similar syntax for problem as ZSolve4ti2 and GraverBasis4ti2

GroebnerBasis4ti2

groebner.gi 4ti2groebner.cc groebner_main.cpp, GroebnerBasis.h/cpp, ...
GroebnerBasis4ti2 _4ti2_GroebnerBasis4ti2 _4ti2_::GroebnerBasis

GroebnerBasis4ti2(list[,order]);

where

order = "lex" | "grlex" | "grvlex"

GroebnerBasis4ti2 (code example)

ParticularSolutionGB:=function(A)
  local zeroAllSameSign, facs, sol;

  zeroAllSameSign:=function(bin)
    local rv, prv;
    rv:=First(bin, x->x<>0);
    if rv=fail then  return false; fi;
    prv:=First([1..Length(bin)],i->bin[i]=rv);
    if rv=Length(bin) then return true; fi;
    return First(bin{[prv+1 .. Length(bin)]}, x->x *  rv<0)=fail;
  end;

  facs:=GroebnerBasis4ti2(A);
  if Length(facs)>0 then
    sol:=First(facs, b->zeroAllSameSign(b));
    if sol<>fail then return sol; fi;
  fi;
  return [];
end;
gap> ParticularSolutionGB([[10, 2, -7, 2191],[-4, 280, 1, 7]]);
[ 109, 1, 156, 0 ]

Thank you for your attention