def test_involutions(): assert set(Permutation.involutions(1)) == {Permutation()} assert set(Permutation.involutions(1, True)) == {Permutation(), Permutation(-1)} assert set(Permutation.involutions(2)) == {Permutation(), Permutation(2, 1)} assert set(Permutation.involutions(2, True)) == { Permutation(), Permutation(-1), Permutation(2, 1), Permutation(-2, -1), Permutation(-1, -2), Permutation(1, -2) } n = 6 assert set(Permutation.involutions(n)) == { w for w in Permutation.all(n) if w.inverse() == w } assert set(Permutation.involutions(n, True)) == { w for w in Permutation.all(n, True) if w.inverse() == w } assert len(set(Permutation.involutions(n))) == len(list(Permutation.involutions(n))) assert set(Permutation.fpf_involutions(4)) == { Permutation(2, 1, 4, 3), Permutation(3, 4, 1, 2), Permutation(4, 3, 2, 1), }
def all(cls, n, k, l, decreasing=False): for w in Permutation.all(n): if w(n) == n: continue cg = cls(w.oneline, k, l, decreasing) if cg.edges: cg.generate()
def test_transitions_finite(): n = 4 for w in Permutation.all(n): for r in range(1, n + 1): phi_plus = {w * Permutation.transposition(r, j) for j in w.upper_transitions(r)} phi_minus = {w * Permutation.transposition(i, r) for i in w.lower_transitions(r)} assert all(w in v.bruhat_covers() for v in phi_plus) assert all(w in v.bruhat_covers() for v in phi_minus)
def test_transitions_all(): n = 4 for w in Permutation.all(n): for r in range(1, n + 1): phi_plus = {w * Permutation.transposition(r, j, n) for j in w.upper_transitions(r)} phi_minus = {w * Permutation.transposition(i, r, n) for i in w.lower_transitions(r)} assert all(w in v.bruhat_covers() for v in phi_plus) assert all(w in v.bruhat_covers() for v in phi_minus) print (w.get_reduced_word()) print(r) print([x.get_reduced_word() for x in phi_plus]) print([x.get_reduced_word() for x in phi_minus])
def test_all(): ans = 1 for n in range(2, 6): ans *= n assert len({w for w in Permutation.all(n, signed=False)}) == ans