test_galois.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. """Test groups defined by the galois module. """
  2. from sympy.combinatorics.galois import (
  3. S4TransitiveSubgroups, S5TransitiveSubgroups, S6TransitiveSubgroups,
  4. find_transitive_subgroups_of_S6,
  5. )
  6. from sympy.combinatorics.homomorphisms import is_isomorphic
  7. from sympy.combinatorics.named_groups import (
  8. SymmetricGroup, AlternatingGroup, CyclicGroup,
  9. )
  10. def test_four_group():
  11. G = S4TransitiveSubgroups.V.get_perm_group()
  12. A4 = AlternatingGroup(4)
  13. assert G.is_subgroup(A4)
  14. assert G.degree == 4
  15. assert G.is_transitive()
  16. assert G.order() == 4
  17. assert not G.is_cyclic
  18. def test_M20():
  19. G = S5TransitiveSubgroups.M20.get_perm_group()
  20. S5 = SymmetricGroup(5)
  21. A5 = AlternatingGroup(5)
  22. assert G.is_subgroup(S5)
  23. assert not G.is_subgroup(A5)
  24. assert G.degree == 5
  25. assert G.is_transitive()
  26. assert G.order() == 20
  27. # Setting this True means that for each of the transitive subgroups of S6,
  28. # we run a test not only on the fixed representation, but also on one freshly
  29. # generated by the search procedure.
  30. INCLUDE_SEARCH_REPS = False
  31. S6_randomized = {}
  32. if INCLUDE_SEARCH_REPS:
  33. S6_randomized = find_transitive_subgroups_of_S6(*list(S6TransitiveSubgroups))
  34. def get_versions_of_S6_subgroup(name):
  35. vers = [name.get_perm_group()]
  36. if INCLUDE_SEARCH_REPS:
  37. vers.append(S6_randomized[name])
  38. return vers
  39. def test_S6_transitive_subgroups():
  40. """
  41. Test enough characteristics to distinguish all 16 transitive subgroups.
  42. """
  43. ts = S6TransitiveSubgroups
  44. A6 = AlternatingGroup(6)
  45. for name, alt, order, is_isom, not_isom in [
  46. (ts.C6, False, 6, CyclicGroup(6), None),
  47. (ts.S3, False, 6, SymmetricGroup(3), None),
  48. (ts.D6, False, 12, None, None),
  49. (ts.A4, True, 12, None, None),
  50. (ts.G18, False, 18, None, None),
  51. (ts.A4xC2, False, 24, None, SymmetricGroup(4)),
  52. (ts.S4m, False, 24, SymmetricGroup(4), None),
  53. (ts.S4p, True, 24, None, None),
  54. (ts.G36m, False, 36, None, None),
  55. (ts.G36p, True, 36, None, None),
  56. (ts.S4xC2, False, 48, None, None),
  57. (ts.PSL2F5, True, 60, None, None),
  58. (ts.G72, False, 72, None, None),
  59. (ts.PGL2F5, False, 120, None, None),
  60. (ts.A6, True, 360, None, None),
  61. (ts.S6, False, 720, None, None),
  62. ]:
  63. for G in get_versions_of_S6_subgroup(name):
  64. assert G.is_transitive()
  65. assert G.degree == 6
  66. assert G.is_subgroup(A6) is alt
  67. assert G.order() == order
  68. if is_isom:
  69. assert is_isomorphic(G, is_isom)
  70. if not_isom:
  71. assert not is_isomorphic(G, not_isom)