#  Copyright (c) 1997-2010
#  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: main.rules 9547 2010-03-09 07:21:34Z smoeser $

# @topic application
# 
# Matroids encode the concept of "(in)dependence" in an abstract way.  You
# can define matroids via vector configurations or graphs, do basic
# conversions between different descriptions and perform basic operations such
# as deletions and contractions.

IMPORT
  common

USE
  polytope tropical

file_suffix mat

# A matroid on the set //{0,...,n-1}//.  Here //n// is the same as [[N_ELEMENTS]].
# 
declare object Matroid;

INCLUDE
  matroid_properties.rules


object Matroid {


rule RANK : BASES {
  $this->RANK = @{$this->BASES->[0]};
} 
weight 0.10;

rule BASES, N_BASES, RANK, N_ELEMENTS : POINTS {
  bases_from_points($this)
}

rule POLYTOPE : BASES, N_ELEMENTS {
  matroid_polytope($this)
}

rule BASES : NON_BASES, N_ELEMENTS {
  $this->BASES = invert_bases($this->NON_BASES, $this->N_ELEMENTS)
}
weight 3.10;

rule NON_BASES : BASES, N_ELEMENTS {
  $this->NON_BASES = invert_bases($this->BASES, $this->N_ELEMENTS)
}
weight 3.10;

rule CIRCUITS : BASES, N_ELEMENTS {
   $this->CIRCUITS = bases_to_circuits($this->BASES, $this->N_ELEMENTS);
}
weight 4.10;

rule COCIRCUITS : BASES, N_ELEMENTS {
   $this->COCIRCUITS = bases_to_cocircuits($this->BASES, $this->N_ELEMENTS);
}
weight 4.10;


rule BASES : CIRCUITS, N_ELEMENTS {
   $this->BASES = circuits_to_bases($this->CIRCUITS, $this->N_ELEMENTS);
}
weight 4.10;

rule BASES : COCIRCUITS, N_ELEMENTS {
   $this->BASES = cocircuits_to_bases($this->COCIRCUITS, $this->N_ELEMENTS);
}
weight 4.10;

rule BASES : CIRCUITS, N_ELEMENTS, RANK {
   $this->BASES = circuits_to_bases_rank($this->CIRCUITS, $this->N_ELEMENTS, $this->RANK);
}
weight 3.10;

rule BASES : COCIRCUITS, N_ELEMENTS, RANK {
   $this->BASES = cocircuits_to_bases_rank($this->COCIRCUITS, $this->N_ELEMENTS, $this->RANK);
}
weight 3.10;


rule N_BASES : BASES {
   $this->N_BASES = @{$this->BASES};
}
weight 0.10;

rule N_CIRCUITS : CIRCUITS {
   $this->N_CIRCUITS = @{$this->CIRCUITS};
}
weight 0.10;

rule N_COCIRCUITS : COCIRCUITS {
   $this->N_COCIRCUITS = @{$this->COCIRCUITS};
}
weight 0.10;

}


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