test_pc_groups.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. from sympy.combinatorics.permutations import Permutation
  2. from sympy.combinatorics.named_groups import SymmetricGroup, AlternatingGroup, DihedralGroup
  3. from sympy.matrices import Matrix
  4. def test_pc_presentation():
  5. Groups = [SymmetricGroup(3), SymmetricGroup(4), SymmetricGroup(9).sylow_subgroup(3),
  6. SymmetricGroup(9).sylow_subgroup(2), SymmetricGroup(8).sylow_subgroup(2), DihedralGroup(10)]
  7. S = SymmetricGroup(125).sylow_subgroup(5)
  8. G = S.derived_series()[2]
  9. Groups.append(G)
  10. G = SymmetricGroup(25).sylow_subgroup(5)
  11. Groups.append(G)
  12. S = SymmetricGroup(11**2).sylow_subgroup(11)
  13. G = S.derived_series()[2]
  14. Groups.append(G)
  15. for G in Groups:
  16. PcGroup = G.polycyclic_group()
  17. collector = PcGroup.collector
  18. pc_presentation = collector.pc_presentation
  19. pcgs = PcGroup.pcgs
  20. free_group = collector.free_group
  21. free_to_perm = {}
  22. for s, g in zip(free_group.symbols, pcgs):
  23. free_to_perm[s] = g
  24. for k, v in pc_presentation.items():
  25. k_array = k.array_form
  26. if v != ():
  27. v_array = v.array_form
  28. lhs = Permutation()
  29. for gen in k_array:
  30. s = gen[0]
  31. e = gen[1]
  32. lhs = lhs*free_to_perm[s]**e
  33. if v == ():
  34. assert lhs.is_identity
  35. continue
  36. rhs = Permutation()
  37. for gen in v_array:
  38. s = gen[0]
  39. e = gen[1]
  40. rhs = rhs*free_to_perm[s]**e
  41. assert lhs == rhs
  42. def test_exponent_vector():
  43. Groups = [SymmetricGroup(3), SymmetricGroup(4), SymmetricGroup(9).sylow_subgroup(3),
  44. SymmetricGroup(9).sylow_subgroup(2), SymmetricGroup(8).sylow_subgroup(2)]
  45. for G in Groups:
  46. PcGroup = G.polycyclic_group()
  47. collector = PcGroup.collector
  48. pcgs = PcGroup.pcgs
  49. # free_group = collector.free_group
  50. for gen in G.generators:
  51. exp = collector.exponent_vector(gen)
  52. g = Permutation()
  53. for i in range(len(exp)):
  54. g = g*pcgs[i]**exp[i] if exp[i] else g
  55. assert g == gen
  56. def test_induced_pcgs():
  57. G = [SymmetricGroup(9).sylow_subgroup(3), SymmetricGroup(20).sylow_subgroup(2), AlternatingGroup(4),
  58. DihedralGroup(4), DihedralGroup(10), DihedralGroup(9), SymmetricGroup(3), SymmetricGroup(4)]
  59. for g in G:
  60. PcGroup = g.polycyclic_group()
  61. collector = PcGroup.collector
  62. gens = list(g.generators)
  63. ipcgs = collector.induced_pcgs(gens)
  64. m = []
  65. for i in ipcgs:
  66. m.append(collector.exponent_vector(i))
  67. assert Matrix(m).is_upper