From 53cc4e28b00820e56233202c644044b15cdaf016 Mon Sep 17 00:00:00 2001 From: Enrique Artal Date: Sat, 19 Oct 2024 14:26:24 +0200 Subject: [PATCH 1/6] avoid some long braid computations --- src/sage/schemes/curves/zariski_vankampen.py | 73 +++++++++++++------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/src/sage/schemes/curves/zariski_vankampen.py b/src/sage/schemes/curves/zariski_vankampen.py index f410a73f8fc..9a287cc9e4b 100755 --- a/src/sage/schemes/curves/zariski_vankampen.py +++ b/src/sage/schemes/curves/zariski_vankampen.py @@ -44,6 +44,7 @@ import itertools from copy import copy +from datetime import datetime from itertools import combinations from sage.combinat.permutation import Permutation @@ -1444,33 +1445,55 @@ def conjugate_positive_form(braid): """ B = braid.parent() d = B.strands() - braid1 = braid.super_summit_set()[0] - L1 = braid1.Tietze() - sg0 = braid.conjugating_braid(braid1) - gns = set(L1) - cuts = [j for j in range(d + 1) if j not in gns] - blocks = [] - for i in range(len(cuts) - 1): - block = [j for j in L1 if cuts[i] < j < cuts[i + 1]] - if block: - blocks.append(block) + rnf= rightnormalform(braid) + ex = rnf[-1][0] + if ex >= 0: + A1 = [B(a) for a in rnf[:-1]] + braid1 = prod(A1, B.delta() ** ex) + sg0 = B.one() + else: + A = braid.super_summit_set() + braid1 = A[0] + sg0 = braid.conjugating_braid(braid1) + if ex > 0: + blocks = list(braid1.Tietze()) + else: + L1 = braid1.Tietze() + gns = set(L1) + cuts = [j for j in range(d + 1) if j not in gns] + blocks = [] + for i in range(len(cuts) - 1): + block = [j for j in L1 if cuts[i] < j < cuts[i + 1]] + if block: + blocks.append(block) shorts = [] + oneblock = len(blocks) == 1 for a in blocks: - A = B(a).super_summit_set() - res = None - for tau in A: - sg = (sg0 * B(a) / sg0).conjugating_braid(tau) - A1 = rightnormalform(sg) - par = A1[-1][0] % 2 - A1 = [B(a) for a in A1[:-1]] - b = prod(A1, B.one()) - b1 = len(b.Tietze()) / (len(A1) + 1) - if res is None or b1 < res[3]: - res = [tau, A1, par, b1] - if res[2] == 1: - r0 = res[0].Tietze() - res[0] = B([i.sign() * (d - abs(i)) for i in r0]) - res0 = res[:2] + if sg0 == B.one(): + res0 = [B(a), []] + else: + if not oneblock: + A = B(a).super_summit_set() + res = None + t0 = datetime.now() + for j, tau in enumerate(A): + if j == 1: + sg = sg0 + else: + sg = (sg0 * B(a) / sg0).conjugating_braid(tau) + A1 = rightnormalform(sg) + par = A1[-1][0] % 2 + A1 = [B(a) for a in A1[:-1]] + b = prod(A1, B.one()) + b1 = len(b.Tietze()) / (len(A1) + 1) + if res is None or b1 < res[3]: + res = [tau, A1, par, b1] + if (datetime.now() - t0).total_seconds() > 60: + break + if res[2] == 1: + r0 = res[0].Tietze() + res[0] = B([i.sign() * (d - abs(i)) for i in r0]) + res0 = res[:2] shorts.append(res0) return shorts From 9ef96e033ed0cfabc9d4396f6f7461f811e03135 Mon Sep 17 00:00:00 2001 From: Enrique Artal Date: Sat, 19 Oct 2024 14:57:25 +0200 Subject: [PATCH 2/6] typo --- src/sage/schemes/curves/zariski_vankampen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/schemes/curves/zariski_vankampen.py b/src/sage/schemes/curves/zariski_vankampen.py index 9a287cc9e4b..cbba0a9ef9a 100755 --- a/src/sage/schemes/curves/zariski_vankampen.py +++ b/src/sage/schemes/curves/zariski_vankampen.py @@ -1445,7 +1445,7 @@ def conjugate_positive_form(braid): """ B = braid.parent() d = B.strands() - rnf= rightnormalform(braid) + rnf = rightnormalform(braid) ex = rnf[-1][0] if ex >= 0: A1 = [B(a) for a in rnf[:-1]] From a3ea70b5d22bd745e50739181be23b6722a82376 Mon Sep 17 00:00:00 2001 From: Enrique Artal Date: Wed, 30 Oct 2024 21:32:35 +0100 Subject: [PATCH 3/6] typo in conjugate_positive_braid --- src/sage/schemes/curves/zariski_vankampen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/schemes/curves/zariski_vankampen.py b/src/sage/schemes/curves/zariski_vankampen.py index ff27d8ede58..f4b3f958575 100755 --- a/src/sage/schemes/curves/zariski_vankampen.py +++ b/src/sage/schemes/curves/zariski_vankampen.py @@ -1456,7 +1456,7 @@ def conjugate_positive_form(braid): braid1 = A[0] sg0 = braid.conjugating_braid(braid1) if ex > 0: - blocks = list(braid1.Tietze()) + blocks = [list(braid1.Tietze())] else: L1 = braid1.Tietze() gns = set(L1) From 3578e9fd4349e0e19d3a15b8e4dc36cd5b786197 Mon Sep 17 00:00:00 2001 From: Enrique Artal Date: Sun, 3 Nov 2024 22:20:47 +0100 Subject: [PATCH 4/6] update libsemigroup --- build/pkgs/libsemigroups/checksums.ini | 4 ++-- build/pkgs/libsemigroups/package-version.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/pkgs/libsemigroups/checksums.ini b/build/pkgs/libsemigroups/checksums.ini index e258d4f2058..f34a1ed428d 100644 --- a/build/pkgs/libsemigroups/checksums.ini +++ b/build/pkgs/libsemigroups/checksums.ini @@ -1,4 +1,4 @@ tarball=libsemigroups-VERSION.tar.gz -sha1=86375824b47ce4b0e23570122e873f67136d0c0a -sha256=6214fd9e87af3834ff5eb6377cde1cbef76c74b233e1b0c4d15af1d2311692b4 +sha1=9c8e73b18a4964135b63e03b2f36b874742edd62 +sha256=d4d88a11651c7d7d497f847fea97e3ff60a39b25b851c1d0d7ccf41e052612be upstream_url=https://github.com/libsemigroups/libsemigroups/releases/download/vVERSION/libsemigroups-VERSION.tar.gz diff --git a/build/pkgs/libsemigroups/package-version.txt b/build/pkgs/libsemigroups/package-version.txt index f90b1afc082..2c9b4ef42ec 100644 --- a/build/pkgs/libsemigroups/package-version.txt +++ b/build/pkgs/libsemigroups/package-version.txt @@ -1 +1 @@ -2.3.2 +2.7.3 From d11e5c477ef467137859dd32cae45d1e7512ba3a Mon Sep 17 00:00:00 2001 From: Enrique Artal Date: Sun, 15 Dec 2024 20:39:04 +0100 Subject: [PATCH 5/6] using new libbraiding --- .../ordered_arrangement.py | 5 +- .../schemes/curves/plane_curve_arrangement.py | 6 +-- src/sage/schemes/curves/projective_curve.py | 5 +- src/sage/schemes/curves/zariski_vankampen.py | 48 +++++++------------ 4 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/sage/geometry/hyperplane_arrangement/ordered_arrangement.py b/src/sage/geometry/hyperplane_arrangement/ordered_arrangement.py index c0024f4c982..87774ec64ab 100644 --- a/src/sage/geometry/hyperplane_arrangement/ordered_arrangement.py +++ b/src/sage/geometry/hyperplane_arrangement/ordered_arrangement.py @@ -394,7 +394,6 @@ def projective_fundamental_group(self): < x0, x1, x2, x3, x4 | x4^-1*x3^-1*x2^-1*x3*x4*x0*x2*x0^-1, x4^-1*x2^-1*x4*x2, x4^-1*x1^-1*x0^-1*x1*x4*x0, x4^-1*x1^-1*x0^-1*x4*x0*x1, - x4^-1*x1^-1*x3*x0*x1*x3^-1*x2^-1*x4*x0^-1*x2, x3^-1*x2^-1*x1^-1*x0^-1*x3*x0*x1*x2, x3^-1*x1^-1*x3*x1 > sage: G3.abelian_invariants() @@ -406,9 +405,7 @@ def projective_fundamental_group(self): < x0, x1, x2, x3, x4 | x4^-1*x3^-1*x2^-1*x3*x4*x0*x2*x0^-1, x4^-1*x2^-1*x4*x2, x4^-1*x1^-1*x0^-1*x1*x4*x0, x4^-1*x1^-1*x0^-1*x4*x0*x1, - x4^-1*x1^-1*x3*x0*x1*x3^-1*x2^-1*x4*x0^-1*x2, - x3^-1*x2^-1*x1^-1*x0^-1*x3*x0*x1*x2, - x3^-1*x1^-1*x3*x1 > + x3^-1*x2^-1*x1^-1*x0^-1*x3*x0*x1*x2, x3^-1*x1^-1*x3*x1 > sage: G4.abelian_invariants() (0, 0, 0, 0, 0) diff --git a/src/sage/schemes/curves/plane_curve_arrangement.py b/src/sage/schemes/curves/plane_curve_arrangement.py index 63e8d03f556..a13faab50bc 100755 --- a/src/sage/schemes/curves/plane_curve_arrangement.py +++ b/src/sage/schemes/curves/plane_curve_arrangement.py @@ -513,7 +513,7 @@ def fundamental_group(self, simplified=True, vertical=True, {0: [x1, x2], 1: [x0], 2: [x3], 3: [x3^-1*x2^-1*x1^-1*x0^-1]} sage: A.fundamental_group(vertical=False) Finitely presented group - < x0, x1, x2 | x2^-1*x1^-1*x2*x1, x1*x0*x1^-1*x0^-1, (x0*x2)^2*(x0^-1*x2^-1)^2 > + < x0, x1, x2 | x2*x1^-1*x2^-1*x1, x1*x0*x1^-1*x0^-1, (x0*x2)^2*(x0^-1*x2^-1)^2 > sage: A.meridians(vertical=False) {0: [x2, x0*x2*x0^-1], 1: [x1], 2: [x0], 3: [x0*x2^-1*x0^-1*x2^-1*x1^-1*x0^-1]} sage: G = A.fundamental_group(simplified=False, vertical=False) @@ -834,7 +834,7 @@ def fundamental_group(self, simplified=True): sage: A.fundamental_group().sorted_presentation() Finitely presented group < x0, x1 | x1^-1*x0^-1*x1*x0 > sage: A.meridians() - {0: [x1], 1: [x0], 2: [x1^-1*x0^-1*x1^-1]} + {0: [x1], 1: [x0], 2: [x0^-1*x1^-2]} sage: G = A.fundamental_group(simplified=False) sage: G.sorted_presentation() Finitely presented group @@ -945,7 +945,7 @@ def meridians(self, simplified=True): sage: A.fundamental_group().sorted_presentation() Finitely presented group < x0, x1 | x1^-1*x0^-1*x1*x0 > sage: A.meridians() - {0: [x1], 1: [x0], 2: [x1^-1*x0^-1*x1^-1]} + {0: [x1], 1: [x0], 2: [x0^-1*x1^-2]} sage: A = H(y^2 + x*z, z, x) sage: A.fundamental_group() Finitely presented group < x0, x1 | (x1*x0)^2*(x1^-1*x0^-1)^2 > diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index d9a7321ade4..265ff56148d 100755 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -1775,8 +1775,9 @@ def fundamental_group(self): sage: C = P.curve(x^2*z - y^3) sage: C.fundamental_group() # needs sirocco Finitely presented group < x0 | x0^3 > - sage: P.curve(z*(x^2*z - y^3)).fundamental_group() # needs sirocco - Finitely presented group < x0, x1 | x1*x0*x1*x0^-1*x1^-1*x0^-1 > + sage: g = P.curve(z*(x^2*z - y^3)).fundamental_group() # needs sirocco + sage: g.sorted_presentation() # needs sirocco + Finitely presented group < x0, x1 | x1^-1*x0^-1*x1^-1*x0*x1*x0 > In the case of number fields, they need to have an embedding into the algebraic field:: diff --git a/src/sage/schemes/curves/zariski_vankampen.py b/src/sage/schemes/curves/zariski_vankampen.py index f4b3f958575..1a6591d6f9b 100755 --- a/src/sage/schemes/curves/zariski_vankampen.py +++ b/src/sage/schemes/curves/zariski_vankampen.py @@ -44,7 +44,6 @@ import itertools from copy import copy -from datetime import datetime from itertools import combinations from sage.combinat.permutation import Permutation @@ -1417,7 +1416,7 @@ def conjugate_positive_form(braid): A list of `r` lists. Each such list is another list with two elements, a positive braid `\alpha_i` and a list of permutation braids - `\gamma_{1}^{i},\dots,\gamma_{r}^{n_i}` such that if + `\gamma_{1}^{i},\dots,\gamma_{n_i}^{i}` such that if `\gamma_i=\prod_{j=1}^{n_i} \gamma_j^i` then the braids `\tau_i=\gamma_i\alpha_i\gamma_i^{-1}` pairwise commute and `\alpha=\prod_{i=1}^{r} \tau_i`. @@ -1428,11 +1427,11 @@ def conjugate_positive_form(braid): sage: B = BraidGroup(4) sage: t = B((1, 3, 2, -3, 1, 1)) sage: conjugate_positive_form(t) - [[(s1*s0)^2, [s2]]] + [[(s0*s1)^2, [s0*s2*s1*s0]]] sage: B = BraidGroup(5) sage: t = B((1, 2, 3, 4, -1, -2, 3, 3, 2, -4)) sage: L = conjugate_positive_form(t); L - [[s1^2, [s3*s2]], [s1*s2, [s0]]] + [[s0^2, [s0*s1*s2*s1*s3*s2*s1*s0]], [s3*s2, [s0*s1*s2*s1*s3*s2*s1*s0]]] sage: s = B.one() sage: for a, l in L: ....: b = prod(l) @@ -1452,9 +1451,7 @@ def conjugate_positive_form(braid): braid1 = prod(A1, B.delta() ** ex) sg0 = B.one() else: - A = braid.super_summit_set() - braid1 = A[0] - sg0 = braid.conjugating_braid(braid1) + braid1, sg0 = braid.super_summit_set_element() if ex > 0: blocks = [list(braid1.Tietze())] else: @@ -1467,30 +1464,18 @@ def conjugate_positive_form(braid): if block: blocks.append(block) shorts = [] - oneblock = len(blocks) == 1 for a in blocks: if sg0 == B.one(): res0 = [B(a), []] else: - if not oneblock: - A = B(a).super_summit_set() + bra = sg0 * B(a) / sg0 + br1, sg = bra.super_summit_set_element() res = None - t0 = datetime.now() - for j, tau in enumerate(A): - if j == 1: - sg = sg0 - else: - sg = (sg0 * B(a) / sg0).conjugating_braid(tau) - A1 = rightnormalform(sg) - par = A1[-1][0] % 2 - A1 = [B(a) for a in A1[:-1]] - b = prod(A1, B.one()) - b1 = len(b.Tietze()) / (len(A1) + 1) - if res is None or b1 < res[3]: - res = [tau, A1, par, b1] - if (datetime.now() - t0).total_seconds() > 60: - break - if res[2] == 1: + A1 = rightnormalform(sg) + par = A1[-1][0] % 2 + A1 = [B(a0) for a0 in A1[:-1]] + res = [br1, A1, par] + if res[2]: r0 = res[0].Tietze() res[0] = B([i.sign() * (d - abs(i)) for i in r0]) res0 = res[:2] @@ -1619,9 +1604,10 @@ def fundamental_group_from_braid_mon(bm, degree=None, sage: bm = [s1*s2*s0*s1*s0^-1*s1^-1*s0^-1, ....: s0*s1^2*s0*s2*s1*(s0^-1*s1^-1)^2*s0^-1, ....: (s0*s1)^2] - sage: g = fundamental_group_from_braid_mon(bm, projective=True); g # needs sirocco + sage: g = fundamental_group_from_braid_mon(bm, projective=True) # needs sirocco + sage: g.sorted_presentation() # needs sirocco Finitely presented group - < x1, x3 | x3^2*x1^2, x1^-1*x3^-1*x1*x3^-1*x1^-1*x3^-1 > + < x0, x1 | x1^-2*x0^-2, x1^-1*(x0^-1*x1)^2*x0 > sage: print(g.order(), g.abelian_invariants()) # needs sirocco 12 (4,) sage: B2 = BraidGroup(2) @@ -1720,8 +1706,8 @@ def fundamental_group(f, simplified=True, projective=False, puiseux=True): sage: from sage.schemes.curves.zariski_vankampen import fundamental_group, braid_monodromy sage: R. = QQ[] sage: f = x^2 + y^3 - sage: fundamental_group(f) - Finitely presented group < x0, x1 | x0*x1^-1*x0^-1*x1^-1*x0*x1 > + sage: fundamental_group(f).sorted_presentation() + Finitely presented group < x0, x1 | x1^-1*x0^-1*x1^-1*x0*x1*x0 > sage: fundamental_group(f, simplified=False, puiseux=False).sorted_presentation() Finitely presented group < x0, x1, x2 | x2^-1*x1^-1*x0*x1, x2^-1*x0*x1*x0^-1, @@ -1882,7 +1868,7 @@ def fundamental_group_arrangement(flist, simplified=True, projective=False, sage: G.sorted_presentation() Finitely presented group < x0, x1, x2, x3 | x3^-1*x2^-1*x3*x2, x3^-1*x1^-1*x0^-1*x1*x3*x0, - x3^-1*x1^-1*x3*x0*x1*x0^-1, x2^-1*x0^-1*x2*x0 > + x3^-1*x1^-1*x0^-1*x3*x0*x1, x2^-1*x0^-1*x2*x0 > sage: dic {0: [x1], 1: [x3], 2: [x2], 3: [x0], 4: [x3^-1*x2^-1*x1^-1*x0^-1]} sage: fundamental_group_arrangement(L, vertical=True) From b4819173711e4ab0cb17ca8e14eb911c9a312f82 Mon Sep 17 00:00:00 2001 From: Enrique Artal Date: Wed, 8 Jan 2025 17:10:51 +0100 Subject: [PATCH 6/6] using new libbrading --- src/sage/schemes/curves/zariski_vankampen.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/sage/schemes/curves/zariski_vankampen.py b/src/sage/schemes/curves/zariski_vankampen.py index 1a6591d6f9b..f7a7cb28921 100644 --- a/src/sage/schemes/curves/zariski_vankampen.py +++ b/src/sage/schemes/curves/zariski_vankampen.py @@ -1426,17 +1426,15 @@ def conjugate_positive_form(braid): sage: from sage.schemes.curves.zariski_vankampen import conjugate_positive_form sage: B = BraidGroup(4) sage: t = B((1, 3, 2, -3, 1, 1)) - sage: conjugate_positive_form(t) + sage: cpf = conjugate_positive_form(t); cpf [[(s0*s1)^2, [s0*s2*s1*s0]]] + sage: t == prod(prod(b) * a / prod(b) for a, b in cpf) + True sage: B = BraidGroup(5) sage: t = B((1, 2, 3, 4, -1, -2, 3, 3, 2, -4)) sage: L = conjugate_positive_form(t); L [[s0^2, [s0*s1*s2*s1*s3*s2*s1*s0]], [s3*s2, [s0*s1*s2*s1*s3*s2*s1*s0]]] - sage: s = B.one() - sage: for a, l in L: - ....: b = prod(l) - ....: s *= b * a / b - sage: s == t + sage: t == prod(prod(b) * a / prod(b) for a, b in L) True sage: s1 = B.gen(1)^3 sage: conjugate_positive_form(s1) @@ -1470,14 +1468,13 @@ def conjugate_positive_form(braid): else: bra = sg0 * B(a) / sg0 br1, sg = bra.super_summit_set_element() - res = None A1 = rightnormalform(sg) par = A1[-1][0] % 2 A1 = [B(a0) for a0 in A1[:-1]] res = [br1, A1, par] if res[2]: r0 = res[0].Tietze() - res[0] = B([i.sign() * (d - abs(i)) for i in r0]) + res[0] = B([d - i for i in r0]) res0 = res[:2] shorts.append(res0) return shorts