def verify_representation(self): r""" Verify the representation: tests that the images of the simple transpositions are involutions and tests that the braid relations hold. EXAMPLES:: sage: spc = SymmetricGroupRepresentation([1,1,1]) sage: spc.verify_representation() True sage: spc = SymmetricGroupRepresentation([4,2,1]) sage: spc.verify_representation() True """ n = self._partition.size() transpositions = [] for i in range(1,n): si = Permutation(range(1,i) + [i+1,i] + range(i+2,n+1)) transpositions.append(si) repn_matrices = map(self.representation_matrix, transpositions) for (i,si) in enumerate(repn_matrices): for (j,sj) in enumerate(repn_matrices): if i == j: if si*sj != si.parent().identity_matrix(): return False, "si si != 1 for i = %s" % (i,) elif abs(i-j) > 1: if si*sj != sj*si: return False, "si sj != sj si for (i,j) =(%s,%s)" % (i,j) else: if si*sj*si != sj*si*sj: return False, "si sj si != sj si sj for (i,j) = (%s,%s)" % (i,j) return True
def verify_representation(self): r""" Verify the representation: tests that the images of the simple transpositions are involutions and tests that the braid relations hold. EXAMPLES:: sage: spc = SymmetricGroupRepresentation([1,1,1]) sage: spc.verify_representation() True sage: spc = SymmetricGroupRepresentation([4,2,1]) sage: spc.verify_representation() True """ n = self._partition.size() transpositions = [] for i in range(1, n): si = Permutation(range(1, i) + [i + 1, i] + range(i + 2, n + 1)) transpositions.append(si) repn_matrices = map(self.representation_matrix, transpositions) for (i, si) in enumerate(repn_matrices): for (j, sj) in enumerate(repn_matrices): if i == j: if si * sj != si.parent().identity_matrix(): return False, "si si != 1 for i = %s" % (i, ) elif abs(i - j) > 1: if si * sj != sj * si: return False, "si sj != sj si for (i,j) =(%s,%s)" % (i, j) else: if si * sj * si != sj * si * sj: return False, "si sj si != sj si sj for (i,j) = (%s,%s)" % ( i, j) return True
def _element_constructor_(self, x): r""" Convert ``x`` into ``self``. EXAMPLES:: sage: R = algebras.FQSym(QQ).G() sage: x, y, z = R([1]), R([2,1]), R([3,2,1]) sage: R(x) G[1] sage: R(x+4*y) G[1] + 4*G[2, 1] sage: R(1) G[] sage: D = algebras.FQSym(ZZ).G() sage: X, Y, Z = D([1]), D([2,1]), D([3,2,1]) sage: R(X-Y).parent() Free Quasi-symmetric functions over Rational Field in the G basis sage: R([1, 3, 2]) G[1, 3, 2] sage: R(Permutation([1, 3, 2])) G[1, 3, 2] sage: R(SymmetricGroup(4)(Permutation([1,3,4,2]))) G[1, 3, 4, 2] sage: RF = algebras.FQSym(QQ).F() sage: R(RF([2, 3, 4, 1])) G[4, 1, 2, 3] sage: R(RF([3, 2, 4, 1])) G[4, 2, 1, 3] sage: DF = algebras.FQSym(ZZ).F() sage: D(DF([2, 3, 4, 1])) G[4, 1, 2, 3] sage: R(DF([2, 3, 4, 1])) G[4, 1, 2, 3] sage: RF(R[2, 3, 4, 1]) F[4, 1, 2, 3] """ if isinstance(x, (list, tuple, PermutationGroupElement)): x = Permutation(x) try: P = x.parent() if isinstance(P, FreeQuasisymmetricFunctions.G): if P is self: return x return self.element_class(self, x.monomial_coefficients()) except AttributeError: pass return CombinatorialFreeModule._element_constructor_(self, x)
def _element_constructor_(self, x): r""" Convert ``x`` into ``self``. EXAMPLES:: sage: R = algebras.FQSym(QQ).F() sage: x, y, z = R([1]), R([2,1]), R([3,2,1]) sage: R(x) F[1] sage: R(x+4*y) F[1] + 4*F[2, 1] sage: R(1) F[] sage: D = algebras.FQSym(ZZ).F() sage: X, Y, Z = D([1]), D([2,1]), D([3,2,1]) sage: R(X-Y).parent() Free Quasi-symmetric functions over Rational Field in the F basis sage: R([1, 3, 2]) F[1, 3, 2] sage: R(Permutation([1, 3, 2])) F[1, 3, 2] sage: R(SymmetricGroup(4)(Permutation([1,3,4,2]))) F[1, 3, 4, 2] """ if isinstance(x, (list, tuple, PermutationGroupElement)): x = Permutation(x) try: P = x.parent() if isinstance(P, FreeQuasisymmetricFunctions.F): if P is self: return x return self.element_class(self, x.monomial_coefficients()) except AttributeError: pass return CombinatorialFreeModule._element_constructor_(self, x)