class FaceMonoid(Parent): def __init__(self, generators): Parent.__init__(self, category = FiniteMonoids()) self._semigroup_generators = generators def _repr_(self): return "Un monoïde de vecteurs signes engendré par: %s" % (self._semigroup_generators) def one(self): length = len(self._semigroup_generators[0]) return self((0,) * length) def product(self, x, y): xv = x.value yv = y.value z = tuple([xv[i] if xv[i] != 0 else yv[i] for i in range(len(xv))]) return self(z) def semigroup_generators(self): return [self.one()] + [self(g) for g in self._semigroup_generators] class Element(ElementWrapper): wrapped_class = tuple def _repr_(self): d = {0:'0', 1:'+', -1:'-'} return "".join([d[i] for i in self.value])