Skip to content

Commit bcac6d4

Browse files
mantepsedimpase
authored andcommitted
add is_trivial method
1 parent e2e0f8d commit bcac6d4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/sage/groups/perm_gps/permgroup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,29 @@ def ngens(self):
13651365
"""
13661366
return len(self.gens())
13671367

1368+
def is_trivial(self):
1369+
r"""
1370+
Return ``True`` if this group is the trivial group.
1371+
1372+
A permutation group is trivial, if it consists only of the
1373+
identity element, that is, if it has no generators.
1374+
1375+
EXAMPLES::
1376+
1377+
sage: G = PermutationGroup([], domain=["a", "b", "c"])
1378+
sage: G.is_trivial()
1379+
True
1380+
sage: SymmetricGroup(0).is_trivial()
1381+
True
1382+
sage: SymmetricGroup(1).is_trivial()
1383+
True
1384+
sage: SymmetricGroup(2).is_trivial()
1385+
False
1386+
sage: DihedralGroup(1).is_trivial()
1387+
False
1388+
"""
1389+
return not self._gens or (len(self._gens) == 1 and self._gens[0].is_one())
1390+
13681391
@cached_method
13691392
def one(self):
13701393
"""

0 commit comments

Comments
 (0)