#  Copyright (c) 1997-2009
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
#  http://www.polymake.de
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#-------------------------------------------------------------------------------
#  $Project: polymake $$Id: lattice_properties.rules 9582 2010-03-17 10:38:31Z herr $

function equal_up_to_row_permutation(Matrix, Matrix) {
   my ($M1, $M2)=@_;
   $M1==$M2 || defined(eval { find_vertex_permutation($M1,$M2) })
}

object Polytope<Rational> {

# The lattice points in the polytope
    property LATTICE_POINTS : Matrix<Integer> {

       sub equal { &equal_up_to_row_permutation }
    }

# The number of [[LATTICE_POINTS]]
    property N_LATTICE_POINTS : Int;
    
# The lattice points on the boundary of the polytope, including the vertices
    property BOUNDARY_LATTICE_POINTS : Matrix<Integer> {

       sub equal { &equal_up_to_row_permutation }
    }

# The number of [[BOUNDARY_LATTICE_POINTS]]
    property N_BOUNDARY_LATTICE_POINTS : Int;
    
# The lattice points strictly in the interior of the polytope
    property INTERIOR_LATTICE_POINTS : Matrix<Integer> {

       sub equal { &equal_up_to_row_permutation }
    }
    
# The number of [[INTERIOR_LATTICE_POINTS]]
    property N_INTERIOR_LATTICE_POINTS : Int;
    
# The Hilbert basis spanned of the cone spanned by P x {1}
    property HILBERT_BASIS : Matrix<Integer> {

       sub equal { &equal_up_to_row_permutation }
    }

# The number of elements of [[HILBERT_BASIS]]
    property N_HILBERT_BASIS : Int;

}

object LatticePolytope {

# True if the polytope and its dual have integral vertices.
    property REFLEXIVE : Bool;

# The polytope is __Gorenstein__ if a dilation of the polytope is reflexive up to translation.
    property GORENSTEIN : Bool;
    
# If the polytope is Gorenstein then this is the multiple such that the polytope is reflexive.
    property GORENSTEIN_INDEX : Integer;
    
# If the polytope is Gorenstein, then this is the unique interior lattice point
# in the multiple of the polytope that is reflexive.
    property GORENSTEIN_VECTOR : Vector<Integer>;
    
# The polytope is __canonical__ if there is exactly one interior lattice point.
    property CANONICAL : Bool;

# The polytope is __terminal__ if there is exactly one interior lattice point and all other lattice points are vertices.
    property TERMINAL : Bool;

# True if the polytope contains no lattice points other than the vertices.
    property LATTICE_EMPTY : Bool;

# The normalized volume of the polytope.
    property LATTICE_VOLUME : Integer;

# The degree of the h*-polynomial or Ehrhart polynomial.
    property LATTICE_DEGREE : Int;

# [[DIM]]+1-[[LATTICE_DEGREE]] or the smallest integer k such that k*P has an interior lattice point.
    property LATTICE_CODEGREE : Int;

# The coefficients of the Ehrhart polynomial starting at the constant coefficient.
    property EHRHART_POLYNOMIAL_COEFF : Vector<Rational>;

# The coefficients of the h^*-polynomial starting at the constant coefficient
    property H_STAR_VECTOR : Vector<Integer>;

# The polytope is __normal__ if the cone spanned by P x {1} is generated in height 1.
    property NORMAL : Bool;

# The entry (i,j) equals the lattice distance of vertex j from facet i.
  property FACET_VERTEX_LATTICE_DISTANCES : Matrix<Integer>;

# The maximal integral width of the polytope with respect to the facet normals.
    property FACET_WIDTH : Integer;
    
# The integral width of the polytope with respect to each facet normal.
    property FACET_WIDTHS : Vector<Integer>;

# True if the facet width is one.
  property COMPRESSED : Bool;

# The polytope is __smooth__ if the associated projective variety is smooth; the determinant of the edge directions is +/-1 at every vertex.
  property SMOOTH : Bool;

# The polytope is __very ample__ if the Hilbert Basis of the cone spanned by the edge-directions of any vertex lies inside the polytope.
  property VERY_AMPLE : Bool;



# The Groebner basis of the homogeneous toric ideal associated to the polytope,
# the term order is given in matrix form.
  declare object GroebnerBasis {

# The Groebner basis for a defined term order
    property BASIS : Matrix<Integer>;

# The term order in matrix form;
# if not square, then a tie breaker is used.
    property TERM_ORDER_MATRIX : Matrix<Integer>;

# A term order by name;
# allowed acronyms are ''lex'', ''deglex'' and ''degrevlex''.
    property TERM_ORDER_NAME : String {
      my %known_term_orders;
      @known_term_orders{ qw(lex deglex degrevlex) }=();

      sub canonical { croak("unknown term order") unless exists $known_term_orders{$_[0]}; }
  }
}

# The Groebner basis for the toric ideal associated to the lattice points in the polytope using any term order.
  property GROEBNER_BASIS : GroebnerBasis : multiple;

}


# Local Variables:
# mode: perl
# c-basic-offset:4
# End:
