#  Copyright (c) 1997-2004
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
#  http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.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: plausible.rules,v 1.14 2004/10/26 18:53:46 gawrilow Exp $


# category: Consistency check
# Checks the consistency of various properties of the polyhedron.
#
user_method CHECK {
   my ($this)=@_;
   my $d=$this->AMBIENT_DIM;
   my $ok=1;
   foreach my $prop (qw(POINTS VERTICES INEQUALITIES FACETS EQUATIONS AFFINE_HULL
			REL_INT_POINT FAR_HYPERPLANE)) {
      foreach ($this->lookup($prop)) {
	 if (split != $d) {
	    print "dimension mismatch in '$prop': [$_]\n";
	    $ok=0;
	 }
      }
   }
   if ($ok) {
      my $v = $Switches::v ? "-v" : "-q";
      client("check_inc", $this, 'POINTS',        'INEQUALITIES',   '0+', $v);
      client("check_inc", $this, 'POINTS',        'FACETS',         '0+', $v);
      client("check_inc", $this, 'POINTS',        'EQUATIONS',      '0',  $v);
      client("check_inc", $this, 'VERTICES',      'INEQUALITIES',   '0+', $v);
      client("check_inc", $this, 'VERTICES',      'FACETS',         '0+', $v);
      client("check_inc", $this, 'VERTICES',      'EQUATIONS',      '0',  $v);
      client("check_inc", $this, 'REL_INT_POINT', 'INEQUALITIES',   '+',  $v);
      client("check_inc", $this, 'REL_INT_POINT', 'FACETS',         '+',  $v);
      client("check_inc", $this, 'REL_INT_POINT', 'EQUATIONS',      '0',  $v);
      client("check_inc", $this, 'POINTS',        'FAR_HYPERPLANE', '+',  $v);
      client("check_inc", $this, 'POINTS',        'AFFINE_HULL',    '0',  $v);
      client("check_inc", $this, 'VERTICES',      'FAR_HYPERPLANE', '+',  $v);
      client("check_inc", $this, 'VERTICES',      'AFFINE_HULL',    '0',  $v);
      print "done\n";
   }
   1
}


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