Skip to content

Commit 0fb7727

Browse files
author
Release Manager
committed
gh-36884: Method braid of class Link loops when the Link contains loops <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> The following link `L` is ambient isotopic to the treefoil knot but has one additional loop. ![grafik](https://github.com/sagemath/sage/assets/47305845/499d14f9- fe72-406a-8a23-cd94bd0000f1) ``` sage: L = Link([[1, 7, 2, 6], [3, 1, 4, 8], [5, 5, 6, 4], [7, 3, 8, 2]]) sage: L.regions()` [[-5], [8, 4, 6, 2], [7, -2], [3, -8], [1, -6, 5, -4], [-1, -3, -7]] sage: L.seifert_circles() [[5], [1, 7, 3], [2, 8, 4, 6]] ``` Invoking `L.braid()` does not terminate. The problem already occurs on the first application of a Vogel move which leads to an extended `pd_code = [[10, 7, 2, 6], [3, 1, 4, 8], [11, 5, 6, 4], [7, 3, 8, 2], [12, 9, 5, 1], [11, 9, 12, 10]]`. A diagram of the corresponding link looks like this: ![grafik](https://github.com/sagemath/sage/assets/47305845/5508593b- b095-4f87-9019-7cfbfe6b4453) The labels `C1`, `C2 = [3, 1, 4, 8]`, `D = [11, 9, 12, 10]` and `E = [12, 9, 5, 1]` correspond to the variables in the code and the numbers to the edges. In case of `C1`the correct list of edges would be `[5, 11, 6, 4]` but the code produces `[11, 5, 6, 4]`. This is caused by usage of the `index` method of the `list` class which always returns the first occurrence of a value in the list, i.e. by the line: ``` C2[C2.index(b)] = newedge + 2 ``` To fix it I replace the method by a local function: ``` def idx(cross, edge): r""" Return the index of an edge in a crossing taking loops into account. A loop appears as an edge which occurs twice in the crossing. In all cases the second occurrence is the correct one needed in the Vogel algorithm. """ i = cross.index(edge) if cross.count(edge) > 1: return cross.index(edge, i+1) else: return i ``` > In all cases the second occurrence is the correct one needed in the Vogel algorithm. The according argumentation goes as follows: If the loop is clockwise oriented the edge has a positive sign in the region, else a negative sign. In the first case the outgoing side of the edge always occurs after the incoming one in the PD-code (edge 1 in the first picture below and edge 2 in the second). In the second case the incoming side of the edge always occurs after the outgoing one in the PD-code (edge 2 in the first picture below and edge 1 in the second). ![grafik](https://github.com/sagemath/sage/assets/47305845/224324c4- d392-4944-8406-586838b164ea) ![grafik](https://github.com/sagemath/sage/ assets/47305845/21548500-777f-4a79-99d7-0e59c3bfd8a1) Thus, this corresponds to the fact that in the first case `a` and `b` leave the crossings `C1` and `C2` (in the original link) whereas they arrive there in the second case. Another way to fix the issue would be to remove all loops from the diagram before starting the Vogel algorithm. But this would harm regular isotopy which might violate the expectation of the user. Thus, I implement this as an optional feature. This gives the user the possibility to obtain a braid of smaller index if he is fine with ambient isotopy. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36884 Reported by: Sebastian Oehms Reviewer(s): Sebastian Oehms, Travis Scrimshaw
2 parents 5d7d2e3 + f68c72a commit 0fb7727

File tree

1 file changed

+95
-10
lines changed

1 file changed

+95
-10
lines changed

src/sage/knots/link.py

Lines changed: 95 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,17 @@ def __ne__(self, other):
610610
"""
611611
return not self.__eq__(other)
612612

613-
def braid(self):
613+
def braid(self, remove_loops=False):
614614
r"""
615615
Return a braid representation of ``self``.
616616
617+
INPUT:
618+
619+
- ``remove_loops`` -- boolean (default: ``False``). If set to ``True``
620+
loops will be removed first. This can reduce the number of strands
621+
needed for an ambient isotopic braid closure. However, this can lead
622+
to a loss of the regular isotopy.
623+
617624
OUTPUT: an element in the braid group
618625
619626
.. WARNING::
@@ -634,6 +641,14 @@ def braid(self):
634641
sage: L.braid()
635642
(s0*s1^-1)^2*s1^-1
636643
644+
using ``remove_loops=True``::
645+
646+
sage: L = Link([[2, 7, 1, 1], [7, 3, 9, 2], [4, 11, 3, 9], [11, 5, 5, 4]])
647+
sage: L.braid()
648+
s0*s1^-1*s2*s3^-1
649+
sage: L.braid(remove_loops=True)
650+
1
651+
637652
TESTS::
638653
639654
sage: L = Link([])
@@ -648,7 +663,20 @@ def braid(self):
648663
sage: A = Link([[[1, 2, -2, -1, -3, -4, 4, 3]], [1, 1, 1, 1]])
649664
sage: A.braid()
650665
s0*s1*s2*s3
666+
667+
Check that :issue:`36884` is solved::
668+
669+
sage: L = Link([[1, 7, 2, 6], [3, 1, 4, 8], [5, 5, 6, 4], [7, 3, 8, 2]])
670+
sage: L.braid()
671+
s0^3*s1*s0*s1^-1
672+
sage: L.braid(remove_loops=True)
673+
s^3
651674
"""
675+
if remove_loops:
676+
L = self.remove_loops()
677+
if L != self:
678+
return L.braid(remove_loops=remove_loops)
679+
652680
if self._braid is not None:
653681
return self._braid
654682

@@ -657,8 +685,8 @@ def braid(self):
657685
if len(comp) > 1:
658686
L1 = Link(comp[0])
659687
L2 = Link(flatten(comp[1:], max_level=1))
660-
b1 = L1.braid()
661-
b2 = L2.braid()
688+
b1 = L1.braid(remove_loops=remove_loops)
689+
b2 = L2.braid(remove_loops=remove_loops)
662690
n1 = b1.parent().strands()
663691
n2 = b2.parent().strands()
664692
t1 = list(b1.Tietze())
@@ -667,13 +695,26 @@ def braid(self):
667695
self._braid = B(t1 + t2)
668696
return self._braid
669697

670-
# look for possible Vogel moves, perform them and call recursively to the modified link
671698
pd_code = self.pd_code()
672699
if not pd_code:
673700
B = BraidGroup(2)
674701
self._braid = B.one()
675702
return self._braid
676703

704+
# look for possible Vogel moves, perform them and call recursively to the modified link
705+
def idx(cross, edge):
706+
r"""
707+
Return the index of an edge in a crossing taking loops into account.
708+
A loop appears as an edge which occurs twice in the crossing.
709+
In all cases the second occurrence is the correct one needed in
710+
the Vogel algorithm (see :issue:`36884`).
711+
"""
712+
i = cross.index(edge)
713+
if cross.count(edge) > 1:
714+
return cross.index(edge, i+1)
715+
else:
716+
return i
717+
677718
seifert_circles = self.seifert_circles()
678719
newedge = max(flatten(pd_code)) + 1
679720
for region in self.regions():
@@ -702,12 +743,12 @@ def braid(self):
702743
# C1 C2 existing crossings
703744
# -------------------------------------------------
704745
C1 = newPD[newPD.index(heads[a])]
705-
C1[C1.index(a)] = newedge + 1
746+
C1[idx(C1, a)] = newedge + 1
706747
C2 = newPD[newPD.index(tails[b])]
707-
C2[C2.index(b)] = newedge + 2
748+
C2[idx(C2, b)] = newedge + 2
708749
newPD.append([newedge + 3, newedge, b, a]) # D
709750
newPD.append([newedge + 2, newedge, newedge + 3, newedge + 1]) # E
710-
self._braid = Link(newPD).braid()
751+
self._braid = Link(newPD).braid(remove_loops=remove_loops)
711752
return self._braid
712753
else:
713754
# -------------------------------------------------
@@ -723,12 +764,12 @@ def braid(self):
723764
# / \
724765
# -------------------------------------------------
725766
C1 = newPD[newPD.index(heads[-a])]
726-
C1[C1.index(-a)] = newedge + 1
767+
C1[idx(C1, -a)] = newedge + 1
727768
C2 = newPD[newPD.index(tails[-b])]
728-
C2[C2.index(-b)] = newedge + 2
769+
C2[idx(C2, -b)] = newedge + 2
729770
newPD.append([newedge + 2, newedge + 1, newedge + 3, newedge]) # D
730771
newPD.append([newedge + 3, -a, -b, newedge]) # E
731-
self._braid = Link(newPD).braid()
772+
self._braid = Link(newPD).braid(remove_loops=remove_loops)
732773
return self._braid
733774

734775
# We are in the case where no Vogel moves are necessary.
@@ -2362,6 +2403,50 @@ def regions(self):
23622403
regions.append(region)
23632404
return regions
23642405

2406+
def remove_loops(self):
2407+
r"""
2408+
Return an ambient isotopic link in which all loops are removed.
2409+
2410+
EXAMPLES::
2411+
2412+
sage: b = BraidGroup(4)((3, 2, -1, -1))
2413+
sage: L = Link(b)
2414+
sage: L.remove_loops()
2415+
Link with 2 components represented by 2 crossings
2416+
sage: K4 = Link([[1, 7, 2, 6], [3, 1, 4, 8], [5, 5, 6, 4], [7, 3, 8, 2]])
2417+
sage: K3 = K4.remove_loops()
2418+
sage: K3.pd_code()
2419+
[[1, 7, 2, 4], [3, 1, 4, 8], [7, 3, 8, 2]]
2420+
sage: U = Link([[1, 2, 2, 1]])
2421+
sage: U.remove_loops()
2422+
Link with 1 component represented by 0 crossings
2423+
"""
2424+
pd = self.pd_code()
2425+
new_pd = []
2426+
loop_crossings = []
2427+
for cr in pd:
2428+
if len(set(cr)) == 4:
2429+
new_pd.append(list(cr))
2430+
else:
2431+
loop_crossings.append(cr)
2432+
if not loop_crossings:
2433+
return self
2434+
if not new_pd:
2435+
# trivial knot
2436+
return type(self)([])
2437+
new_edges = flatten(new_pd)
2438+
for cr in loop_crossings:
2439+
rem = set([e for e in cr if e in new_edges])
2440+
if len(rem) == 2:
2441+
# put remaining edges together
2442+
a, b = sorted(rem)
2443+
for ncr in new_pd:
2444+
if b in ncr:
2445+
ncr[ncr.index(b)] = a
2446+
break
2447+
res = type(self)(new_pd)
2448+
return res.remove_loops()
2449+
23652450
@cached_method
23662451
def mirror_image(self):
23672452
r"""

0 commit comments

Comments
 (0)