def naive_min_gen(original_group, ordering): eles = original_group._list_elements(key = ordering_to_perm_key(ordering)) cur_gens = [eles[1]] cur_G = Group.fixed_base_group(cur_gens, ordering) for ele in eles: if ele not in cur_G: cur_gens.append(ele) cur_G = Group.fixed_base_group(cur_gens, ordering) if cur_G.order() == G.order(): break return cur_gens
def test_element_at_index(self): cf = Permutation.read_cycle_form a = cf([[1, 2, 3,4,5]],5) b = cf([[1,2,3]], 5) e = cf([],5) ordering = [3,5,2,1,4] base, _, _, graphs = schreier_sims_algorithm_fixed_base([a,b], ordering, e) full_group = [] ele_key = ordering_to_key(ordering) perm_key = ordering_to_perm_key(ordering) for index in range(group_size(graphs)): full_group.append(element_at_index(base, graphs, index, e, key=ele_key)) ordered_group = sorted(full_group, key = perm_key) #for x,y in zip(full_group, ordered_group): #print("{!s:<20} {!s:<20}".format(x,y)) self.assertEqual(full_group, ordered_group)
def test_memebership_index(self): cf = Permutation.read_cycle_form a = cf([[1, 2, 3,4,5]],5) b = cf([[1,2,3]], 5) c = cf([[1,2]], 5) e = cf([],5) ordering = [3,5,2,1,4] base, _, _, graphs = schreier_sims_algorithm_fixed_base([a,b], ordering, e) S5_base, _, _, S5_graphs = schreier_sims_algorithm_fixed_base([a,c], ordering, e) real_group = [] S5_group = [] ele_key = ordering_to_key(ordering) perm_key = ordering_to_perm_key(ordering) for index in range(group_size(S5_graphs)): S5_group.append(element_at_index(S5_base, S5_graphs, index, e, key=ele_key)) self.assertEquals(len(S5_group), 120) self.assertEquals(S5_group, sorted(S5_group, key = perm_key)) for index in range(group_size(graphs)): real_group.append(element_at_index(base, graphs, index, e, key=ele_key)) self.assertEquals(len(real_group), 60) self.assertEquals(real_group, sorted(real_group, key = perm_key)) for ele in S5_group: cand_index = membership_index(ele, graphs, base, e, key = ele_key) if cand_index > -1: #print("{}: {} {}?".format(cand_index, ele, real_group[cand_index])) self.assertTrue(ele in real_group) self.assertEquals(real_group[cand_index], ele) else: self.assertFalse(ele in real_group)
def find_partition_backtrack_subgroup(self): #Assume the refinement families are symmetric. generators = [] r_base = self._r_base() count = 0 leaf_count = 0 if self.printing: print("-----------------------------------") print("Traversing tree:") while self._cur_height > -1: count += 1 if self.printing: a = self._cur_position b = self.right[self._cur_height] c = self.left[self._cur_height] print("\n{}: {}\n{} -> {}".format(self._cur_height,a,c,b)) #Alternatice 1: premature rule out. if self.alt1(): if self.printing: print("Alternative 1: partition violation") #print("alt_1") self.backtrack(self._cur_height - 1) #Alternative 2: discrete check. elif self.right.discrete(): leaf_count += 1 #print("alt_2") perm = Permutation.read_partitions(self.left[self._cur_height], self.right[self._cur_height]) if self.double_coset_check and self.printing: G=PermGroup(generators) Dco = G*perm*G perm_key = ordering.ordering_to_perm_key(self.left.fix()) if Dco.mid_minimal(key = perm_key): print("Actually minimal in own double coset: {}".format(Dco._list_elements(Perm_key))) added = False if not perm.trivial() and self.group_property.check(perm): generators.append(perm) added = True #self.backtrack() if self.printing: print("Alternative 2 found permutation: {} ({})".format(perm, added)) if self.multi_backtrack and added: self.backtrack(self._cur_position.min_changed_index()) else: self.backtrack() #Alternative 3: not a special level elif r_base[self._cur_height] is not None: #print("alt_3") r_base[self._cur_height](None, self.right) if self.printing: print("Alternative 3 applying function: {}".format(r_base[self._cur_height]._info)) self._cur_height += 1 #Alternative 4: is a special level else: if self.printing: print("Alternative 4 special level") #print("alt_4") self.extend_right() if self.printing: print("\nFinished tree traversal.") print("Visited {} vertices ({} of which were terminal).".format(count, leaf_count)) return generators
from coset_property import CosetProperty as Prop from coset_property import PermutationCommuterProperty import sims_search from ordering import ordering_to_key, ordering_to_perm_key #Set up group generators cf = Permutation.read_cycle_form a = cf([[2,3],[4,6],[5,8],[9,11]], 13) b = cf([[1,2,4,7,9,3,5,6,8,10,11,12,13]], 13) #Define ordering of base elements fix = [1,3,5,9,7,11,2,12,4,6,8,10,13] #Define corresponding key functions on numbers and perms based on base element ordering key_single = ordering_to_key(fix) key_perm = ordering_to_perm_key(fix) #Construct group G = Group.fixed_base_group([a,b],fix) #Find all elements in order #Print the base and stab orbits of G. print(G.base) level_orbits = [] for level in range(len(G.base)): to_check = sorted(G.orbit(G.base[level],level), key = key_single) level_orbits.append(to_check) print(to_check) #Set up the modulo values for a naive traversal. mods = [len(orbit) for orbit in level_orbits]