#  Copyright (c) 1997-2015
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
#  http://www.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.
#-------------------------------------------------------------------------------

object Ideal {

   rule PRIMARY : {
      $this->PRIMARY = 1;
   }
   precondition : PRIME;

   rule PRIMARY : RADICAL.PRIME {
      $this->PRIMARY = $this->RADICAL->PRIME;
   }

   rule RING : GENERATORS {
      my $gens = $this->GENERATORS;
      $this->RING = $gens->[0]->get_ring;
   }
   precondition : !ZERO;

   rule ZERO : GENERATORS {
      foreach my $p (@{$this->GENERATORS}){
         if(!$p->trivial){
            $this->ZERO = 0;
            return;
         }
      }
      $this->ZERO = 1;
   }

}

object Groebner {
      
   rule initial :  {
      if (my $order = $this->lookup("ORDER_NAME")) {
         $order =~ /^(dp|Dp|lp|Lp|rp|ls|rs|ds|Ds)$/ or croak ("unknown term order");
      } elsif ( ! defined($this->lookup("ORDER_VECTOR | ORDER_MATRIX"))) {
         croak ("no term order specified");
      }
   }

}

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