1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
/*
* app_integergb.cpp
*
* Created on: Dec 14, 2010
* Author: anders
*/
#include "printer.h"
#include "parser.h"
#include "gfanapplication.h"
#include "division.h"
#include "log.h"
#include "polyhedralcone.h"
#include "tropical2.h"
#include "wallideal.h"
#include "integergb.h"
#include <ostream>
using namespace std;
class IntegerGBApplication : public GFanApplication
{
SimpleOption gbOption;
SimpleOption initialOption;
SimpleOption gFanOption;
SimpleOption gConeOption;
SimpleOption listOption;
SimpleOption optionInputIsGroebnerBasis;
public:
const char *helpText()
{
return "This program is an experimental implementation of Groebner bases for ideals in Z[x_1,...,x_n].\n"
"Several operations are supported by specifying the appropriate option:\n"
" (1) computation of the reduced Groebner basis with respect to a given vector (tiebroken lexicographically),\n"
" (2) computation of an initial ideal,\n"
" (3) computation of the Groebner fan,\n"
" (4) computation of a single Groebner cone.\n"
"Since Gfan only knows polynomial rings with coefficients being elements of a field, the ideal is specified by giving a set of polynomials in the polynomial ring Q[x_1,...,x_n]. That is, by using Q instead of Z when specifying the ring. The ideal MUST BE HOMOGENEOUS (in a positive grading) for computation of the Groebner fan. Non-homogeneous ideals are allowed for the other computations if the specified weight vectors are positive.\n"
"NOTE: This program is experimental and expected to change behaviour in future releases, so don't write your SAGE and M2 interfaces just yet.\n";
}
IntegerGBApplication():
gbOption("--groebnerBasis","Asks the program to compute a marked Groebner basis with respect to a weight vector tie-broken lexicographically.\n"
"The input order is: Ring ideal vector.\n"),
initialOption("--initialIdeal","Asks the program to compute an initial ideal with respect to a vector. "
"The input order is: Ring ideal vector.\n"),
gFanOption("--groebnerFan","Asks the program to compute the Groebner fan. \n "
"The input order is: Ring ideal.\n"),
gConeOption("--groebnerCone","Asks the program to compute a single Groebner cone containing the specified vector in its relative interior. The output is stored as a fan. "
"The input order is: Ring ideal vector."),
listOption("-m","For the operations taking a vector as input, read in a list of vectors instead, and perform the operation for each vector in the list."),
optionInputIsGroebnerBasis("-g",
"Tells the program that the input is already a Groebner basis (with the initial term of each polynomial being "
"the first ones listed). Use this option if the usual --groebnerFan is too slow.\n")
{
registerOptions();
}
const char *name()
{
return "_overintegers";
}
int main()
{
if(gbOption.getValue()+initialOption.getValue()+gFanOption.getValue()+gConeOption.getValue()!=1)
{
debug<<"WRONG COMBINATION OF COMMAND LINE OPTIONS\n";
assert(0);
}
LexicographicTermOrder tieBreaker;
FileParser P(Stdin);
PolynomialSet a=P.parsePolynomialSetWithRing();
int n=a.getRing().getNumberOfVariables();
// IntegerVectorList omegas=P.parseIntegerVectorList();
if(gFanOption.getValue())
{
SymmetryGroup G(n);
SymmetricTargetFanBuilder target(n,G);
if(optionInputIsGroebnerBasis.getValue())
{
IntegerVectorList empty;
IntegerVector w=PolyhedralCone(wallInequalities(a),empty).getRelativeInteriorPoint();
WeightReverseLexicographicTermOrder tieBreaker(w);
zAutoReduce(&a,tieBreaker);
}
else
{
WeightReverseLexicographicTermOrder tieBreaker(IntegerVector::allOnes(n));
zBuchberger(a,tieBreaker);
}
IntegerGroebnerFanTraverser traverser(a);
symmetricTraverse(traverser,target);
AsciiPrinter Q(Stdout);
target.getFanRef().printWithIndices(&Q,
FPF_default);
}
else
{
IntegerVectorList omegas;
if(listOption.getValue())
omegas=P.parseIntegerVectorList();
else
omegas.push_back(P.parseIntegerVector());
for(IntegerVectorList::const_iterator i=omegas.begin();i!=omegas.end();i++)
{
if(i->size()!=a.getRing().getNumberOfVariables())
{
debug<<"ERROR: The number of entries of the weight vector is not equal to the number of variables in the ring.\n";
assert(0);
}
if(gbOption.getValue())
{
WeightTermOrder T(*i);
zBuchberger(a,T);
pout<<a.getRing()<<a;
}
else if(initialOption.getValue())
{
WeightTermOrder T(*i);
zBuchberger(a,T);
pout<<a.getRing();
pout<<initialForms(a,*i);
}
else if(gConeOption.getValue())
{
WeightTermOrder T(*i);
zBuchberger(a,T);
IntegerVectorList inequalities=wallInequalities(a);
inequalities.push_back(IntegerVector::standardVector(n,0));
IntegerVectorList empty;
PolyhedralCone C(inequalities,empty,n);
C=C.faceContaining(*i);
C.canonicalize();
PolyhedralFan F(C.ambientDimension());
F.insert(C);
F.printWithIndices(&pout,
FPF_default);
}
}
}
/*
for(IntegerVectorList::const_iterator i=omegas.begin();i!=omegas.end();i++)
{
debug<<"INTEGRAL GROEBNER BASIS:\n";
WeightTermOrder T(*i);
zBuchberger(a,T);
debug<<"INTEGRAL GROEBNER BASIS:\n";
debug<<a;
// PolynomialRing ZModPZRing=residuePolynomialRing(a.getRing(), prime);
debug<<"INTEGRAL INITIAL IDEAL:\n";
// debug<<ZModPZRing;
debug<<initialForms(a,*i);
// debug<<"P-ADIC INITIAL TERMS:\n";
// debug<<ZModPZRing;
// debug<<pAdicInitialTerms(ZModPZRing,a,prime,omega,tieBreaker);
// debug<<"AUTOREDUCED:\n";
// pAdicAutoReduce(a,prime,omega,tieBreaker);
// debug<<a;
debug<<"MAXIMAL GROEBNER CONE:\n";
IntegerVectorList inequalities=wallInequalities(a);
IntegerVectorList empty;
PolyhedralCone C(inequalities,empty,n);
debug<<C;
debug<<"RAYS:\n";
debug<<C.extremeRays();
}
{
SymmetryGroup G(n);
SymmetricTargetFanBuilder target(n,G);
IntegerGroebnerFanTraverser traverser(a);
symmetricTraverse(traverser,target);
AsciiPrinter Q(Stdout);
target.getFanRef().printWithIndices(&Q,
FPF_default);
}
*/ return 0;
}
};
static IntegerGBApplication theApplication;
|