#  Copyright (c) 1997-2021
#  Ewgenij Gawrilow, Michael Joswig, and the polymake team
#  Technische Universität Berlin, Germany
#  https://polymake.org
#
#  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.
#-------------------------------------------------------------------------------

# @topic application
# This application concentrates on [[Hypersurface|tropical hypersurfaces]] and [[Polytope|tropical polytopes]].
# It provides the functionality for the computation of basic properties. Visualization and various constructions are possible.

IMPORT graph

USE polytope fan graph matroid

file_suffix trop


HELP help.rules


##################################################################################

declare property_type CovectorDecoration : c++ (name => "tropical::CovectorDecoration", include => "polymake/tropical/covectors.h");

# A tropical polytope is the tropical convex hull of finitely many points or the finite intersection of tropical halfspaces in a tropical projective space.
# Many combinatorial properties depend on [[POINTS]].
# Note: [[VERTICES]] are used for [[POINTS]] if the tropical polytope is initialized by INEQUALITIES. 
# @tparam Addition Either [[Min]] or [[Max]]. There is NO default for this, you have to choose!
# @tparam Scalar Rational by default. The underlying type of ordered group.
# @example Constructing a tropical polygon from a fixed list of generators.  
# > $P = new Polytope<Min>(POINTS=>[[0,1,0],[0,4,1],[0,3,3],[0,0,2]]);
# @example Constructing the same tropical polygon from tropical linear inequalities.
# > $A1 = new Matrix<TropicalNumber<Min>>([[0,-2,"inf"],["inf",-4,"inf"],["inf",-3,-1],["inf","inf",-3],[0,"inf","inf"]]);
# > $A2 = new Matrix<TropicalNumber<Min>>([["inf","inf",-1],[0,"inf",-1],[0,"inf","inf"],[0,-1,"inf"],["inf",0,0]]);
# > $Q = new Polytope<Min>(INEQUALITIES=>[$A1,$A2]);
# > print $Q->VERTICES;
# | 0 0 2
# | 0 1 0
# | 0 3 3
# | 0 4 1
declare object Polytope<Addition, Scalar=Rational> [ is_ordered_field_with_unlimited_precision(Scalar) ];

# A tropical cycle is a weighted, balanced, pure polyhedral complex.
# It is given as a polyhedral complex in tropical projective coordinates.
# To be precise: Each row of [[VERTICES]] and [[LINEALITY_SPACE]]
# has a leading 1 or 0, depending on whether it is a vertex or a ray.
# The remaining n coordinates are interpreted as an element of
# R<sup>n</sup> modulo (1,..,1).
# IMPORTANT NOTE: VERTICES are assumed to be normalized such that the first coordinate (i.e.
# column index 1) is 0. If your input is not of that form, use [[PROJECTIVE_VERTICES]].
# Note that there is a convenience method [[thomog]], which converts affine coordinates
# into projective coordinates.
# @tparam Addition The tropical addition. Warning: There is NO default for this, you have to choose either [[Max]] or [[Min]].
declare object Cycle<Addition> : fan::PolyhedralComplex<Rational>;

# Tropical hypersurface in the tropical projective torus R^d/R1.
# This is a special instance of a Cycle: It is the tropical locus of a
# homogeneous polynomial over the tropical numbers.
# Note: Homogeneity of the [[MONOMIALS]] is never checked.
# @tparam Addition The tropical addition. Warning: There is NO default for this, you have to choose either [[Max]] or [[Min]].
# @example The following yields a tropical plane conic.
# > $C=new Hypersurface<Min>(MONOMIALS=>[ [2,0,0],[1,1,0],[0,2,0],[1,0,1],[0,1,1],[0,0,2] ], COEFFICIENTS=>[6,5,6,5,5,7]);
declare object Hypersurface<Addition> : Cycle<Addition>;

# This encodes a patchworking structure on a hypersurface.
declare object Patchwork;

# Abstract tropical curve, possibly with marked edges, edge lengths, vertex weights.
# Additional functionality for moduli space computations.
# @tparam Scalar Edge length type.
# @example We construct a tropical quartic curve of genus 3.
# Edge labels as in Fig. 4 (000) on Brodsky et al., Res. Math. Sci (2015).
# > ($u,$v,$w,$x,$y,$z)=0..5;
# > $skeleton = new IncidenceMatrix([[$u,$v,$x],[$v,$w,$z],[$u,$w,$y],[$x,$y,$z]]);
# > $quartic = new tropical::Curve(EDGES_THROUGH_VERTICES=>$skeleton, EDGE_LENGTHS=>[1,2,3,4,5,6]);
declare object Curve<Scalar=Rational> [ is_ordered_field(Scalar) ];


INCLUDE
  cycle.rules
  hypersurface.rules
  covector_lattice.rules
  cone_properties.rules
  cone.rules
  gfan.rules
  #FIXME Add connection to tplib again?
  #tplib.rules
  visual.rules
  visual_covector.rules
  patchwork.rules
  voronoi.rules
  curve.rules

# Local Variables:
# mode: perl
# cperl-indent-level: 3
# indent-tabs-mode:nil
# End:
