def test_coset_enumeration(self): g1 = Permutation.read_cycle_form([[1,2,3,4]], 4) g2 = Permutation.read_cycle_form([[1,2]], 4) h1 = Permutation.read_cycle_form([[1,2,3]], 4) h2 = Permutation.read_cycle_form([[1,2]], 4) G = PermGroup([g1, g2]) H = PermGroup([h1, h2]) cosets = G._left_cosets(H) total = 0 elements = [] for coset in cosets: temp_eles = coset._list_elements() elements += temp_eles self.assertEqual(len(temp_eles),len(H)) total += len(temp_eles) self.assertEqual(len(G), total) self.assertEqual(sorted(G._list_elements()), sorted(elements)) cosets = G._right_cosets(H) total = 0 elements = [] for coset in cosets: temp_eles = coset._list_elements() elements += temp_eles self.assertEqual(len(temp_eles),len(H)) total += len(temp_eles) self.assertEqual(len(G), total) self.assertEqual(sorted(G._list_elements()), sorted(elements))
from group import PermGroup from permutation import Permutation _base_size = 6 cf = lambda x : Permutation.read_cycle_form(x, _base_size) a= cf([[1,2,3,4]]) b= cf([[1,2]]) c= cf([[1,2,3]]) s4 = PermGroup([a,b]) s3 = PermGroup([b,c]) for coset in s4._right_cosets(s3): print(coset._list_elements()) for coset in s4._left_cosets(s3): print(coset._list_elements()) cf = Permutation.read_cycle_form a = cf([[1, 2, 3,4,5]],5) b = cf([[1,2,3]], 5) G=PermGroup([a,b]) print(len(G))