Ticket #10871: trac_10871-intersection-permutation-groups-v2.patch

File trac_10871-intersection-permutation-groups-v2.patch, 2.5 KB (added by rbeezer, 10 years ago)
  • sage/groups/perm_gps/permgroup.py

    # HG changeset patch
    # User Rob Beezer <beezer@ups.edu>
    # Date 1299188053 28800
    # Node ID c1af1d0a24733a90ffac4247374a34e2e6c7aabc
    # Parent  8438b7c20d79c02a2ece3e1c3f7224a772ff8f07
    10871: intersection of permutation groups
    
    diff -r 8438b7c20d79 -r c1af1d0a2473 sage/groups/perm_gps/permgroup.py
    a b  
    11631163        C = self._gap_().Center()
    11641164        return PermutationGroup(gap_group=C)
    11651165
     1166    def intersection(self, other):
     1167        r"""
     1168        Returns the permutation group that is the intersection of
     1169        ``self`` and ``other``.
     1170
     1171        INPUT:
     1172
     1173        - ``other`` - a permutation group.
     1174
     1175        OUTPUT:
     1176
     1177        A permutation group that is the set-theoretic intersection of ``self``
     1178        with ``other``.  The groups are viewed as subgroups of a symmetric
     1179        group big enough to contain both group's symbol sets.  So there is
     1180        no strict notion of the two groups being subgroups of a common parent.
     1181
     1182        EXAMPLES::
     1183
     1184            sage: H = DihedralGroup(4)
     1185
     1186            sage: K = CyclicPermutationGroup(4)
     1187            sage: H.intersection(K)
     1188            Permutation Group with generators [(1,2,3,4)]
     1189
     1190            sage: L = DihedralGroup(5)
     1191            sage: H.intersection(L)
     1192            Permutation Group with generators [(1,4)(2,3)]
     1193
     1194            sage: M = PermutationGroup(["()"])
     1195            sage: H.intersection(M)
     1196            Permutation Group with generators [()]
     1197
     1198        Some basic properties. ::
     1199
     1200            sage: H = DihedralGroup(4)
     1201            sage: L = DihedralGroup(5)
     1202            sage: H.intersection(L) == L.intersection(H)
     1203            True
     1204            sage: H.intersection(H) == H
     1205            True
     1206
     1207        The group ``other`` is verified as such.  ::
     1208
     1209            sage: H = DihedralGroup(4)
     1210            sage: H.intersection('junk')
     1211            Traceback (most recent call last):
     1212            ...
     1213            TypeError: junk is not a permutation group
     1214        """
     1215        from sage.categories.finite_permutation_groups import FinitePermutationGroups
     1216        if other not in FinitePermutationGroups():
     1217            raise TypeError("{0} is not a permutation group".format(other))
     1218        return PermutationGroup(gap_group=gap.Intersection(self, other))
     1219
    11661220    def direct_product(self,other,maps=True):
    11671221        """
    11681222        Wraps GAP's ``DirectProduct``, ``Embedding``, and ``Projection``.