| 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 | |