From d038b951d569bd9b03c58e52565390554c3bff23 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 9 Jun 2024 17:59:09 +0100 Subject: [PATCH 001/167] Created Chow Ring Ideal Class --- src/sage/matroids/chow_ring_ideal.py | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/sage/matroids/chow_ring_ideal.py diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py new file mode 100644 index 00000000000..34fece34320 --- /dev/null +++ b/src/sage/matroids/chow_ring_ideal.py @@ -0,0 +1,40 @@ +from sage.all import * +from sage.rings.ideal import Ideal_generic +from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal +from sage.matroids.matroid import Matroid +from sage.matroids.utilities import cmp_elements_key +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing + + +class ChowRingIdeal(MPolynomialIdeal): + def __init__(self, M, R=None, augmented=False): + if R is None: + raise ValueError("Ring not given") + self.augmented = augmented + self.mat = M + flats = [X for i in range(1, self.mat.rank()) + for X in self.mat.flats(i)] + try: + self.names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] + self.poly_ring = PolynomialRing(R, self.names) + except ValueError: # variables are not proper names + self.poly_ring = PolynomialRing(R, 'A', len(flats)) + self.names = self.poly_ring.variable_names() + self.gens = self.poly_ring.gens() + Ideal_generic.__init__(self, self.poly_ring, self.gens, coerce=coerce) + + + + def groebner_basis(self): + gb = [] + if self.augmented: + + else: + + + + + + + + From 16850226728172697b5ddf231eef1b8a18c56ade Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 10 Jun 2024 19:34:05 +0100 Subject: [PATCH 002/167] Created class and defined groebner_basis() method --- src/sage/matroids/chow_ring_ideal.py | 114 +++++++++++++++++++++++---- 1 file changed, 97 insertions(+), 17 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 34fece34320..76d5b809021 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -1,35 +1,115 @@ -from sage.all import * -from sage.rings.ideal import Ideal_generic +#from sage.all import * +#from sage.rings.ideal import Ideal_generic from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal from sage.matroids.matroid import Matroid from sage.matroids.utilities import cmp_elements_key from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing - +from sage.sets.set import Set +from sage.rings.morphism import _tensor_product_ring class ChowRingIdeal(MPolynomialIdeal): def __init__(self, M, R=None, augmented=False): if R is None: raise ValueError("Ring not given") self.augmented = augmented - self.mat = M - flats = [X for i in range(1, self.mat.rank()) - for X in self.mat.flats(i)] - try: - self.names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] - self.poly_ring = PolynomialRing(R, self.names) - except ValueError: # variables are not proper names - self.poly_ring = PolynomialRing(R, 'A', len(flats)) - self.names = self.poly_ring.variable_names() - self.gens = self.poly_ring.gens() - Ideal_generic.__init__(self, self.poly_ring, self.gens, coerce=coerce) - + self._matroid = M + self.flats = [X for i in range(1, self._matroid.rank()) + for X in self._matroid.flats(i)] + E = list(self._matroid.groundset()) + flats_containing = {x: [] for x in E} + for i,F in enumerate(self.flats): + for x in F: + flats_containing[x].append(i) + self.names = dict() - def groebner_basis(self): - gb = [] if self.augmented: + try: + P1 = PolynomialRing(R, 'A', len(E)) + names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] + P2 = PolynomialRing(R, names_flats) + self.poly_ring = _tensor_product_ring(P1, P2) + + except: + P1 = PolynomialRing(R, 'A', len(E)) + P2 = PolynomialRing(R, 'B', len(self.flats)) + self.poly_ring = _tensor_product_ring(P1, P2) + + gens = self.poly_ring.gens() + for i,x in enumerate(E): + self.names[x] = gens[i] + for i,F in enumerate(self.flats): + self.names[F] = gens[len(E) + i] + + Q =[gens[len(E)+i] * gens[len(E)+i+j+1] for i,F in enumerate(self.flats) + for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] + Q.append([gens[i]*gens[len(E)+j] for i,x in enumerate(E) for j,F in enumerate(self.flats) if F not in flats_containing[x]]) + L = list() + for i,x in enumerate(E): + for j,F in enumerate(self.flats): + term = 0 + if F not in flats_containing[x]: + term += gens[len(E)+j] + L.append(gens[i] - term) + print(L) + self.gens = Q + L + + + else: + try: + names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] + self.poly_ring = PolynomialRing(R, names) + for F in self.flats: + for i in range(len(self.poly_ring.gens())): + self.names[F] = self.poly_ring.gens()[i] + except ValueError: # variables are not proper names + self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) + for i in range(len(self.flats)): + self.names[self.flats[i]] = self.poly_ring.gens()[i] + + gens = self.poly_ring.gens() + Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self.flats) + for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] + L = [sum(gens[i] for i in flats_containing[x]) + - sum(gens[i] for i in flats_containing[y]) + for j,x in enumerate(E) for y in E[j+1:]] + self.gens = Q + L + + MPolynomialIdeal.__init__(self, self.poly_ring, self.gens) + + def __repr__(self): + if self.augmented: + return "Augmented Chow ring ideal of {}".format(self._matroid) else: + return "Chow ring ideal of {}".format(self._matroid) + + def groebner_basis(self): + gb = list() + for F in self.flats: + for G in self.flats: + if not (F < G or G < F): + gb.append(self.names[F]*self.names[G]) + elif Set(F).is_empty(): + term = 0 + for H in self.flats: + if H < F: + term += self.names[H] + gb.append(term**self._matroid.rank(Set(G))) + elif F < G: + term = 0 + for H in self.flats: + if H < F: + term += self.names[H] + gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) + return gb + + + + + + + From 0ab73bb6000de362ac33b079e226d4aa810d4fa1 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 10 Jun 2024 22:29:04 +0100 Subject: [PATCH 003/167] Modified groebner_basis() method --- src/sage/matroids/chow_ring_ideal.py | 38 +++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 76d5b809021..3947471d5a1 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -85,23 +85,27 @@ def __repr__(self): return "Chow ring ideal of {}".format(self._matroid) def groebner_basis(self): - gb = list() - for F in self.flats: - for G in self.flats: - if not (F < G or G < F): - gb.append(self.names[F]*self.names[G]) - elif Set(F).is_empty(): - term = 0 - for H in self.flats: - if H < F: - term += self.names[H] - gb.append(term**self._matroid.rank(Set(G))) - elif F < G: - term = 0 - for H in self.flats: - if H < F: - term += self.names[H] - gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) + if self.augmented: + print("Augmented gb") + else: + gb = list() + for F in self.flats: + for G in self.flats: + if not (F < G or G < F): + gb.append(self.names[F]*self.names[G]) + elif Set(F).is_empty(): + term = 0 + for H in self.flats: + if H < F: + term += self.names[H] + gb.append(term**self._matroid.rank(Set(G))) + elif F < G: + term = 0 + for H in self.flats: + if H < F: + term += self.names[H] + gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) + return gb From 237fdad015dcdbdd15114a52fd51a523a30e6d1e Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 18 Jun 2024 10:56:26 +0530 Subject: [PATCH 004/167] Added Augmented Chow Ring Ideal Class --- src/sage/matroids/chow_ring_ideal.py | 191 +++++++++++++++++---------- 1 file changed, 118 insertions(+), 73 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 3947471d5a1..3b5d0a16207 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -8,10 +8,7 @@ from sage.rings.morphism import _tensor_product_ring class ChowRingIdeal(MPolynomialIdeal): - def __init__(self, M, R=None, augmented=False): - if R is None: - raise ValueError("Ring not given") - self.augmented = augmented + def __init__(self, M, R): self._matroid = M self.flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] @@ -22,96 +19,144 @@ def __init__(self, M, R=None, augmented=False): for x in F: flats_containing[x].append(i) self.names = dict() + try: + names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] + self.poly_ring = PolynomialRing(R, names) + for F in self.flats: + for i in range(len(self.poly_ring.gens())): + self.names[F] = self.poly_ring.gens()[i] + except ValueError: # variables are not proper names + self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) + for i in range(len(self.flats)): + self.names[self.flats[i]] = self.poly_ring.gens()[i] + + gens = self.poly_ring.gens() + Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self.flats) + for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] + L = [sum(gens[i] for i in flats_containing[x]) + - sum(gens[i] for i in flats_containing[y]) + for j,x in enumerate(E) for y in E[j+1:]] + self.gens = Q + L + - if self.augmented: - try: - P1 = PolynomialRing(R, 'A', len(E)) - names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] - P2 = PolynomialRing(R, names_flats) - self.poly_ring = _tensor_product_ring(P1, P2) - - except: - P1 = PolynomialRing(R, 'A', len(E)) - P2 = PolynomialRing(R, 'B', len(self.flats)) - self.poly_ring = _tensor_product_ring(P1, P2) - - gens = self.poly_ring.gens() - for i,x in enumerate(E): - self.names[x] = gens[i] - for i,F in enumerate(self.flats): - self.names[F] = gens[len(E) + i] + MPolynomialIdeal.__init__(self, self.poly_ring, self.gens) - Q =[gens[len(E)+i] * gens[len(E)+i+j+1] for i,F in enumerate(self.flats) - for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] - Q.append([gens[i]*gens[len(E)+j] for i,x in enumerate(E) for j,F in enumerate(self.flats) if F not in flats_containing[x]]) - L = list() - for i,x in enumerate(E): - for j,F in enumerate(self.flats): + def __repr__(self): + return "Chow ring ideal of {}".format(self._matroid) + + def groebner_basis(self): + gb = list() + for F in self.flats: + for G in self.flats: + if not (F < G or G < F): + gb.append(self.names[F]*self.names[G]) + elif Set(F).is_empty(): term = 0 - if F not in flats_containing[x]: - term += gens[len(E)+j] - L.append(gens[i] - term) - print(L) - self.gens = Q + L - + for H in self.flats: + if H < F: + term += self.names[H] + gb.append(term**self._matroid.rank(Set(G))) + elif F < G: + term = 0 + for H in self.flats: + if H < F: + term += self.names[H] + gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) - else: - try: - names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] - self.poly_ring = PolynomialRing(R, names) - for F in self.flats: - for i in range(len(self.poly_ring.gens())): - self.names[F] = self.poly_ring.gens()[i] - except ValueError: # variables are not proper names - self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) - for i in range(len(self.flats)): - self.names[self.flats[i]] = self.poly_ring.gens()[i] - - gens = self.poly_ring.gens() - Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self.flats) - for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] - L = [sum(gens[i] for i in flats_containing[x]) - - sum(gens[i] for i in flats_containing[y]) - for j,x in enumerate(E) for y in E[j+1:]] - self.gens = Q + L - + return gb - MPolynomialIdeal.__init__(self, self.poly_ring, self.gens) +class AugmentedChowRingIdeal(MPolynomialIdeal): + def __init__(self, M, R): + self._matroid = M + self.flats = [X for i in range(1, self._matroid.rank()) + for X in self._matroid.flats(i)] + + E = list(self._matroid.groundset()) + flats_containing = {x: [] for x in E} + for i,F in enumerate(self.flats): + for x in F: + flats_containing[x].append(i) + self.names = dict() + #names_groundset = ['A{}'.format(''.join(str(x))) for x in E] + #names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] + self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) + gens = self.poly_ring.gens() + for i,x in enumerate(E): + self.names[x] = gens[i] + for i,F in enumerate(self.flats): + self.names[F] = gens[len(E) + i] + + Q =[gens[len(E)+i] * gens[len(E)+i+j+1] for i,F in enumerate(self.flats) + for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] + Q.append([gens[i]*gens[len(E)+j] for i,x in enumerate(E) for j,F in enumerate(self.flats) if F not in flats_containing[x]]) + L = list() + for i,x in enumerate(E): + term = 0 + for j,F in enumerate(self.flats): + if F not in flats_containing[x]: + term += gens[len(E)+j] + L.append(gens[i] - term) + self.gens = Q + L + MPolynomialIdeal.__init__(self, self.poly_ring, self.gens, coerce=False) + def __repr__(self): - if self.augmented: - return "Augmented Chow ring ideal of {}".format(self._matroid) - else: - return "Chow ring ideal of {}".format(self._matroid) + return "Augmented Chow ring ideal of {}".format(self._matroid) - def groebner_basis(self): - if self.augmented: - print("Augmented gb") - else: - gb = list() + + def groebner_basis(self, atom_free=False): + #add removal of empty flat line + #list returned or iterator returned? + gb = [] + if atom_free: for F in self.flats: for G in self.flats: - if not (F < G or G < F): + if not (F > G or G > F): gb.append(self.names[F]*self.names[G]) - elif Set(F).is_empty(): + elif F < G: term = 0 for H in self.flats: if H < F: term += self.names[H] - gb.append(term**self._matroid.rank(Set(G))) - elif F < G: + gb.append(self.names[F]*(term**self._matroid.rank(Set(G)))* + (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) + + else: + E = list(self._matroid.groundset()) + for i in E: + for F in self.flats: + for G in self.flats: term = 0 for H in self.flats: - if H < F: + if i in Set(H): term += self.names[H] - gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) - - return gb + gb.append(self.names[i] + term) + + if i in Set(F): + term = 0 + for H in self.flats: + if H < F: + term += self.names[H] + gb.append(self.names[i]*(term**self._matroid.rank(Set(G)))* + (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) + + elif not i in Set(F): + gb.append(self.names[i]*self.names[F]) + + elif not (F < G or G < F): + gb.append(self.names[F]*self.names[G]) + + elif F < G: + term = 0 + for H in self.flats: + if H < F: + term += self.names[H] + gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) + + return gb - - From d51bd1d663282448c8d2754e41d1b20f08030cfb Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 23 Jun 2024 14:45:48 +0530 Subject: [PATCH 005/167] Modified ChowRingIdeal class --- src/sage/matroids/chow_ring_ideal.py | 77 +++++++++++++++++++--------- 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 3b5d0a16207..4e55ca4a313 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -10,7 +10,7 @@ class ChowRingIdeal(MPolynomialIdeal): def __init__(self, M, R): self._matroid = M - self.flats = [X for i in range(1, self._matroid.rank()) + self.flats = [X for i in range(1, self._matroid.rank()) #_flats. NOT NEEDED AS AN ATTRIBUTE. USE NAMES for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) @@ -18,17 +18,17 @@ def __init__(self, M, R): for i,F in enumerate(self.flats): for x in F: flats_containing[x].append(i) - self.names = dict() + self.flat_generator = dict() try: names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] - self.poly_ring = PolynomialRing(R, names) + self.poly_ring = PolynomialRing(R, names) #self.ring for F in self.flats: for i in range(len(self.poly_ring.gens())): - self.names[F] = self.poly_ring.gens()[i] + self.flat_generator[F] = self.poly_ring.gens()[i] #change self.names to self.flat_generator except ValueError: # variables are not proper names self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) for i in range(len(self.flats)): - self.names[self.flats[i]] = self.poly_ring.gens()[i] + self.flat_generator[self.flats[i]] = self.poly_ring.gens()[i] gens = self.poly_ring.gens() Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self.flats) @@ -41,13 +41,13 @@ def __init__(self, M, R): MPolynomialIdeal.__init__(self, self.poly_ring, self.gens) - def __repr__(self): + def _repr_(self): return "Chow ring ideal of {}".format(self._matroid) def groebner_basis(self): gb = list() for F in self.flats: - for G in self.flats: + for G in self.flats: #write from F not G if not (F < G or G < F): gb.append(self.names[F]*self.names[G]) elif Set(F).is_empty(): @@ -66,6 +66,16 @@ def groebner_basis(self): return gb + def matroid(self): + return Matroid(self._matroid) + + def flat_generator(self): + return dict(self.flat_generator) + +#get matroid method, called matroid, returning the matroid +#get names + + class AugmentedChowRingIdeal(MPolynomialIdeal): def __init__(self, M, R): self._matroid = M @@ -77,19 +87,38 @@ def __init__(self, M, R): for i,F in enumerate(self.flats): for x in F: flats_containing[x].append(i) - self.names = dict() + self.flats_generator = dict() #names_groundset = ['A{}'.format(''.join(str(x))) for x in E] #names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) gens = self.poly_ring.gens() for i,x in enumerate(E): - self.names[x] = gens[i] + self.flats_generator[x] = gens[i] for i,F in enumerate(self.flats): - self.names[F] = gens[len(E) + i] + self.flats_generator[F] = gens[len(E) + i] + + print(gens) - Q =[gens[len(E)+i] * gens[len(E)+i+j+1] for i,F in enumerate(self.flats) - for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] - Q.append([gens[i]*gens[len(E)+j] for i,x in enumerate(E) for j,F in enumerate(self.flats) if F not in flats_containing[x]]) + Q = list() + for i,F in enumerate(self.flats): + for j,G in enumerate(self.flats): + if not (F < G or G < F): + print(type(gens[len(E)+i] * gens[len(E)+i+j+1])) + Q.append(gens[len(E)+i] * gens[len(E)+i+j+1]) + + for j,F in enumerate(self.flats): + for k,x in enumerate(E): + if F not in flats_containing[x]: + print(type(gens[k]*gens[len(E)+j])) + Q.append(gens[k]*gens[len(E)+j]) + print("this is Q", Q) + + + + #debug Q and L. coerce must be true. Coerce allows you to add two different elements from two different rings + #Q =[gens[len(E)+i] * gens[len(E)+i+j+1] for i,F in enumerate(self.flats) + #for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] + #Q.append([gens[i]*gens[len(E)+j] for i,x in enumerate(E) for j,F in enumerate(self.flats) if F not in flats_containing[x]]) L = list() for i,x in enumerate(E): term = 0 @@ -100,17 +129,19 @@ def __init__(self, M, R): self.gens = Q + L MPolynomialIdeal.__init__(self, self.poly_ring, self.gens, coerce=False) - def __repr__(self): + def _repr_short(self): #use single underscore return "Augmented Chow ring ideal of {}".format(self._matroid) def groebner_basis(self, atom_free=False): - #add removal of empty flat line - #list returned or iterator returned? + #list returned or iterator returned? - neither - polynomial_sequence_generic object gb = [] + flats = self.flats + if Set([]) in flats: + flats.remove(Set([])) if atom_free: - for F in self.flats: - for G in self.flats: + for F in flats: + for G in flats: if not (F > G or G > F): gb.append(self.names[F]*self.names[G]) elif F < G: @@ -124,17 +155,17 @@ def groebner_basis(self, atom_free=False): else: E = list(self._matroid.groundset()) for i in E: - for F in self.flats: - for G in self.flats: + for F in flats: + for G in flats: term = 0 - for H in self.flats: + for H in flats: if i in Set(H): term += self.names[H] gb.append(self.names[i] + term) if i in Set(F): term = 0 - for H in self.flats: + for H in flats: if H < F: term += self.names[H] gb.append(self.names[i]*(term**self._matroid.rank(Set(G)))* @@ -148,7 +179,7 @@ def groebner_basis(self, atom_free=False): elif F < G: term = 0 - for H in self.flats: + for H in flats: if H < F: term += self.names[H] gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) From 462ce6c0c25d916a85dba2e54963c4bb0dc30ca6 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 23 Jun 2024 14:47:36 +0530 Subject: [PATCH 006/167] Created Chow Ring class --- src/sage/matroids/chow_ring.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/sage/matroids/chow_ring.py diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py new file mode 100644 index 00000000000..0498307f491 --- /dev/null +++ b/src/sage/matroids/chow_ring.py @@ -0,0 +1,18 @@ +from sage.matroids.chow_ring_ideal import * +from sage.rings.quotient_ring import QuotientRing_nc +from sage.rings.quotient_ring_element import QuotientRingElement +from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis +import sage.misc.latex as latex + +class ChowRing(QuotientRing_nc, category=GradedAlgebrasWithBasis): + def __init__(self, R, M): + self._matroid = M + self._ideal = ChowRingIdeal(M, R) + self.poly_ring = self._ideal.poly_ring + QuotientRing_nc.__init__(R, self._ideal, names=self.poly_ring.variable_names, category=GradedAlgebrasWithBasis) + + def _repr_(self): + return "Chow ring of {}".format(self._matroid) + + def _latex_(self): + return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) \ No newline at end of file From ad4c43c1c4f7f609dfe84921966c9e183c4bd8dc Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 23 Jun 2024 14:49:08 +0530 Subject: [PATCH 007/167] Created Augmented Chow Ring class --- src/sage/matroids/chow_ring.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 0498307f491..ac59ca2d408 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -15,4 +15,17 @@ def _repr_(self): return "Chow ring of {}".format(self._matroid) def _latex_(self): - return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) \ No newline at end of file + return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) + +class AugmentedChowRing(QuotientRing_nc, category=GradedAlgebrasWithBasis): + def __init__(self, R, M): + self._matroid = M + self._ideal = AugmentedChowRingIdeal(M, R) + self.poly_ring = self._ideal.poly_ring + QuotientRing_nc.__init__(R, self._ideal, names=self.poly_ring.variable_names, category=GradedAlgebrasWithBasis) + + def _repr_(self): + return "Chow ring of {}".format(self._matroid) + + def _latex_(self): + return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) \ No newline at end of file From cbf6db49cb0bcedd936d758e78f1c0ce845d78f2 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 25 Jun 2024 09:52:40 +0530 Subject: [PATCH 008/167] Edited __init__ and _repr_short funcs --- src/sage/matroids/chow_ring.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index ac59ca2d408..7af728f2c71 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -4,27 +4,27 @@ from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis import sage.misc.latex as latex -class ChowRing(QuotientRing_nc, category=GradedAlgebrasWithBasis): +class ChowRing(QuotientRing_nc): def __init__(self, R, M): self._matroid = M self._ideal = ChowRingIdeal(M, R) self.poly_ring = self._ideal.poly_ring - QuotientRing_nc.__init__(R, self._ideal, names=self.poly_ring.variable_names, category=GradedAlgebrasWithBasis) + QuotientRing_nc.__init__(self, R=R, I=self._ideal, names=self.poly_ring.variable_names, category=GradedAlgebrasWithBasis) - def _repr_(self): + def _repr_short(self): return "Chow ring of {}".format(self._matroid) def _latex_(self): return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) -class AugmentedChowRing(QuotientRing_nc, category=GradedAlgebrasWithBasis): +class AugmentedChowRing(QuotientRing_nc): def __init__(self, R, M): self._matroid = M self._ideal = AugmentedChowRingIdeal(M, R) self.poly_ring = self._ideal.poly_ring - QuotientRing_nc.__init__(R, self._ideal, names=self.poly_ring.variable_names, category=GradedAlgebrasWithBasis) + QuotientRing_nc.__init__(self, R, self._ideal, names=self.poly_ring.variable_names, category=GradedAlgebrasWithBasis) - def _repr_(self): + def _repr_short(self): return "Chow ring of {}".format(self._matroid) def _latex_(self): From 873d9a705ac99e1194a8c86380d95f10ca2bd296 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 26 Jun 2024 15:12:27 +0530 Subject: [PATCH 009/167] Modified __init__() functions for both classes --- src/sage/matroids/chow_ring_ideal.py | 74 +++++++++++++++------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 4e55ca4a313..12a708d196b 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -1,11 +1,9 @@ -#from sage.all import * -#from sage.rings.ideal import Ideal_generic from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal from sage.matroids.matroid import Matroid from sage.matroids.utilities import cmp_elements_key from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.sets.set import Set -from sage.rings.morphism import _tensor_product_ring + class ChowRingIdeal(MPolynomialIdeal): def __init__(self, M, R): @@ -18,28 +16,27 @@ def __init__(self, M, R): for i,F in enumerate(self.flats): for x in F: flats_containing[x].append(i) - self.flat_generator = dict() + + names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] + try: - names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] - self.poly_ring = PolynomialRing(R, names) #self.ring - for F in self.flats: - for i in range(len(self.poly_ring.gens())): - self.flat_generator[F] = self.poly_ring.gens()[i] #change self.names to self.flat_generator + poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names - self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) - for i in range(len(self.flats)): - self.flat_generator[self.flats[i]] = self.poly_ring.gens()[i] + poly_ring = PolynomialRing(R, 'A', len(self.flats)) + + + gens = poly_ring.gens() + self.flat_generator = dict(zip(self.flats, gens)) - gens = self.poly_ring.gens() + Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self.flats) for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] L = [sum(gens[i] for i in flats_containing[x]) - sum(gens[i] for i in flats_containing[y]) for j,x in enumerate(E) for y in E[j+1:]] - self.gens = Q + L - MPolynomialIdeal.__init__(self, self.poly_ring, self.gens) + MPolynomialIdeal.__init__(self, poly_ring, Q + L) def _repr_(self): return "Chow ring ideal of {}".format(self._matroid) @@ -67,13 +64,11 @@ def groebner_basis(self): def matroid(self): - return Matroid(self._matroid) + return self._matroid def flat_generator(self): return dict(self.flat_generator) -#get matroid method, called matroid, returning the matroid -#get names class AugmentedChowRingIdeal(MPolynomialIdeal): @@ -90,28 +85,28 @@ def __init__(self, M, R): self.flats_generator = dict() #names_groundset = ['A{}'.format(''.join(str(x))) for x in E] #names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] - self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) - gens = self.poly_ring.gens() + poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) + gens = poly_ring.gens() for i,x in enumerate(E): self.flats_generator[x] = gens[i] for i,F in enumerate(self.flats): self.flats_generator[F] = gens[len(E) + i] - print(gens) - + + le = len(E) Q = list() for i,F in enumerate(self.flats): for j,G in enumerate(self.flats): if not (F < G or G < F): - print(type(gens[len(E)+i] * gens[len(E)+i+j+1])) - Q.append(gens[len(E)+i] * gens[len(E)+i+j+1]) + #print(type(gens[le+i] * gens[le+i+j+1])) + Q.append(gens[le+i] * gens[le+j]) for j,F in enumerate(self.flats): for k,x in enumerate(E): if F not in flats_containing[x]: - print(type(gens[k]*gens[len(E)+j])) - Q.append(gens[k]*gens[len(E)+j]) - print("this is Q", Q) + #print(type(gens[k]*gens[len(E)+j])) + Q.append(gens[k]*gens[le+j]) + #print("this is Q", Q) @@ -121,17 +116,30 @@ def __init__(self, M, R): #Q.append([gens[i]*gens[len(E)+j] for i,x in enumerate(E) for j,F in enumerate(self.flats) if F not in flats_containing[x]]) L = list() for i,x in enumerate(E): - term = 0 + term = poly_ring.zero() for j,F in enumerate(self.flats): if F not in flats_containing[x]: - term += gens[len(E)+j] - L.append(gens[i] - term) - self.gens = Q + L - MPolynomialIdeal.__init__(self, self.poly_ring, self.gens, coerce=False) + term += gens[le+j] + L.append(gens[i] - term) + + for g in Q: + print(g, g.parent()) + for g in L: + print(g, g.parent()) + MPolynomialIdeal.__init__(self, poly_ring, Q + L) - def _repr_short(self): #use single underscore + def _repr_(self): #use single underscore return "Augmented Chow ring ideal of {}".format(self._matroid) + def matroid(self): + return self._matroid + + def flat_generator(self): + return self.flat_generator + + + + def groebner_basis(self, atom_free=False): #list returned or iterator returned? - neither - polynomial_sequence_generic object From 529bb10b3554082242c4a19f7dc053a9c2031575 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 26 Jun 2024 15:21:36 +0530 Subject: [PATCH 010/167] Debugged __init__() function of Chow ring class --- src/sage/matroids/chow_ring.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 7af728f2c71..d4b817564a2 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -4,28 +4,27 @@ from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis import sage.misc.latex as latex +#chow rings class needs to be written properly +#gens of chow ring ideal must be debugged +#gb must be a poly sequence +#commented and documented +#use is_groebner() +#matroids - try all of them + + class ChowRing(QuotientRing_nc): - def __init__(self, R, M): + def __init__(self, R, M, augmented): self._matroid = M - self._ideal = ChowRingIdeal(M, R) - self.poly_ring = self._ideal.poly_ring - QuotientRing_nc.__init__(self, R=R, I=self._ideal, names=self.poly_ring.variable_names, category=GradedAlgebrasWithBasis) + self._augmented = augmented + if augmented: + self._ideal = AugmentedChowRingIdeal(M, R) + else: + self._ideal = ChowRingIdeal(M, R) #check method to get ring + QuotientRing_nc.__init__(self, R=self._ideal.poly_ring, I=self._ideal, names=self.poly_ring.variable_names(), category=GradedAlgebrasWithBasis(R)) - def _repr_short(self): + def _repr_(self): return "Chow ring of {}".format(self._matroid) def _latex_(self): return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) -class AugmentedChowRing(QuotientRing_nc): - def __init__(self, R, M): - self._matroid = M - self._ideal = AugmentedChowRingIdeal(M, R) - self.poly_ring = self._ideal.poly_ring - QuotientRing_nc.__init__(self, R, self._ideal, names=self.poly_ring.variable_names, category=GradedAlgebrasWithBasis) - - def _repr_short(self): - return "Chow ring of {}".format(self._matroid) - - def _latex_(self): - return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) \ No newline at end of file From 6079e3d5d888594eb71d514cabffd4df9f5e5130 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Fri, 28 Jun 2024 14:17:09 +0530 Subject: [PATCH 011/167] Modified groebner_basis() method for both classes --- src/sage/matroids/chow_ring_ideal.py | 76 ++++++++++++++-------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 12a708d196b..bf5f2b50a37 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -3,6 +3,7 @@ from sage.matroids.utilities import cmp_elements_key from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.sets.set import Set +from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence class ChowRingIdeal(MPolynomialIdeal): @@ -20,13 +21,13 @@ def __init__(self, M, R): names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] try: - poly_ring = PolynomialRing(R, names) #self.ring + self.poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names - poly_ring = PolynomialRing(R, 'A', len(self.flats)) + self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) - gens = poly_ring.gens() - self.flat_generator = dict(zip(self.flats, gens)) + gens = self.poly_ring.gens() + self.flats_generator = dict(zip(self.flats, gens)) Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self.flats) @@ -36,7 +37,7 @@ def __init__(self, M, R): for j,x in enumerate(E) for y in E[j+1:]] - MPolynomialIdeal.__init__(self, poly_ring, Q + L) + MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) def _repr_(self): return "Chow ring ideal of {}".format(self._matroid) @@ -44,30 +45,31 @@ def _repr_(self): def groebner_basis(self): gb = list() for F in self.flats: - for G in self.flats: #write from F not G + for G in self.flats: if not (F < G or G < F): - gb.append(self.names[F]*self.names[G]) + gb.append(self.flats_generator[F]*self.flats_generator[G]) elif Set(F).is_empty(): - term = 0 + term = self.poly_ring.zero() for H in self.flats: if H < F: - term += self.names[H] + term += self.flats_generator[H] gb.append(term**self._matroid.rank(Set(G))) elif F < G: - term = 0 + term = self.poly_ring.zero() for H in self.flats: if H < F: - term += self.names[H] + term += self.flats_generator[H] gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) - return gb + g_basis = PolynomialSequence(self.poly_ring, [gb]) + return g_basis def matroid(self): return self._matroid - def flat_generator(self): - return dict(self.flat_generator) + def flats_generator(self): + return dict(self.flats_generator) @@ -85,8 +87,8 @@ def __init__(self, M, R): self.flats_generator = dict() #names_groundset = ['A{}'.format(''.join(str(x))) for x in E] #names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] - poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) - gens = poly_ring.gens() + self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) + gens = self.poly_ring.gens() for i,x in enumerate(E): self.flats_generator[x] = gens[i] for i,F in enumerate(self.flats): @@ -116,17 +118,13 @@ def __init__(self, M, R): #Q.append([gens[i]*gens[len(E)+j] for i,x in enumerate(E) for j,F in enumerate(self.flats) if F not in flats_containing[x]]) L = list() for i,x in enumerate(E): - term = poly_ring.zero() + term = self.poly_ring.zero() for j,F in enumerate(self.flats): if F not in flats_containing[x]: term += gens[le+j] L.append(gens[i] - term) - for g in Q: - print(g, g.parent()) - for g in L: - print(g, g.parent()) - MPolynomialIdeal.__init__(self, poly_ring, Q + L) + MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) def _repr_(self): #use single underscore return "Augmented Chow ring ideal of {}".format(self._matroid) @@ -135,14 +133,13 @@ def matroid(self): return self._matroid def flat_generator(self): - return self.flat_generator + return self.flats_generator def groebner_basis(self, atom_free=False): - #list returned or iterator returned? - neither - polynomial_sequence_generic object gb = [] flats = self.flats if Set([]) in flats: @@ -151,13 +148,13 @@ def groebner_basis(self, atom_free=False): for F in flats: for G in flats: if not (F > G or G > F): - gb.append(self.names[F]*self.names[G]) + gb.append(self.flats_generator[F]*self.flats_generator[G]) elif F < G: - term = 0 + term = self.poly_ring.zero() for H in self.flats: if H < F: - term += self.names[H] - gb.append(self.names[F]*(term**self._matroid.rank(Set(G)))* + term += self.flats_generator[H] + gb.append(self.flats_generator[F]*(term**self._matroid.rank(Set(G)))* (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) else: @@ -165,34 +162,35 @@ def groebner_basis(self, atom_free=False): for i in E: for F in flats: for G in flats: - term = 0 + term = self.poly_ring.zero() for H in flats: if i in Set(H): - term += self.names[H] - gb.append(self.names[i] + term) + term += self.flats_generator[H] + gb.append(self.flats_generator[i] + term) if i in Set(F): - term = 0 + term = self.poly_ring.zero() for H in flats: if H < F: - term += self.names[H] - gb.append(self.names[i]*(term**self._matroid.rank(Set(G)))* + term += self.flats_generator[H] + gb.append(self.flats_generator[i]*(term**self._matroid.rank(Set(G)))* (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) elif not i in Set(F): - gb.append(self.names[i]*self.names[F]) + gb.append(self.flats_generator[i]*self.flats_generator[F]) elif not (F < G or G < F): - gb.append(self.names[F]*self.names[G]) + gb.append(self.flats_generator[F]*self.flats_generator[G]) elif F < G: - term = 0 + term = self.poly_ring.zero() for H in flats: if H < F: - term += self.names[H] + term += self.flats_generator[H] gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) - return gb + g_basis = PolynomialSequence(self.poly_ring, [gb]) + return g_basis From 3f466b945bc3a83124a218bf26c2b7aad16aec8b Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 2 Jul 2024 10:23:54 +0530 Subject: [PATCH 012/167] Added Documentation to both classes --- src/sage/matroids/chow_ring_ideal.py | 243 +++++++++++++++++++++------ 1 file changed, 189 insertions(+), 54 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index bf5f2b50a37..5c3ebabb9d6 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -5,20 +5,79 @@ from sage.sets.set import Set from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence +r""" +Chow ring ideals of matroids + +AUTHORS: + +- Travis Scrimshaw +- Shriya M + +These are the classes of Chow ring ideals for matroids. There are two classes +created - Chow ring ideal and augmented Chow ring ideal. The augmented +Chow ring ideal has two different presentations implemented - the Feitchner- +Yuzvinsky presentation and atom-free presentation. Both classes have +``grobner_basis()`` methods as well, as an explicit Groebner basis is known +in each case. + +REFERENCES + +- :arxiv:`2309.14312` +- :arxiv:`2111.00393` +""" +#***************************************************************************** +# Copyright (C) 2024 Travis Scrimshaw +# 2024 Shriya M +# +# Distributed under the terms of the GNU General Public License (GPL) +# +# This code is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# The full text of the GPL is available at: +# +# http://www.gnu.org/licenses/ +#***************************************************************************** class ChowRingIdeal(MPolynomialIdeal): + r""" + The class of Chow ring ideal, a multi-polynomial ideal. + Base class - ``MPolynomialIdeal``. + + INPUT: + + + - `M` -- a matroid. + - `R` -- a ring. + + OUTPUT: Chow ring ideal of matroid `M`. + + EXAMPLES:: + + Chow ring ideal of uniform matroid of rank 3 on 6 elements:: + + sage: ch = ChowRingIdeal(M=matroids.Uniform(3,6), R=QQ) + sage: ch + Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures + {3: {{0, 1, 2, 3, 4, 5}}} + sage: ch = ChowRingIdeal(M=matroids.catalog.Fano(), R=QQ) + Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + """ + def __init__(self, M, R): self._matroid = M - self.flats = [X for i in range(1, self._matroid.rank()) #_flats. NOT NEEDED AS AN ATTRIBUTE. USE NAMES + flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} - for i,F in enumerate(self.flats): + for i,F in enumerate(flats): for x in F: flats_containing[x].append(i) - names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] + names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] try: self.poly_ring = PolynomialRing(R, names) #self.ring @@ -27,11 +86,11 @@ def __init__(self, M, R): gens = self.poly_ring.gens() - self.flats_generator = dict(zip(self.flats, gens)) + self.flats_generator = dict(zip(flats, gens)) - Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self.flats) - for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] + Q = [gens[i] * gens[i+j+1] for i,F in enumerate(flats) + for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] L = [sum(gens[i] for i in flats_containing[x]) - sum(gens[i] for i in flats_containing[y]) for j,x in enumerate(E) for y in E[j+1:]] @@ -39,24 +98,45 @@ def __init__(self, M, R): MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) - def _repr_(self): + def __repr__(self): return "Chow ring ideal of {}".format(self._matroid) - def groebner_basis(self): + def groebner_basis(self): + r""" + Returns the Groebner basis of the Chow ring ideal of consideration. + Return type - ``PolynomialSequence``. + + EXAMPLES:: + + sage: ch = ChowRingIdeal(M=BasisMatroid(groundset='abc', bases=['ab', 'ac']), R=QQ) + sage: ch.groebner_basis() + [Aa^2, Aa*Abc, Aa*Abc, Abc^2] + sage: ch.groebner_basis().is_groebner() + True + + Another example would be the Groebner basis of the Chow ring ideal of + the Non-Fano matroid:: + + sage: ch = ChowRingIdeal(M=matroids.catalog.NonFano(), R=QQ) + sage: ch.groebner.basis() + Polynomial Sequence with 592 Polynomials in 16 Variables + """ + + flats = list(self.flats_generator.keys()) gb = list() - for F in self.flats: - for G in self.flats: + for F in flats: + for G in flats: if not (F < G or G < F): gb.append(self.flats_generator[F]*self.flats_generator[G]) elif Set(F).is_empty(): term = self.poly_ring.zero() - for H in self.flats: + for H in flats: if H < F: term += self.flats_generator[H] gb.append(term**self._matroid.rank(Set(G))) elif F < G: term = self.poly_ring.zero() - for H in self.flats: + for H in flats: if H < F: term += self.flats_generator[H] gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) @@ -74,84 +154,139 @@ def flats_generator(self): class AugmentedChowRingIdeal(MPolynomialIdeal): - def __init__(self, M, R): + r""" + The class of Chow ring ideal, a multi-polynomial ideal. + Base class - ``MPolynomialIdeal``. + + INPUT: + + + - `M` -- a matroid. + - `R` -- a ring. + - ``atom_free`` -- a Boolean value, default value set to ``False``. When + ``True``, it returns the atom-free presentation of the augmented Chow + ring. If ``False``, it returns the Feitchner-Yuzvinsky presentation of the + augmented Chow ring. + + OUTPUT: augmented Chow ring ideal of matroid `M`. + + EXAMPLES:: + + Augmented Chow ring ideal of Wheel matroid of rank 3:: + + sage: ch = AugumentedChowRingIdeal(M=matroids.Wheel(3), R=QQ) + sage: ch + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + """ + def __init__(self, M, R, atom_free=False): + self.atom_free = atom_free self._matroid = M - self.flats = [X for i in range(1, self._matroid.rank()) + flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} - for i,F in enumerate(self.flats): + for F in flats: for x in F: - flats_containing[x].append(i) + flats_containing[x].append(F) self.flats_generator = dict() - #names_groundset = ['A{}'.format(''.join(str(x))) for x in E] - #names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] - self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) + try: + names_groundset = ['A{}'.format(''.join(str(x))) for x in E] + names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] + self.poly_ring = PolynomialRing(R, names_groundset + names_flats) + except ValueError: + self.poly_ring = PolynomialRing(R, 'A', len(E) + len(flats)) gens = self.poly_ring.gens() for i,x in enumerate(E): - self.flats_generator[x] = gens[i] - for i,F in enumerate(self.flats): + self.flats_generator[x] = gens[i] + for i,F in enumerate(flats): self.flats_generator[F] = gens[len(E) + i] le = len(E) Q = list() - for i,F in enumerate(self.flats): - for j,G in enumerate(self.flats): + for i,F in enumerate(flats): + for j,G in enumerate(flats): if not (F < G or G < F): - #print(type(gens[le+i] * gens[le+i+j+1])) Q.append(gens[le+i] * gens[le+j]) - - for j,F in enumerate(self.flats): + + for j,F in enumerate(flats): for k,x in enumerate(E): if F not in flats_containing[x]: - #print(type(gens[k]*gens[len(E)+j])) - Q.append(gens[k]*gens[le+j]) - #print("this is Q", Q) - - - - #debug Q and L. coerce must be true. Coerce allows you to add two different elements from two different rings - #Q =[gens[len(E)+i] * gens[len(E)+i+j+1] for i,F in enumerate(self.flats) - #for j,G in enumerate(self.flats[i+1:]) if not (F < G or G < F)] - #Q.append([gens[i]*gens[len(E)+j] for i,x in enumerate(E) for j,F in enumerate(self.flats) if F not in flats_containing[x]]) - L = list() - for i,x in enumerate(E): - term = self.poly_ring.zero() - for j,F in enumerate(self.flats): - if F not in flats_containing[x]: - term += gens[le+j] - L.append(gens[i] - term) - - MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) + if self.atom_free: + term = self.poly_ring.zero() + for G in flats_containing[x]: + term += self.flats_generator[G] + Q.append(self.flats_generator[F]*term) + else: + Q.append(gens[k]*gens[le+j]) + + + if self.atom_free: + for i in E: + term = self.poly_ring.zero() + for F in flats_containing[i]: + term += self.flats_generator[F] + Q.append(term**2) + + MPolynomialIdeal.__init__(self, self.poly_ring, Q) + else: + L = list() + for i,x in enumerate(E): + term = self.poly_ring.zero() + for j,F in enumerate(flats): + if F not in flats_containing[x]: + term += gens[le+j] + L.append(gens[i] - term) + + MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) - def _repr_(self): #use single underscore - return "Augmented Chow ring ideal of {}".format(self._matroid) + def __repr__(self): + if self.atom_free: + return "Augmented Chow ring ideal of {} of atom-free presentation".format(self._matroid) + else: + return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) def matroid(self): return self._matroid def flat_generator(self): - return self.flats_generator - + return dict(self.flats_generator) + def groebner_basis(self): + r""" + Returns the Groebner basis of the augmented Chow ring ideal. + Return type - ``PolynomialSequence``. + EXAMPLES:: - - def groebner_basis(self, atom_free=False): + sage: ch = AugmentedChowRingIdeal(M=matroids.catalog.Fano(), R=QQ) + sage: ch.groebner_basis() + Polynomial Sequence with 2744 Polynomials in 21 Variables + + Another example would be the Groebner basis of the augmented Chow ring + ideal (atom-free presentation) of the Graphic matroid of cycle graph of + 3 vertices:: + + sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) + sage: ch = AugmentedChowRingIdeal(M=M1, R=QQ, atom_free=True) + sage: ch.groebner_basis() + [B0^2, B0*B1, B0*B2, B0*B1, B1^2, B1*B2, B0*B2, B1*B2, B2^2] + """ gb = [] - flats = self.flats + flats = [X for i in range(1, self._matroid.rank()) + for X in self._matroid.flats(i)] if Set([]) in flats: flats.remove(Set([])) - if atom_free: + if self.atom_free: for F in flats: for G in flats: if not (F > G or G > F): gb.append(self.flats_generator[F]*self.flats_generator[G]) elif F < G: term = self.poly_ring.zero() - for H in self.flats: + for H in flats: if H < F: term += self.flats_generator[H] gb.append(self.flats_generator[F]*(term**self._matroid.rank(Set(G)))* From 980c63f5e9b066ce917a34e9932ce1acf788ca57 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 2 Jul 2024 10:24:13 +0530 Subject: [PATCH 013/167] Added Documentation to Chow ring class --- src/sage/matroids/chow_ring.py | 62 ++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index d4b817564a2..66de4c1a967 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -4,15 +4,63 @@ from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis import sage.misc.latex as latex -#chow rings class needs to be written properly -#gens of chow ring ideal must be debugged -#gb must be a poly sequence -#commented and documented -#use is_groebner() -#matroids - try all of them +r""" +Chow rings of matroids + +AUTHORS: + +- Travis Scrimshaw +- Shriya M + +These are the classes of Chow rings for matroids. It also takes in +a parameter boolean ``augmented`` which creates the augmented Chow +ring if given ``True``. + + +REFERENCES + +- :arxiv:`2309.14312` +- :arxiv:`2111.00393` +""" +#***************************************************************************** +# Copyright (C) 2024 Travis Scrimshaw +# 2024 Shriya M +# +# Distributed under the terms of the GNU General Public License (GPL) +# +# This code is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# The full text of the GPL is available at: +# +# http://www.gnu.org/licenses/ +#***************************************************************************** class ChowRing(QuotientRing_nc): + r""" + The class of Chow ring, a multi-polynomial quotient ring. + Base class - ``QuotientRing_nc``. + + INPUT: + + + - `M` -- a matroid. + - `R` -- a ring. + - ``augmented`` -- a Boolean value. When ``True``, it returns the augmented Chow + ring. If ``False``, it returns the Chow ring + + OUTPUT: Chow ring of matroid `M`. + + EXAMPLES:: + + sage: M1 = matroids.catalog.P8pp() + sage: ch = ChowRing(M=M1, R=QQ, augmented=False) + sage: ch + Chow ring of P8'': Matroid of rank 4 on 8 elements with 8 nonspanning circuits + """ def __init__(self, R, M, augmented): self._matroid = M self._augmented = augmented @@ -20,7 +68,7 @@ def __init__(self, R, M, augmented): self._ideal = AugmentedChowRingIdeal(M, R) else: self._ideal = ChowRingIdeal(M, R) #check method to get ring - QuotientRing_nc.__init__(self, R=self._ideal.poly_ring, I=self._ideal, names=self.poly_ring.variable_names(), category=GradedAlgebrasWithBasis(R)) + QuotientRing_nc.__init__(self, R=self._ideal.poly_ring, I=self._ideal, names=self._ideal.poly_ring.variable_names(), category=GradedAlgebrasWithBasis(R)) def _repr_(self): return "Chow ring of {}".format(self._matroid) From ca4bdc4876dd9d7ae140f1bb5bff62bd247fb52b Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 9 Jul 2024 18:58:20 +0530 Subject: [PATCH 014/167] Added Chow rings section in documentation --- src/doc/en/reference/matroids/index.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/doc/en/reference/matroids/index.rst b/src/doc/en/reference/matroids/index.rst index b52c5b3420a..ca7d39d2f54 100644 --- a/src/doc/en/reference/matroids/index.rst +++ b/src/doc/en/reference/matroids/index.rst @@ -65,4 +65,10 @@ Internals sage/matroids/set_system sage/matroids/unpickling +.. toctree:: + :maxdepth: 1 + + sage/matroids/chow_ring_ideal + sage/matroids/chow_ring + .. include:: ../footer.txt From 79538064adfdcabea73b25b378d88e3566503d9f Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 9 Jul 2024 18:59:14 +0530 Subject: [PATCH 015/167] Split Augmented Chow ring ideal class into 3 classes --- src/sage/matroids/chow_ring_ideal.py | 325 +++++++++++++++------------ 1 file changed, 178 insertions(+), 147 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 5c3ebabb9d6..908012c2a7b 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -1,16 +1,8 @@ -from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal -from sage.matroids.matroid import Matroid -from sage.matroids.utilities import cmp_elements_key -from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.sets.set import Set -from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence - r""" Chow ring ideals of matroids AUTHORS: -- Travis Scrimshaw - Shriya M These are the classes of Chow ring ideals for matroids. There are two classes @@ -25,21 +17,14 @@ - :arxiv:`2309.14312` - :arxiv:`2111.00393` """ -#***************************************************************************** -# Copyright (C) 2024 Travis Scrimshaw -# 2024 Shriya M -# -# Distributed under the terms of the GNU General Public License (GPL) -# -# This code is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# The full text of the GPL is available at: -# -# http://www.gnu.org/licenses/ -#***************************************************************************** + +from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal +from sage.matroids.utilities import cmp_elements_key +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing +from sage.sets.set import Set +from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence +from abc import ABC, abstractmethod, ABCMeta +from sage.structure.sage_object import SageObject class ChowRingIdeal(MPolynomialIdeal): r""" @@ -128,17 +113,14 @@ def groebner_basis(self): for G in flats: if not (F < G or G < F): gb.append(self.flats_generator[F]*self.flats_generator[G]) - elif Set(F).is_empty(): - term = self.poly_ring.zero() - for H in flats: - if H < F: - term += self.flats_generator[H] - gb.append(term**self._matroid.rank(Set(G))) - elif F < G: + else: term = self.poly_ring.zero() for H in flats: if H < F: term += self.flats_generator[H] + if Set(F).is_empty(): + gb.append(term**self._matroid.rank(Set(G))) + else: gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) g_basis = PolynomialSequence(self.poly_ring, [gb]) @@ -150,12 +132,28 @@ def matroid(self): def flats_generator(self): return dict(self.flats_generator) + +class AugmentedChowRingIdeal(SageObject): + + @abstractmethod + def gens_constructor(): + pass + @abstractmethod + def groebner_basis(): + pass + def matroid(self): + M = self._matroid + return M + + def flats_generator(self): + return dict(self.flats_generator) -class AugmentedChowRingIdeal(MPolynomialIdeal): +class AugmentedChowRingIdeal_fy(AugmentedChowRingIdeal, MPolynomialIdeal): r""" - The class of Chow ring ideal, a multi-polynomial ideal. + The class of augmented Chow ring ideal of Feitchner-Yuzvinsky + presentation, a multi-polynomial ideal. Base class - ``MPolynomialIdeal``. INPUT: @@ -163,96 +161,171 @@ class AugmentedChowRingIdeal(MPolynomialIdeal): - `M` -- a matroid. - `R` -- a ring. - - ``atom_free`` -- a Boolean value, default value set to ``False``. When - ``True``, it returns the atom-free presentation of the augmented Chow - ring. If ``False``, it returns the Feitchner-Yuzvinsky presentation of the - augmented Chow ring. - OUTPUT: augmented Chow ring ideal of matroid `M`. + OUTPUT: augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky + presentation. EXAMPLES:: Augmented Chow ring ideal of Wheel matroid of rank 3:: - sage: ch = AugumentedChowRingIdeal(M=matroids.Wheel(3), R=QQ) + sage: ch = AugumentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation """ - def __init__(self, M, R, atom_free=False): - self.atom_free = atom_free + def __init__(self, M, R): self._matroid = M - flats = [X for i in range(1, self._matroid.rank()) + self.flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] - + E = list(self._matroid.groundset()) + self.flats_generator = dict() + try: + names_groundset = ['A{}'.format(''.join(str(x))) for x in E] + names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] + self.poly_ring = PolynomialRing(R, names_groundset + names_flats) + except ValueError: + self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) + for i,x in enumerate(E): + self.flats_generator[x] = self.poly_ring.gens()[i] + for i,F in enumerate(self.flats): + self.flats_generator[F] = self.poly_ring.gens()[len(E) + i] + MPolynomialIdeal.__init__(self, self.poly_ring, self.gens_constructor()) + + def gens_constructor(self): E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} - for F in flats: + for F in self.flats: for x in F: flats_containing[x].append(F) + + Q = list() + for F in self.flats: + for G in self.flats: + if not (F < G or G < F): + Q.append(self.flats_generator[F] * self.flats_generator[G]) + L = list() + for x in E: + term = self.poly_ring.zero() + for F in self.flats: + if F not in flats_containing[x]: + term += self.flats_generator[F] + L.append(self.flats_generator[x] - term) + return Q + L + + def __repr__(self): + return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) + + def groebner_basis(self): + r""" + Returns the Groebner basis of the augmented Chow ring ideal. + Return type - ``PolynomialSequence``. + + EXAMPLES:: + + sage: ch = AugmentedChowRingIdeal_fy(M=matroids.catalog.Fano(), R=QQ) + sage: ch.groebner_basis() + Polynomial Sequence with 2744 Polynomials in 21 Variables + """ + gb = [] + E = list(self._matroid.groundset()) + for i in E: + for F in self.flats: + for G in self.flats: + term = self.poly_ring.zero() + term1 = self.poly_ring.zero() + for H in self.flats: + if i in Set(H): + term += self.flats_generator[H] + if H > F: + term1 += self.flats_generator[H] + + gb.append(self.flats_generator[i] + term) + gb.append(term1**(self._matroid.rank(Set(F))) + 1) + + if i in Set(F): + gb.append(self.flats_generator[i]*((term1)**self._matroid.rank(Set(F)))) + + elif not i in Set(F): + gb.append(self.flats_generator[i]*self.flats_generator[F]) + + elif not (F < G or G < F): + gb.append(self.flats_generator[F]*self.flats_generator[G]) + + elif G < F: + gb.append(self.flats_generator[G]*term1**(self._matroid.rank(Set(F))-self._matroid.rank(Set(G)))) + + g_basis = PolynomialSequence(self.poly_ring, [gb]) + return g_basis + +class AugmentedChowRingIdeal_atom_free(AugmentedChowRingIdeal, MPolynomialIdeal): + r""" + The class of augmented Chow ring ideal of atom-free + presentation, a multi-polynomial ideal. + Base class - ``MPolynomialIdeal``. + + INPUT: + + + - `M` -- a matroid. + - `R` -- a ring. + + OUTPUT: augmented Chow ring ideal of matroid `M` of atom-free + presentation. + + EXAMPLES:: + + Augmented Chow ring ideal of Wheel matroid of rank 3:: + + sage: ch = AugumentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: ch + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases of atom-free presentation + """ + def __init__(self, M, R): + self._matroid = M + self.flats = [X for i in range(1, self._matroid.rank()) + for X in self._matroid.flats(i)] + E = list(self._matroid.groundset()) self.flats_generator = dict() try: names_groundset = ['A{}'.format(''.join(str(x))) for x in E] - names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] + names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] self.poly_ring = PolynomialRing(R, names_groundset + names_flats) except ValueError: - self.poly_ring = PolynomialRing(R, 'A', len(E) + len(flats)) - gens = self.poly_ring.gens() + self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) for i,x in enumerate(E): - self.flats_generator[x] = gens[i] - for i,F in enumerate(flats): - self.flats_generator[F] = gens[len(E) + i] + self.flats_generator[x] = self.poly_ring.gens()[i] + for i,F in enumerate(self.flats): + self.flats_generator[F] = self.poly_ring.gens()[len(E) + i] + MPolynomialIdeal.__init__(self, self.poly_ring, self.gens_constructor()) - - le = len(E) - Q = list() - for i,F in enumerate(flats): - for j,G in enumerate(flats): - if not (F < G or G < F): - Q.append(gens[le+i] * gens[le+j]) - - for j,F in enumerate(flats): - for k,x in enumerate(E): + def gens_constructor(self): + E = list(self._matroid.groundset()) + Q = [] + flats_containing = {x: [] for x in E} + for F in self.flats: + for x in F: + flats_containing[x].append(F) + for F in self.flats: + for x in E: if F not in flats_containing[x]: - if self.atom_free: - term = self.poly_ring.zero() - for G in flats_containing[x]: - term += self.flats_generator[G] + Q.append(self.flats_generator[x]*self.flats_generator[F]) + term = self.poly_ring.zero() + for G in flats_containing[x]: + term += self.flats_generator[G] Q.append(self.flats_generator[F]*term) - else: - Q.append(gens[k]*gens[le+j]) + for i in E: + term = self.poly_ring.zero() + for F in flats_containing[i]: + term += self.flats_generator[F] + Q.append(term**2) - if self.atom_free: - for i in E: - term = self.poly_ring.zero() - for F in flats_containing[i]: - term += self.flats_generator[F] - Q.append(term**2) - - MPolynomialIdeal.__init__(self, self.poly_ring, Q) - else: - L = list() - for i,x in enumerate(E): - term = self.poly_ring.zero() - for j,F in enumerate(flats): - if F not in flats_containing[x]: - term += gens[le+j] - L.append(gens[i] - term) + return Q - MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) - def __repr__(self): - if self.atom_free: - return "Augmented Chow ring ideal of {} of atom-free presentation".format(self._matroid) - else: - return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) - - def matroid(self): - return self._matroid - - def flat_generator(self): - return dict(self.flats_generator) + return "Augmented Chow ring ideal of {} of atom-free presentation".format(self._matroid) def groebner_basis(self): r""" @@ -261,16 +334,8 @@ def groebner_basis(self): EXAMPLES:: - sage: ch = AugmentedChowRingIdeal(M=matroids.catalog.Fano(), R=QQ) - sage: ch.groebner_basis() - Polynomial Sequence with 2744 Polynomials in 21 Variables - - Another example would be the Groebner basis of the augmented Chow ring - ideal (atom-free presentation) of the Graphic matroid of cycle graph of - 3 vertices:: - sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) - sage: ch = AugmentedChowRingIdeal(M=M1, R=QQ, atom_free=True) + sage: ch = AugmentedChowRingIdeal_atom_free(M=M1, R=QQ) sage: ch.groebner_basis() [B0^2, B0*B1, B0*B2, B0*B1, B1^2, B1*B2, B0*B2, B1*B2, B2^2] """ @@ -279,56 +344,22 @@ def groebner_basis(self): for X in self._matroid.flats(i)] if Set([]) in flats: flats.remove(Set([])) - if self.atom_free: - for F in flats: - for G in flats: - if not (F > G or G > F): - gb.append(self.flats_generator[F]*self.flats_generator[G]) - elif F < G: - term = self.poly_ring.zero() - for H in flats: - if H < F: - term += self.flats_generator[H] - gb.append(self.flats_generator[F]*(term**self._matroid.rank(Set(G)))* - (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) - - else: - E = list(self._matroid.groundset()) - for i in E: - for F in flats: - for G in flats: - term = self.poly_ring.zero() - for H in flats: - if i in Set(H): - term += self.flats_generator[H] - gb.append(self.flats_generator[i] + term) - - if i in Set(F): - term = self.poly_ring.zero() - for H in flats: - if H < F: - term += self.flats_generator[H] - gb.append(self.flats_generator[i]*(term**self._matroid.rank(Set(G)))* - (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) - - elif not i in Set(F): - gb.append(self.flats_generator[i]*self.flats_generator[F]) - - elif not (F < G or G < F): - gb.append(self.flats_generator[F]*self.flats_generator[G]) - - elif F < G: - term = self.poly_ring.zero() - for H in flats: - if H < F: - term += self.flats_generator[H] - gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) + for F in flats: + for G in flats: + if not (F > G or G > F): + gb.append(self.flats_generator[F]*self.flats_generator[G]) + elif F < G: + term = self.poly_ring.zero() + for H in flats: + if H < F: + term += self.flats_generator[H] + gb.append(self.flats_generator[F]*(term**self._matroid.rank(Set(G)))* + (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) g_basis = PolynomialSequence(self.poly_ring, [gb]) return g_basis - From 1d9210a78b13a8febf9d2277c3cfac520bfe71d3 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 9 Jul 2024 19:02:38 +0530 Subject: [PATCH 016/167] Edited Documentation --- src/sage/matroids/chow_ring.py | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 66de4c1a967..2c8ac514574 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -1,15 +1,8 @@ -from sage.matroids.chow_ring_ideal import * -from sage.rings.quotient_ring import QuotientRing_nc -from sage.rings.quotient_ring_element import QuotientRingElement -from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis -import sage.misc.latex as latex - r""" Chow rings of matroids AUTHORS: -- Travis Scrimshaw - Shriya M These are the classes of Chow rings for matroids. It also takes in @@ -22,26 +15,16 @@ - :arxiv:`2309.14312` - :arxiv:`2111.00393` """ -#***************************************************************************** -# Copyright (C) 2024 Travis Scrimshaw -# 2024 Shriya M -# -# Distributed under the terms of the GNU General Public License (GPL) -# -# This code is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# The full text of the GPL is available at: -# -# http://www.gnu.org/licenses/ -#***************************************************************************** +from sage.matroids.chow_ring_ideal import ChowRingIdeal, AugmentedChowRingIdeal +from sage.rings.quotient_ring import QuotientRing_nc +from sage.rings.quotient_ring_element import QuotientRingElement +from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis +import sage.misc.latex as latex class ChowRing(QuotientRing_nc): r""" - The class of Chow ring, a multi-polynomial quotient ring. + The class of Chow ring, a multi-polynomial quotient ring. Base class - ``QuotientRing_nc``. INPUT: @@ -50,7 +33,7 @@ class ChowRing(QuotientRing_nc): - `M` -- a matroid. - `R` -- a ring. - ``augmented`` -- a Boolean value. When ``True``, it returns the augmented Chow - ring. If ``False``, it returns the Chow ring + ring. If ``False``, it returns the Chow ring OUTPUT: Chow ring of matroid `M`. @@ -74,5 +57,4 @@ def _repr_(self): return "Chow ring of {}".format(self._matroid) def _latex_(self): - return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) - + return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) From 80738208ed68780c5eafc4490bffa9cc973eec01 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 14 Jul 2024 15:58:57 +0530 Subject: [PATCH 017/167] Edited Documentation --- src/sage/matroids/chow_ring_ideal.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 908012c2a7b..62e80774859 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -27,7 +27,8 @@ from sage.structure.sage_object import SageObject class ChowRingIdeal(MPolynomialIdeal): - r""" + def __init__(self, M, R): + """ The class of Chow ring ideal, a multi-polynomial ideal. Base class - ``MPolynomialIdeal``. @@ -50,8 +51,6 @@ class ChowRingIdeal(MPolynomialIdeal): sage: ch = ChowRingIdeal(M=matroids.catalog.Fano(), R=QQ) Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ - - def __init__(self, M, R): self._matroid = M flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] @@ -87,7 +86,7 @@ def __repr__(self): return "Chow ring ideal of {}".format(self._matroid) def groebner_basis(self): - r""" + """ Returns the Groebner basis of the Chow ring ideal of consideration. Return type - ``PolynomialSequence``. @@ -151,7 +150,8 @@ def flats_generator(self): return dict(self.flats_generator) class AugmentedChowRingIdeal_fy(AugmentedChowRingIdeal, MPolynomialIdeal): - r""" + def __init__(self, M, R): + """ The class of augmented Chow ring ideal of Feitchner-Yuzvinsky presentation, a multi-polynomial ideal. Base class - ``MPolynomialIdeal``. @@ -174,7 +174,6 @@ class AugmentedChowRingIdeal_fy(AugmentedChowRingIdeal, MPolynomialIdeal): Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation """ - def __init__(self, M, R): self._matroid = M self.flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] @@ -217,7 +216,7 @@ def __repr__(self): return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) def groebner_basis(self): - r""" + """ Returns the Groebner basis of the augmented Chow ring ideal. Return type - ``PolynomialSequence``. @@ -259,7 +258,8 @@ def groebner_basis(self): return g_basis class AugmentedChowRingIdeal_atom_free(AugmentedChowRingIdeal, MPolynomialIdeal): - r""" + def __init__(self, M, R): + """ The class of augmented Chow ring ideal of atom-free presentation, a multi-polynomial ideal. Base class - ``MPolynomialIdeal``. @@ -282,7 +282,6 @@ class AugmentedChowRingIdeal_atom_free(AugmentedChowRingIdeal, MPolynomialIdeal) Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation """ - def __init__(self, M, R): self._matroid = M self.flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] @@ -328,7 +327,7 @@ def __repr__(self): return "Augmented Chow ring ideal of {} of atom-free presentation".format(self._matroid) def groebner_basis(self): - r""" + """ Returns the Groebner basis of the augmented Chow ring ideal. Return type - ``PolynomialSequence``. From b3f9e31561878f7cc56640a8b0ba96fc636f8cb1 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 14 Jul 2024 15:59:47 +0530 Subject: [PATCH 018/167] Created a documentation block for chow rings --- src/doc/en/reference/matroids/index.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/en/reference/matroids/index.rst b/src/doc/en/reference/matroids/index.rst index ca7d39d2f54..5f1bf9f5f45 100644 --- a/src/doc/en/reference/matroids/index.rst +++ b/src/doc/en/reference/matroids/index.rst @@ -65,6 +65,9 @@ Internals sage/matroids/set_system sage/matroids/unpickling + Chow rings of matroids + ---------------------- + .. toctree:: :maxdepth: 1 From b867da5c3877d9a6e320ee845c7676c079909587 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 15 Jul 2024 08:14:56 +0530 Subject: [PATCH 019/167] Edited latex() method --- src/sage/matroids/chow_ring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 2c8ac514574..e63998e629b 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -20,7 +20,6 @@ from sage.rings.quotient_ring import QuotientRing_nc from sage.rings.quotient_ring_element import QuotientRingElement from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis -import sage.misc.latex as latex class ChowRing(QuotientRing_nc): r""" @@ -57,4 +56,5 @@ def _repr_(self): return "Chow ring of {}".format(self._matroid) def _latex_(self): + import sage.misc.latex as latex return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) From cba41ab47f04c4d18da1c69060c14d58125f851c Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 16 Jul 2024 14:13:23 +0530 Subject: [PATCH 020/167] Corrected Doctests --- src/sage/matroids/chow_ring_ideal.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 62e80774859..bca13ceb384 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -44,11 +44,14 @@ def __init__(self, M, R): Chow ring ideal of uniform matroid of rank 3 on 6 elements:: + sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal + sage: ch = ChowRingIdeal(M=matroids.Uniform(3,6), R=QQ) sage: ch Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} sage: ch = ChowRingIdeal(M=matroids.catalog.Fano(), R=QQ) + sage: ch Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ self._matroid = M @@ -92,6 +95,9 @@ def groebner_basis(self): EXAMPLES:: + sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal + sage: from sage.matroids.basis_matroid import BasisMatroid + sage: ch = ChowRingIdeal(M=BasisMatroid(groundset='abc', bases=['ab', 'ac']), R=QQ) sage: ch.groebner_basis() [Aa^2, Aa*Abc, Aa*Abc, Abc^2] @@ -102,7 +108,7 @@ def groebner_basis(self): the Non-Fano matroid:: sage: ch = ChowRingIdeal(M=matroids.catalog.NonFano(), R=QQ) - sage: ch.groebner.basis() + sage: ch.groebner_basis() Polynomial Sequence with 592 Polynomials in 16 Variables """ @@ -169,6 +175,8 @@ def __init__(self, M, R): Augmented Chow ring ideal of Wheel matroid of rank 3:: + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy + sage: ch = AugumentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on @@ -222,6 +230,8 @@ def groebner_basis(self): EXAMPLES:: + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy + sage: ch = AugmentedChowRingIdeal_fy(M=matroids.catalog.Fano(), R=QQ) sage: ch.groebner_basis() Polynomial Sequence with 2744 Polynomials in 21 Variables @@ -277,6 +287,8 @@ def __init__(self, M, R): Augmented Chow ring ideal of Wheel matroid of rank 3:: + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free + sage: ch = AugumentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on @@ -333,6 +345,8 @@ def groebner_basis(self): EXAMPLES:: + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free + sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) sage: ch = AugmentedChowRingIdeal_atom_free(M=M1, R=QQ) sage: ch.groebner_basis() From c90fe5bcf003a4581235cbcfe5563190baa0bf74 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 17 Jul 2024 13:29:40 +0530 Subject: [PATCH 021/167] Edited Doctests --- src/sage/matroids/chow_ring.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index e63998e629b..4745df22ea1 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -18,7 +18,6 @@ from sage.matroids.chow_ring_ideal import ChowRingIdeal, AugmentedChowRingIdeal from sage.rings.quotient_ring import QuotientRing_nc -from sage.rings.quotient_ring_element import QuotientRingElement from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis class ChowRing(QuotientRing_nc): @@ -38,6 +37,8 @@ class ChowRing(QuotientRing_nc): EXAMPLES:: + sage: from sage.matroids.chow_ring import ChowRing + sage: M1 = matroids.catalog.P8pp() sage: ch = ChowRing(M=M1, R=QQ, augmented=False) sage: ch From cf83d974dfe2dde9839171d5cc64bfaf939c3af6 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 17 Jul 2024 13:29:54 +0530 Subject: [PATCH 022/167] Corrected Doctests --- src/sage/matroids/chow_ring_ideal.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index bca13ceb384..8e3751d915d 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -138,7 +138,8 @@ def matroid(self): def flats_generator(self): return dict(self.flats_generator) -class AugmentedChowRingIdeal(SageObject): + +class AugmentedChowRingIdeal(SageObject, metaclass=ABCMeta): @abstractmethod def gens_constructor(): @@ -155,7 +156,7 @@ def matroid(self): def flats_generator(self): return dict(self.flats_generator) -class AugmentedChowRingIdeal_fy(AugmentedChowRingIdeal, MPolynomialIdeal): +class AugmentedChowRingIdeal_fy(MPolynomialIdeal, metaclass=AugmentedChowRingIdeal): def __init__(self, M, R): """ The class of augmented Chow ring ideal of Feitchner-Yuzvinsky From d892cdb7c32a3717be8b49b61b65c496e021863e Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 18 Jul 2024 08:15:22 +0530 Subject: [PATCH 023/167] Edited abstract class - AugmentedChowRingIdeal --- src/sage/matroids/chow_ring_ideal.py | 31 +++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 8e3751d915d..cc7feb467bb 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -138,9 +138,10 @@ def matroid(self): def flats_generator(self): return dict(self.flats_generator) +class CombinedMeta(ABCMeta, type): + pass -class AugmentedChowRingIdeal(SageObject, metaclass=ABCMeta): - +class AugmentedChowRingIdeal(CombinedMeta): @abstractmethod def gens_constructor(): pass @@ -156,7 +157,7 @@ def matroid(self): def flats_generator(self): return dict(self.flats_generator) -class AugmentedChowRingIdeal_fy(MPolynomialIdeal, metaclass=AugmentedChowRingIdeal): +class AugmentedChowRingIdeal_fy(SageObject,MPolynomialIdeal, AugmentedChowRingIdeal): def __init__(self, M, R): """ The class of augmented Chow ring ideal of Feitchner-Yuzvinsky @@ -183,9 +184,10 @@ def __init__(self, M, R): Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation """ + def __init__(self, M, R): self._matroid = M self.flats = [X for i in range(1, self._matroid.rank()) - for X in self._matroid.flats(i)] + for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) self.flats_generator = dict() try: @@ -199,6 +201,7 @@ def __init__(self, M, R): for i,F in enumerate(self.flats): self.flats_generator[F] = self.poly_ring.gens()[len(E) + i] MPolynomialIdeal.__init__(self, self.poly_ring, self.gens_constructor()) + def gens_constructor(self): E = list(self._matroid.groundset()) @@ -268,7 +271,7 @@ def groebner_basis(self): g_basis = PolynomialSequence(self.poly_ring, [gb]) return g_basis -class AugmentedChowRingIdeal_atom_free(AugmentedChowRingIdeal, MPolynomialIdeal): +class AugmentedChowRingIdeal_atom_free(AugmentedChowRingIdeal): def __init__(self, M, R): """ The class of augmented Chow ring ideal of atom-free @@ -295,22 +298,8 @@ def __init__(self, M, R): Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation """ - self._matroid = M - self.flats = [X for i in range(1, self._matroid.rank()) - for X in self._matroid.flats(i)] - E = list(self._matroid.groundset()) - self.flats_generator = dict() - try: - names_groundset = ['A{}'.format(''.join(str(x))) for x in E] - names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] - self.poly_ring = PolynomialRing(R, names_groundset + names_flats) - except ValueError: - self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) - for i,x in enumerate(E): - self.flats_generator[x] = self.poly_ring.gens()[i] - for i,F in enumerate(self.flats): - self.flats_generator[F] = self.poly_ring.gens()[len(E) + i] - MPolynomialIdeal.__init__(self, self.poly_ring, self.gens_constructor()) + + AugmentedChowRingIdeal.__init__(self, M, R) def gens_constructor(self): E = list(self._matroid.groundset()) From fdd0444e379223d51bccceaa376f10faabf9ba04 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 23 Jul 2024 15:53:20 +0530 Subject: [PATCH 024/167] Split ChowRingIdeal into 4 classes --- src/sage/matroids/chow_ring_ideal.py | 194 +++++++++++++++++---------- 1 file changed, 122 insertions(+), 72 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index cc7feb467bb..902dec3565f 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -5,7 +5,7 @@ - Shriya M -These are the classes of Chow ring ideals for matroids. There are two classes +These are the classes of Chow ring ideals for matroids. There are three classes created - Chow ring ideal and augmented Chow ring ideal. The augmented Chow ring ideal has two different presentations implemented - the Feitchner- Yuzvinsky presentation and atom-free presentation. Both classes have @@ -23,12 +23,23 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.sets.set import Set from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence -from abc import ABC, abstractmethod, ABCMeta -from sage.structure.sage_object import SageObject +from sage.misc.abstract_method import abstract_method class ChowRingIdeal(MPolynomialIdeal): - def __init__(self, M, R): - """ + @abstract_method + def gens_constructor(): + pass + + def matroid(self): + M = self._matroid + return M + + def flats_generator(self): + return dict(self.flats_generator) + + +class ChowRingIdeal_nonaug(ChowRingIdeal): + r""" The class of Chow ring ideal, a multi-polynomial ideal. Base class - ``MPolynomialIdeal``. @@ -44,16 +55,27 @@ def __init__(self, M, R): Chow ring ideal of uniform matroid of rank 3 on 6 elements:: - sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal + sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug - sage: ch = ChowRingIdeal(M=matroids.Uniform(3,6), R=QQ) + sage: ch = ChowRingIdeal_nonaug(M=matroids.Uniform(3,6), R=QQ) sage: ch Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} - sage: ch = ChowRingIdeal(M=matroids.catalog.Fano(), R=QQ) + sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) sage: ch Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ + def __init__(self, M, R): + r""" + Initialize ``self``. + + EXAMPLES:: + + sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug + + sage: I = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) + sage: TestSuite(I).run() + """ self._matroid = M flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] @@ -89,16 +111,16 @@ def __repr__(self): return "Chow ring ideal of {}".format(self._matroid) def groebner_basis(self): - """ + r""" Returns the Groebner basis of the Chow ring ideal of consideration. Return type - ``PolynomialSequence``. EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal + sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug sage: from sage.matroids.basis_matroid import BasisMatroid - sage: ch = ChowRingIdeal(M=BasisMatroid(groundset='abc', bases=['ab', 'ac']), R=QQ) + sage: ch = ChowRingIdeal_nonaug(M=BasisMatroid(groundset='abc', bases=['ab', 'ac']), R=QQ) sage: ch.groebner_basis() [Aa^2, Aa*Abc, Aa*Abc, Abc^2] sage: ch.groebner_basis().is_groebner() @@ -107,7 +129,7 @@ def groebner_basis(self): Another example would be the Groebner basis of the Chow ring ideal of the Non-Fano matroid:: - sage: ch = ChowRingIdeal(M=matroids.catalog.NonFano(), R=QQ) + sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.NonFano(), R=QQ) sage: ch.groebner_basis() Polynomial Sequence with 592 Polynomials in 16 Variables """ @@ -121,7 +143,7 @@ def groebner_basis(self): else: term = self.poly_ring.zero() for H in flats: - if H < F: + if H < G: term += self.flats_generator[H] if Set(F).is_empty(): gb.append(term**self._matroid.rank(Set(G))) @@ -130,61 +152,45 @@ def groebner_basis(self): g_basis = PolynomialSequence(self.poly_ring, [gb]) return g_basis - - - def matroid(self): - return self._matroid - def flats_generator(self): - return dict(self.flats_generator) -class CombinedMeta(ABCMeta, type): - pass +class AugmentedChowRingIdeal_fy(ChowRingIdeal): + r""" + The class of augmented Chow ring ideal of Feitchner-Yuzvinsky + presentation, a multi-polynomial ideal. + Base class - ``MPolynomialIdeal``. -class AugmentedChowRingIdeal(CombinedMeta): - @abstractmethod - def gens_constructor(): - pass + INPUT: - @abstractmethod - def groebner_basis(): - pass - def matroid(self): - M = self._matroid - return M - - def flats_generator(self): - return dict(self.flats_generator) + - `M` -- a matroid. + - `R` -- a ring. -class AugmentedChowRingIdeal_fy(SageObject,MPolynomialIdeal, AugmentedChowRingIdeal): - def __init__(self, M, R): - """ - The class of augmented Chow ring ideal of Feitchner-Yuzvinsky - presentation, a multi-polynomial ideal. - Base class - ``MPolynomialIdeal``. - - INPUT: + OUTPUT: augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky + presentation. + EXAMPLES:: - - `M` -- a matroid. - - `R` -- a ring. + Augmented Chow ring ideal of Wheel matroid of rank 3:: - OUTPUT: augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky - presentation. + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy - EXAMPLES:: + sage: ch = AugumentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: ch + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + """ + def __init__(self, M, R): + r""" + Initialize ``self``. - Augmented Chow ring ideal of Wheel matroid of rank 3:: + EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy + sage: from sage.matroids.chow_ring_ideal import AugumentedChowRingIdeal_fy - sage: ch = AugumentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) - sage: ch - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on - 6 elements with 16 bases of Feitchner-Yuzvinsky presentation - """ - def __init__(self, M, R): + sage: I = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: TestSuite(I).run() + """ self._matroid = M self.flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] @@ -228,7 +234,7 @@ def __repr__(self): return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) def groebner_basis(self): - """ + r""" Returns the Groebner basis of the augmented Chow ring ideal. Return type - ``PolynomialSequence``. @@ -238,7 +244,7 @@ def groebner_basis(self): sage: ch = AugmentedChowRingIdeal_fy(M=matroids.catalog.Fano(), R=QQ) sage: ch.groebner_basis() - Polynomial Sequence with 2744 Polynomials in 21 Variables + Polynomial Sequence with 4116 Polynomials in 21 Variables """ gb = [] E = list(self._matroid.groundset()) @@ -271,23 +277,20 @@ def groebner_basis(self): g_basis = PolynomialSequence(self.poly_ring, [gb]) return g_basis -class AugmentedChowRingIdeal_atom_free(AugmentedChowRingIdeal): - def __init__(self, M, R): - """ - The class of augmented Chow ring ideal of atom-free - presentation, a multi-polynomial ideal. - Base class - ``MPolynomialIdeal``. +class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): + r""" + The augmented Chow ring ideal in the atom-free + presentation. INPUT: - - - `M` -- a matroid. - - `R` -- a ring. + - ``M`` -- a matroid + - ``R`` -- a ring OUTPUT: augmented Chow ring ideal of matroid `M` of atom-free presentation. - EXAMPLES:: + EXAMPLES: Augmented Chow ring ideal of Wheel matroid of rank 3:: @@ -297,9 +300,49 @@ def __init__(self, M, R): sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation - """ + """ + def __init__(self, M, R): #documentation of every init + r""" + Initialize ``self``. + + EXAMPLES:: + + sage: from sage.matroids.chow_ring_ideal import AugumentedChowRingIdeal_atom_free + + sage: I = AugumentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: TestSuite(I).run() + """ + self._matroid = M + flats = [X for i in range(1, self._matroid.rank()) + for X in self._matroid.flats(i)] + + E = list(self._matroid.groundset()) + flats_containing = {x: [] for x in E} + for i,F in enumerate(flats): + for x in F: + flats_containing[x].append(i) + + names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] + + try: + self.poly_ring = PolynomialRing(R, names) #self.ring + except ValueError: # variables are not proper names + self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) + + + gens = self.poly_ring.gens() + self.flats_generator = dict(zip(flats, gens)) + + + Q = [gens[i] * gens[i+j+1] for i,F in enumerate(flats) + for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] + L = [sum(gens[i] for i in flats_containing[x]) + - sum(gens[i] for i in flats_containing[y]) + for j,x in enumerate(E) for y in E[j+1:]] + + + MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) - AugmentedChowRingIdeal.__init__(self, M, R) def gens_constructor(self): E = list(self._matroid.groundset()) @@ -336,11 +379,12 @@ def groebner_basis(self): EXAMPLES:: sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free + sage: from sage.matroids.graphic_matroid import GraphicMatroid sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) sage: ch = AugmentedChowRingIdeal_atom_free(M=M1, R=QQ) sage: ch.groebner_basis() - [B0^2, B0*B1, B0*B2, B0*B1, B1^2, B1*B2, B0*B2, B1*B2, B2^2] + [A0^2, A0*A1, A0*A2, A0*A1, A1^2, A1*A2, A0*A2, A1*A2, A2^2] """ gb = [] flats = [X for i in range(1, self._matroid.rank()) @@ -365,10 +409,16 @@ def groebner_basis(self): +#linting tests pass +#single underscore for attributes +#Developer's guide +#use 'self' in docstrings +#rebase chow_ring from repr_update +#common base class for all chow ring ideals - augmented parameter +#getting ring from chow ring ideal to chow ring +#references in the main index - - From 1d42f3ada22abc992ca19568ffd6d599cd8cbfdb Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 23 Jul 2024 15:53:34 +0530 Subject: [PATCH 025/167] Edited documentation --- src/sage/matroids/chow_ring.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 4745df22ea1..e67328abb5b 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -16,7 +16,7 @@ - :arxiv:`2111.00393` """ -from sage.matroids.chow_ring_ideal import ChowRingIdeal, AugmentedChowRingIdeal +from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug, AugmentedChowRingIdeal_fy, AugmentedChowRingIdeal_atom_free from sage.rings.quotient_ring import QuotientRing_nc from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis @@ -44,13 +44,16 @@ class ChowRing(QuotientRing_nc): sage: ch Chow ring of P8'': Matroid of rank 4 on 8 elements with 8 nonspanning circuits """ - def __init__(self, R, M, augmented): + def __init__(self, R, M, augmented, presentation=None): self._matroid = M self._augmented = augmented if augmented: - self._ideal = AugmentedChowRingIdeal(M, R) + if presentation=='fy': + self._ideal = AugmentedChowRingIdeal_fy(M, R) + elif presentation=='atom-free': + self._ideal = AugmentedChowRingIdeal_fy(M, R) else: - self._ideal = ChowRingIdeal(M, R) #check method to get ring + self._ideal = ChowRingIdeal_nonaug(M, R) #check method to get ring QuotientRing_nc.__init__(self, R=self._ideal.poly_ring, I=self._ideal, names=self._ideal.poly_ring.variable_names(), category=GradedAlgebrasWithBasis(R)) def _repr_(self): From 20fa80f5f292e113492cbe797908615bb64e2817 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 23 Jul 2024 16:13:26 +0530 Subject: [PATCH 026/167] Debugged groebner_basis() method for ChowRingIdeal_nonaug --- src/sage/matroids/chow_ring_ideal.py | 81 +++++++++++++--------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 902dec3565f..21b0994a8c9 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -79,33 +79,29 @@ def __init__(self, M, R): self._matroid = M flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] - - E = list(self._matroid.groundset()) - flats_containing = {x: [] for x in E} - for i,F in enumerate(flats): - for x in F: - flats_containing[x].append(i) - names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] - try: self.poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) - - gens = self.poly_ring.gens() self.flats_generator = dict(zip(flats, gens)) + MPolynomialIdeal.__init__(self, self.poly_ring, self.gens_constructor()) - + def gens_constructor(self): + E = list(self._matroid.groundset()) + flats = list(self.flats_generator.keys()) + flats_containing = {x: [] for x in E} + for i,F in enumerate(flats): + for x in F: + flats_containing[x].append(i) + gens = self.poly_ring.gens() Q = [gens[i] * gens[i+j+1] for i,F in enumerate(flats) for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] L = [sum(gens[i] for i in flats_containing[x]) - sum(gens[i] for i in flats_containing[y]) for j,x in enumerate(E) for y in E[j+1:]] - - - MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) + return Q + L def __repr__(self): return "Chow ring ideal of {}".format(self._matroid) @@ -131,7 +127,7 @@ def groebner_basis(self): sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.NonFano(), R=QQ) sage: ch.groebner_basis() - Polynomial Sequence with 592 Polynomials in 16 Variables + Polynomial Sequence with 232 Polynomials in 16 Variables """ flats = list(self.flats_generator.keys()) @@ -143,17 +139,16 @@ def groebner_basis(self): else: term = self.poly_ring.zero() for H in flats: - if H < G: + if H > G: term += self.flats_generator[H] if Set(F).is_empty(): gb.append(term**self._matroid.rank(Set(G))) - else: + elif F < G: gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) g_basis = PolynomialSequence(self.poly_ring, [gb]) return g_basis - class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" The class of augmented Chow ring ideal of Feitchner-Yuzvinsky @@ -175,7 +170,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy - sage: ch = AugumentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: ch = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation @@ -186,25 +181,25 @@ def __init__(self, M, R): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugumentedChowRingIdeal_fy + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy sage: I = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) sage: TestSuite(I).run() """ self._matroid = M - self.flats = [X for i in range(1, self._matroid.rank()) + self._flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) self.flats_generator = dict() try: names_groundset = ['A{}'.format(''.join(str(x))) for x in E] - names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self.flats] + names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] self.poly_ring = PolynomialRing(R, names_groundset + names_flats) except ValueError: - self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self.flats)) + self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self._flats)) for i,x in enumerate(E): self.flats_generator[x] = self.poly_ring.gens()[i] - for i,F in enumerate(self.flats): + for i,F in enumerate(self._flats): self.flats_generator[F] = self.poly_ring.gens()[len(E) + i] MPolynomialIdeal.__init__(self, self.poly_ring, self.gens_constructor()) @@ -212,19 +207,19 @@ def __init__(self, M, R): def gens_constructor(self): E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} - for F in self.flats: + for F in self._flats: for x in F: flats_containing[x].append(F) Q = list() - for F in self.flats: - for G in self.flats: + for F in self._flats: + for G in self._flats: if not (F < G or G < F): Q.append(self.flats_generator[F] * self.flats_generator[G]) L = list() for x in E: term = self.poly_ring.zero() - for F in self.flats: + for F in self._flats: if F not in flats_containing[x]: term += self.flats_generator[F] L.append(self.flats_generator[x] - term) @@ -249,11 +244,11 @@ def groebner_basis(self): gb = [] E = list(self._matroid.groundset()) for i in E: - for F in self.flats: - for G in self.flats: + for F in self._flats: + for G in self._flats: term = self.poly_ring.zero() term1 = self.poly_ring.zero() - for H in self.flats: + for H in self._flats: if i in Set(H): term += self.flats_generator[H] if H > F: @@ -296,7 +291,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free - sage: ch = AugumentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: ch = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation @@ -307,35 +302,35 @@ def __init__(self, M, R): #documentation of every init EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugumentedChowRingIdeal_atom_free + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free - sage: I = AugumentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: I = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) sage: TestSuite(I).run() """ self._matroid = M - flats = [X for i in range(1, self._matroid.rank()) + self._flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} - for i,F in enumerate(flats): + for i,F in enumerate(self._flats): for x in F: flats_containing[x].append(i) - names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] + names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] try: self.poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names - self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) + self.poly_ring = PolynomialRing(R, 'A', len(self._flats)) gens = self.poly_ring.gens() - self.flats_generator = dict(zip(flats, gens)) + self.flats_generator = dict(zip(self._flats, gens)) - Q = [gens[i] * gens[i+j+1] for i,F in enumerate(flats) - for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] + Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self._flats) + for j,G in enumerate(self._flats[i+1:]) if not (F < G or G < F)] L = [sum(gens[i] for i in flats_containing[x]) - sum(gens[i] for i in flats_containing[y]) for j,x in enumerate(E) for y in E[j+1:]] @@ -348,10 +343,10 @@ def gens_constructor(self): E = list(self._matroid.groundset()) Q = [] flats_containing = {x: [] for x in E} - for F in self.flats: + for F in self._flats: for x in F: flats_containing[x].append(F) - for F in self.flats: + for F in self._flats: for x in E: if F not in flats_containing[x]: Q.append(self.flats_generator[x]*self.flats_generator[F]) From 0ee932fb2acb0a2fcbca7f14a4b80bbcee601cde Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 23 Jul 2024 16:18:16 +0530 Subject: [PATCH 027/167] Added TestSuite.run() doctest to ChowRing class --- src/sage/matroids/chow_ring.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index e67328abb5b..bcbd31e4ba8 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -45,6 +45,16 @@ class ChowRing(QuotientRing_nc): Chow ring of P8'': Matroid of rank 4 on 8 elements with 8 nonspanning circuits """ def __init__(self, R, M, augmented, presentation=None): + r""" + Initialize ``self``. + + EXAMPLES:: + + sage: from sage.matroids.chow_ring import ChowRing + + sage: I = ChowRing(M=matroids.Wheel(3), R=QQ, augmented=False) + sage: TestSuite(I).run() + """ self._matroid = M self._augmented = augmented if augmented: From 470d69bd9c465158bfc51016474ae3f4bcabcbf9 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 29 Jul 2024 15:44:33 +0530 Subject: [PATCH 028/167] Added basis() method --- src/sage/matroids/chow_ring.py | 186 ++++++++++++++++++++++++++++++++- 1 file changed, 184 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index bcbd31e4ba8..304692bfbab 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -19,6 +19,10 @@ from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug, AugmentedChowRingIdeal_fy, AugmentedChowRingIdeal_atom_free from sage.rings.quotient_ring import QuotientRing_nc from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis +from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence +from sage.sets.set import Set +from sage.combinat.posets.posets import Poset + class ChowRing(QuotientRing_nc): r""" @@ -57,14 +61,15 @@ def __init__(self, R, M, augmented, presentation=None): """ self._matroid = M self._augmented = augmented + self._presentation = presentation if augmented: if presentation=='fy': self._ideal = AugmentedChowRingIdeal_fy(M, R) elif presentation=='atom-free': - self._ideal = AugmentedChowRingIdeal_fy(M, R) + self._ideal = AugmentedChowRingIdeal_atom_free(M, R) else: self._ideal = ChowRingIdeal_nonaug(M, R) #check method to get ring - QuotientRing_nc.__init__(self, R=self._ideal.poly_ring, I=self._ideal, names=self._ideal.poly_ring.variable_names(), category=GradedAlgebrasWithBasis(R)) + QuotientRing_nc.__init__(self, R=self._ideal.ring(), I=self._ideal, names=self._ideal.ring().variable_names(), category=GradedAlgebrasWithBasis(R)) def _repr_(self): return "Chow ring of {}".format(self._matroid) @@ -72,3 +77,180 @@ def _repr_(self): def _latex_(self): import sage.misc.latex as latex return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) + + def _coerce_map_from_base_ring(self): + r""" + Disable the coercion from the base ring from the category. + + TESTS:: + + sage: SGA = SymmetricGroupAlgebra(QQ, 4) + sage: GP = SGA.garsia_procesi_module([2, 2]) + sage: GP._coerce_map_from_base_ring() is None + True + """ + return None # don't need anything special + + def basis(self): + flats = [Set(X) for i in range(1, self._matroid.rank()) + for X in self._matroid.flats(i)] + flats.append(Set([])) + maximum_rank = max([self._matroid.rank(F) for F in flats]) + func = lambda A,B: A.issubset(B) + flats = Poset((flats, func), cover_relations=True).directed_subsets('down') #DEBUG + monomial_basis = [] + if self._augmented: + if self._presentation=='fy': + for i in range(maximum_rank): + term = self._ideal.ring().one() + for j in range(len(flats)): + if j == 0: + if i > self._matroid.rank(flats[0]): + term *= self._flats_generator[flats[j]]**(0) + else: + term *= self._flats_generator[flats[j]]**(i + 1) + else: + if i >= (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1])): + term *= self._flats_generator[flats[j]]**(0) + else: + term *= self._flats_generator[flats[j]]**(i + 1) + monomial_basis.append(term) + + elif self._presentation=='atom-free': + for i in range(maximum_rank): + term = self._ideal.ring().one() + pow = [] + for j in range(1, len(flats) - 1): + if i >= (self._matroid.rank(flats[j-1]) - self._matroid.rank(flats[j])): + pow.append((j , i)) + if sum(pow) == self._matroid.rank(flats[0]): + for p in pow: + term *= self._flats_generator[flats[p[0]]]**(p[1]) + monomial_basis.append(term) + + + else: + for i in range(maximum_rank): + term = self._ideal.ring().one() + for j in range(len(flats)): + if i > (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1]) - 1): + term *= self._flats_generator[flats[j]]**(0) + else: + term *= self._flats_generator[flats[j]]**(i + 1) + monomial_basis.append(term) + + + m_basis = PolynomialSequence([monomial_basis], self._ideal.ring()) + return m_basis + + + + + + + + + + + + + + + class Element(QuotientRing_nc.Element): + def to_vector(self, order=None): + r""" + Return ``self`` as a (dense) free module vector. + + EXAMPLES:: + + sage: SGA = SymmetricGroupAlgebra(GF(3), 4) + sage: GP22 = SGA.garsia_procesi_module([2, 2]) + sage: v = GP22.an_element(); v + -gp1 - gp2 - gp3 + sage: v.to_vector() + (0, 0, 2, 2, 2, 0) + """ + P = self.parent() + B = P.basis() + FM = P._dense_free_module() + f = self.lift() + return FM([f.monomial_coefficient(b.lift()) for b in B]) + + _vector_ = to_vector + + def monomial_coefficients(self, copy=None): + r""" + Return the monomial coefficients of ``self``. + + EXAMPLES:: + + sage: SGA = SymmetricGroupAlgebra(GF(3), 4) + sage: GP31 = SGA.garsia_procesi_module([3, 1]) + sage: v = GP31.an_element(); v + -gp1 - gp2 - gp3 + sage: v.monomial_coefficients() + {0: 2, 1: 2, 2: 2, 3: 0} + """ + B = self.parent().basis() + f = self.lift() + return {i: f.monomial_coefficient(b.lift()) for i, b in enumerate(B)} + + def degree(self): + r""" + Return the degree of ``self``. + + EXAMPLES:: + + sage: SGA = SymmetricGroupAlgebra(GF(3), 4) + sage: GP22 = SGA.garsia_procesi_module([2, 2]) + sage: for b in GP22.basis(): + ....: print(b, b.degree()) + gp2*gp3 2 + gp1*gp3 2 + gp3 1 + gp2 1 + gp1 1 + 1 0 + sage: v = sum(GP22.basis()) + sage: v.degree() + 2 + """ + return self.lift().degree() + + def homogeneous_degree(self): + r""" + Return the (homogeneous) degree of ``self`` if homogeneous + otherwise raise an error. + + EXAMPLES:: + + sage: SGA = SymmetricGroupAlgebra(GF(2), 4) + sage: GP31 = SGA.garsia_procesi_module([3, 1]) + sage: for b in GP31.basis(): + ....: print(b, b.homogeneous_degree()) + gp3 1 + gp2 1 + gp1 1 + 1 0 + sage: v = sum(GP31.basis()); v + gp1 + gp2 + gp3 + 1 + sage: v.homogeneous_degree() + Traceback (most recent call last): + ... + ValueError: element is not homogeneous + + TESTS:: + + sage: SGA = SymmetricGroupAlgebra(GF(3), 4) + sage: GP4 = SGA.garsia_procesi_module([4]) + sage: GP4.zero().homogeneous_degree() + Traceback (most recent call last): + ... + ValueError: the zero element does not have a well-defined degree + """ + if not self: + raise ValueError("the zero element does not have a well-defined degree") + f = self.lift() + if not f.is_homogeneous(): + raise ValueError("element is not homogeneous") + return f.degree() \ No newline at end of file From a724173b8887ad130c3f0f631a01e08b12e77a5c Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 29 Jul 2024 15:45:23 +0530 Subject: [PATCH 029/167] Edited attribute names --- src/sage/matroids/chow_ring_ideal.py | 138 +++++++++++---------------- 1 file changed, 58 insertions(+), 80 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 21b0994a8c9..6520474ab75 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -27,7 +27,7 @@ class ChowRingIdeal(MPolynomialIdeal): @abstract_method - def gens_constructor(): + def _gens_constructor(): pass def matroid(self): @@ -35,7 +35,7 @@ def matroid(self): return M def flats_generator(self): - return dict(self.flats_generator) + return dict(self._flats_generator) class ChowRingIdeal_nonaug(ChowRingIdeal): @@ -74,28 +74,28 @@ def __init__(self, M, R): sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug sage: I = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) - sage: TestSuite(I).run() + sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] try: - self.poly_ring = PolynomialRing(R, names) #self.ring + poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names - self.poly_ring = PolynomialRing(R, 'A', len(self.flats)) - gens = self.poly_ring.gens() - self.flats_generator = dict(zip(flats, gens)) - MPolynomialIdeal.__init__(self, self.poly_ring, self.gens_constructor()) + poly_ring = PolynomialRing(R, 'A', len(self.flats)) + gens = poly_ring.gens() + self._flats_generator = dict(zip(flats, gens)) + MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) - def gens_constructor(self): + def _gens_constructor(self, poly_ring): E = list(self._matroid.groundset()) - flats = list(self.flats_generator.keys()) + flats = list(self._flats_generator.keys()) flats_containing = {x: [] for x in E} for i,F in enumerate(flats): for x in F: flats_containing[x].append(i) - gens = self.poly_ring.gens() + gens = poly_ring.gens() Q = [gens[i] * gens[i+j+1] for i,F in enumerate(flats) for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] L = [sum(gens[i] for i in flats_containing[x]) @@ -130,23 +130,24 @@ def groebner_basis(self): Polynomial Sequence with 232 Polynomials in 16 Variables """ - flats = list(self.flats_generator.keys()) + flats = list(self._flats_generator) gb = list() + R = self.ring() for F in flats: for G in flats: if not (F < G or G < F): - gb.append(self.flats_generator[F]*self.flats_generator[G]) + gb.append(self._flats_generator[F]*self._flats_generator[G]) else: - term = self.poly_ring.zero() + term = R.zero() for H in flats: if H > G: - term += self.flats_generator[H] + term += self._flats_generator[H] if Set(F).is_empty(): - gb.append(term**self._matroid.rank(Set(G))) + gb.append(term**self._matroid.rank(G)) elif F < G: - gb.append(term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F)))) + gb.append(term**(self._matroid.rank(G)-self._matroid.rank(F))) - g_basis = PolynomialSequence(self.poly_ring, [gb]) + g_basis = PolynomialSequence(R, [gb]) return g_basis class AugmentedChowRingIdeal_fy(ChowRingIdeal): @@ -194,17 +195,17 @@ def __init__(self, M, R): try: names_groundset = ['A{}'.format(''.join(str(x))) for x in E] names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] - self.poly_ring = PolynomialRing(R, names_groundset + names_flats) + poly_ring = PolynomialRing(R, names_groundset + names_flats) except ValueError: - self.poly_ring = PolynomialRing(R, 'A', len(E) + len(self._flats)) + poly_ring = PolynomialRing(R, 'A', len(E) + len(self._flats)) for i,x in enumerate(E): - self.flats_generator[x] = self.poly_ring.gens()[i] + self._flats_generator[x] = poly_ring.gens()[i] for i,F in enumerate(self._flats): - self.flats_generator[F] = self.poly_ring.gens()[len(E) + i] - MPolynomialIdeal.__init__(self, self.poly_ring, self.gens_constructor()) + self._flats_generator[F] = poly_ring.gens()[len(E) + i] + MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) - def gens_constructor(self): + def _gens_constructor(self, poly_ring): E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} for F in self._flats: @@ -215,14 +216,14 @@ def gens_constructor(self): for F in self._flats: for G in self._flats: if not (F < G or G < F): - Q.append(self.flats_generator[F] * self.flats_generator[G]) + Q.append(self._flats_generator[F] * self._flats_generator[G]) L = list() for x in E: - term = self.poly_ring.zero() + term = poly_ring.zero() for F in self._flats: if F not in flats_containing[x]: - term += self.flats_generator[F] - L.append(self.flats_generator[x] - term) + term += self._flats_generator[F] + L.append(self._flats_generator[x] - term) return Q + L def __repr__(self): @@ -243,33 +244,34 @@ def groebner_basis(self): """ gb = [] E = list(self._matroid.groundset()) + poly_ring = self.ring() for i in E: for F in self._flats: for G in self._flats: - term = self.poly_ring.zero() - term1 = self.poly_ring.zero() + term = poly_ring.zero() + term1 = poly_ring.zero() for H in self._flats: if i in Set(H): - term += self.flats_generator[H] + term += self._flats_generator[H] if H > F: - term1 += self.flats_generator[H] + term1 += self._flats_generator[H] - gb.append(self.flats_generator[i] + term) + gb.append(self._flats_generator[i] + term) gb.append(term1**(self._matroid.rank(Set(F))) + 1) if i in Set(F): - gb.append(self.flats_generator[i]*((term1)**self._matroid.rank(Set(F)))) + gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(Set(F)))) elif not i in Set(F): - gb.append(self.flats_generator[i]*self.flats_generator[F]) + gb.append(self._flats_generator[i]*self._flats_generator[F]) elif not (F < G or G < F): - gb.append(self.flats_generator[F]*self.flats_generator[G]) + gb.append(self._flats_generator[F]*self._flats_generator[G]) elif G < F: - gb.append(self.flats_generator[G]*term1**(self._matroid.rank(Set(F))-self._matroid.rank(Set(G)))) + gb.append(self._flats_generator[G]*term1**(self._matroid.rank(Set(F))-self._matroid.rank(Set(G)))) - g_basis = PolynomialSequence(self.poly_ring, [gb]) + g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): @@ -296,7 +298,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation """ - def __init__(self, M, R): #documentation of every init + def __init__(self, M, R): r""" Initialize ``self``. @@ -305,7 +307,7 @@ def __init__(self, M, R): #documentation of every init sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free sage: I = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) - sage: TestSuite(I).run() + sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M self._flats = [X for i in range(1, self._matroid.rank()) @@ -320,26 +322,14 @@ def __init__(self, M, R): #documentation of every init names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] try: - self.poly_ring = PolynomialRing(R, names) #self.ring + poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names - self.poly_ring = PolynomialRing(R, 'A', len(self._flats)) - - - gens = self.poly_ring.gens() - self.flats_generator = dict(zip(self._flats, gens)) - - - Q = [gens[i] * gens[i+j+1] for i,F in enumerate(self._flats) - for j,G in enumerate(self._flats[i+1:]) if not (F < G or G < F)] - L = [sum(gens[i] for i in flats_containing[x]) - - sum(gens[i] for i in flats_containing[y]) - for j,x in enumerate(E) for y in E[j+1:]] - + poly_ring = PolynomialRing(R, 'A', len(self._flats)) - MPolynomialIdeal.__init__(self, self.poly_ring, Q + L) + MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) - def gens_constructor(self): + def _gens_constructor(self, poly_ring): E = list(self._matroid.groundset()) Q = [] flats_containing = {x: [] for x in E} @@ -349,16 +339,16 @@ def gens_constructor(self): for F in self._flats: for x in E: if F not in flats_containing[x]: - Q.append(self.flats_generator[x]*self.flats_generator[F]) - term = self.poly_ring.zero() + Q.append(self._flats_generator[x]*self._flats_generator[F]) + term = poly_ring.zero() for G in flats_containing[x]: - term += self.flats_generator[G] - Q.append(self.flats_generator[F]*term) + term += self._flats_generator[G] + Q.append(self._flats_generator[F]*term) for i in E: - term = self.poly_ring.zero() + term = poly_ring.zero() for F in flats_containing[i]: - term += self.flats_generator[F] + term += self._flats_generator[F] Q.append(term**2) return Q @@ -384,36 +374,24 @@ def groebner_basis(self): gb = [] flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] + poly_ring = self.ring() if Set([]) in flats: flats.remove(Set([])) for F in flats: for G in flats: if not (F > G or G > F): - gb.append(self.flats_generator[F]*self.flats_generator[G]) + gb.append(self._flats_generator[F]*self._flats_generator[G]) elif F < G: - term = self.poly_ring.zero() + term = poly_ring.zero() for H in flats: if H < F: - term += self.flats_generator[H] - gb.append(self.flats_generator[F]*(term**self._matroid.rank(Set(G)))* + term += self._flats_generator[H] + gb.append(self._flats_generator[F]*(term**self._matroid.rank(Set(G)))* (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) - g_basis = PolynomialSequence(self.poly_ring, [gb]) + g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis - - - -#linting tests pass -#single underscore for attributes -#Developer's guide -#use 'self' in docstrings -#rebase chow_ring from repr_update -#common base class for all chow ring ideals - augmented parameter -#getting ring from chow ring ideal to chow ring -#references in the main index - - From 7ab59ad5094d6178715f258ab466201f35e75bba Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 29 Jul 2024 15:45:50 +0530 Subject: [PATCH 030/167] Modified chow_ring() method --- src/sage/matroids/matroid.pyx | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 5591e14c038..785dc795df4 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8027,7 +8027,7 @@ cdef class Matroid(SageObject): return [F for F in FF if fsol[F]] - def chow_ring(self, R=None): + def chow_ring(self, R, augmented=False, presentation=None): r""" Return the Chow ring of ``self`` over ``R``. @@ -8099,37 +8099,8 @@ cdef class Matroid(SageObject): - [FY2004]_ - [AHK2015]_ """ - # Setup - if R is None: - R = ZZ - # We only want proper flats - flats = [X for i in range(1, self.rank()) - for X in self.flats(i)] - E = list(self.groundset()) - flats_containing = {x: [] for x in E} - for i,F in enumerate(flats): - for x in F: - flats_containing[x].append(i) - - # Create the ambient polynomial ring - from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing - try: - names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] - P = PolynomialRing(R, names) - except ValueError: # variables are not proper names - P = PolynomialRing(R, 'A', len(flats)) - names = P.variable_names() - gens = P.gens() - # Create the ideal of quadratic relations - Q = [gens[i] * gens[i+j+1] for i,F in enumerate(flats) - for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] - # Create the ideal of linear relations - L = [sum(gens[i] for i in flats_containing[x]) - - sum(gens[i] for i in flats_containing[y]) - for j,x in enumerate(E) for y in E[j+1:]] - ret = P.quotient(Q + L, names=names) - ret.rename("Chow ring of {} over {}".format(self, R)) - return ret + from sage.matroids.chow_ring import ChowRing + return ChowRing(M=self, R=R, augmented=augmented, presentation=presentation) cpdef plot(self, B=None, lineorders=None, pos_method=None,pos_dict=None,save_pos=False): """ From 2ec5329523008289d3a08d2c72197bab4a8289d5 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 30 Jul 2024 12:04:21 +0530 Subject: [PATCH 031/167] Modified basis() method --- src/sage/matroids/chow_ring.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 304692bfbab..6a05c45ac3f 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -21,7 +21,7 @@ from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence from sage.sets.set import Set -from sage.combinat.posets.posets import Poset +from functools import cmp_to_key class ChowRing(QuotientRing_nc): @@ -96,8 +96,15 @@ def basis(self): for X in self._matroid.flats(i)] flats.append(Set([])) maximum_rank = max([self._matroid.rank(F) for F in flats]) - func = lambda A,B: A.issubset(B) - flats = Poset((flats, func), cover_relations=True).directed_subsets('down') #DEBUG + flats_gen = self._ideal.flats_generator() + def func(A, B): + if A.issubset(B): + return 1 + elif B.issubset(A): + return -1 + else: + return 0 + flats = sorted(flats, key=cmp_to_key(func)) monomial_basis = [] if self._augmented: if self._presentation=='fy': @@ -106,14 +113,15 @@ def basis(self): for j in range(len(flats)): if j == 0: if i > self._matroid.rank(flats[0]): - term *= self._flats_generator[flats[j]]**(0) + term *= flats_gen[flats[j]]**(0) else: - term *= self._flats_generator[flats[j]]**(i + 1) + term *= flats_gen[flats[j]]**(i + 1) else: if i >= (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1])): - term *= self._flats_generator[flats[j]]**(0) + if (flats[j] in list(flats_gen)): + term *= flats_gen[flats[j]]**(0) else: - term *= self._flats_generator[flats[j]]**(i + 1) + term *= flats_gen[flats[j]]**(i + 1) monomial_basis.append(term) elif self._presentation=='atom-free': @@ -123,9 +131,9 @@ def basis(self): for j in range(1, len(flats) - 1): if i >= (self._matroid.rank(flats[j-1]) - self._matroid.rank(flats[j])): pow.append((j , i)) - if sum(pow) == self._matroid.rank(flats[0]): + if sum([p[1] for p in pow]) == self._matroid.rank(flats[0]): for p in pow: - term *= self._flats_generator[flats[p[0]]]**(p[1]) + term *= flats_gen[flats[p[0]]]**(p[1]) monomial_basis.append(term) @@ -134,13 +142,14 @@ def basis(self): term = self._ideal.ring().one() for j in range(len(flats)): if i > (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1]) - 1): - term *= self._flats_generator[flats[j]]**(0) + if flats[j] in list(flats_gen): + term *= flats_gen[flats[j]]**(0) else: - term *= self._flats_generator[flats[j]]**(i + 1) + term *= flats_gen[flats[j]]**(i + 1) monomial_basis.append(term) - m_basis = PolynomialSequence([monomial_basis], self._ideal.ring()) + m_basis = PolynomialSequence(self._ideal.ring(), monomial_basis) return m_basis From d9271fd17448a99d035ec0fe1b19d2b759081c2d Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 30 Jul 2024 12:04:46 +0530 Subject: [PATCH 032/167] Debugged AugmentedChowRingIdeal_atom_free.__init__() --- src/sage/matroids/chow_ring_ideal.py | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 6520474ab75..686b11bd5eb 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -191,7 +191,7 @@ def __init__(self, M, R): self._flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) - self.flats_generator = dict() + self._flats_generator = dict() try: names_groundset = ['A{}'.format(''.join(str(x))) for x in E] names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] @@ -325,7 +325,9 @@ def __init__(self, M, R): poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names poly_ring = PolynomialRing(R, 'A', len(self._flats)) - + gens = poly_ring.gens() + self._flats_generator = dict() + self._flats_generator = dict(zip(self._flats, gens)) MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) @@ -337,19 +339,20 @@ def _gens_constructor(self, poly_ring): for x in F: flats_containing[x].append(F) for F in self._flats: - for x in E: - if F not in flats_containing[x]: - Q.append(self._flats_generator[x]*self._flats_generator[F]) + for G in self._flats: + if not (G > F or F > G): + Q.append(self._flats_generator[F]*self._flats_generator[G]) + for x in E: term = poly_ring.zero() - for G in flats_containing[x]: - term += self._flats_generator[G] + for H in flats_containing[x]: + term += self._flats_generator[H] + Q.append(term**2) + + if F not in flats_containing[x]: + term = poly_ring.zero() + for H in flats_containing[x]: + term += self._flats_generator[H] Q.append(self._flats_generator[F]*term) - - for i in E: - term = poly_ring.zero() - for F in flats_containing[i]: - term += self._flats_generator[F] - Q.append(term**2) return Q From 4d1097d38ae3a967e1626f3c3a506c4572d195ab Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 5 Aug 2024 11:45:27 +0530 Subject: [PATCH 033/167] Added Element() class --- src/sage/matroids/chow_ring.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 6a05c45ac3f..1a8e8f2bed1 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -22,7 +22,7 @@ from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence from sage.sets.set import Set from functools import cmp_to_key - +from sage.misc.misc_c import prod class ChowRing(QuotientRing_nc): r""" @@ -112,29 +112,24 @@ def func(A, B): term = self._ideal.ring().one() for j in range(len(flats)): if j == 0: - if i > self._matroid.rank(flats[0]): - term *= flats_gen[flats[j]]**(0) - else: + if i <= self._matroid.rank(flats[0]): term *= flats_gen[flats[j]]**(i + 1) else: - if i >= (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1])): - if (flats[j] in list(flats_gen)): - term *= flats_gen[flats[j]]**(0) - else: - term *= flats_gen[flats[j]]**(i + 1) + if i < (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1])): #store the ranks as a list + if flats[j] in flats_gen: + term *= flats_gen[flats[j]]**(i + 1) monomial_basis.append(term) - elif self._presentation=='atom-free': + elif self._presentation == 'atom-free': #all double equals need spacing + first_rank = self._matroid.rank(flats[len(flats)]) for i in range(maximum_rank): - term = self._ideal.ring().one() pow = [] for j in range(1, len(flats) - 1): - if i >= (self._matroid.rank(flats[j-1]) - self._matroid.rank(flats[j])): + if i >= (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1])): pow.append((j , i)) - if sum([p[1] for p in pow]) == self._matroid.rank(flats[0]): - for p in pow: - term *= flats_gen[flats[p[0]]]**(p[1]) - monomial_basis.append(term) + if sum(p[1] for p in pow) == first_rank: + term = prod(flats_gen[flats[p[0]]] ** p[1] for p in pow) + monomial_basis.append(term) else: From d03c0e0220ea400e1e4bd3af2f7e3abf26cbcab1 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 5 Aug 2024 11:45:49 +0530 Subject: [PATCH 034/167] Written doctests for every method --- src/sage/matroids/chow_ring_ideal.py | 94 ++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 13 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 686b11bd5eb..73f4ed0eb86 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -31,27 +31,44 @@ def _gens_constructor(): pass def matroid(self): + r""" + Return the matroid of the given Chow ring ideal. + + EXAMPLE:: + + sage: ch = ChowRingIdeal_nonaug(M=matroids.Uniform(3,6), R=QQ) + sage: ch.matroid() + U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures + {3: {{0, 1, 2, 3, 4, 5}}} + """ M = self._matroid return M def flats_generator(self): + r""" + Return the variables of every corresponding flat/groundset element + of the matroid. + + EXAMPLE:: + + sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) + sage: ch.flats_generator() #WHERE IS OUTPUT? + """ return dict(self._flats_generator) -class ChowRingIdeal_nonaug(ChowRingIdeal): +class ChowRingIdeal_nonaug(ChowRingIdeal): r""" - The class of Chow ring ideal, a multi-polynomial ideal. - Base class - ``MPolynomialIdeal``. + The Chow ring ideal. INPUT: + - `M` -- a matroid + - `R` -- a ring - - `M` -- a matroid. - - `R` -- a ring. - - OUTPUT: Chow ring ideal of matroid `M`. + OUTPUT: Chow ring ideal of matroid `M` - EXAMPLES:: + EXAMPLES: Chow ring ideal of uniform matroid of rank 3 on 6 elements:: @@ -89,6 +106,14 @@ def __init__(self, M, R): MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) def _gens_constructor(self, poly_ring): + r""" + Returns the generators of the Chow ring ideal. + + EXAMPLE:: + sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.NonFano(), R=QQ) + sage: ch._gens_constructor() #WHERE IS OUTPUT? + + """ E = list(self._matroid.groundset()) flats = list(self._flats_generator.keys()) flats_containing = {x: [] for x in E} @@ -103,12 +128,19 @@ def _gens_constructor(self, poly_ring): for j,x in enumerate(E) for y in E[j+1:]] return Q + L - def __repr__(self): + def _repr_(self): + r""" + EXAMPLE:: + + sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) + sage: ch + Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + """ return "Chow ring ideal of {}".format(self._matroid) def groebner_basis(self): r""" - Returns the Groebner basis of the Chow ring ideal of consideration. + Returns the Groebner basis of the Chow ring ideal. Return type - ``PolynomialSequence``. EXAMPLES:: @@ -206,6 +238,16 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): + r""" + Return the generators of augmented Chow ring ideal of + Feitchner-Yuzvinsky presentation. + + EXAMPLES:: + + sage: ch = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: ch._gens_constructor() #WHERE IS OUTPUT? + + """ E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} for F in self._flats: @@ -226,7 +268,15 @@ def _gens_constructor(self, poly_ring): L.append(self._flats_generator[x] - term) return Q + L - def __repr__(self): + def _repr_(self): + r""" + EXAMPLES:: + + sage: ch = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: ch + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + """ return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) def groebner_basis(self): @@ -331,7 +381,17 @@ def __init__(self, M, R): MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) - def _gens_constructor(self, poly_ring): + def _gens_constructor(self, poly_ring): + r""" + Return the generators of augmented Chow ring ideal of + atom-free presentation. + + EXAMPLES:: + + sage: ch = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: ch._gens_constructor() #WHERE IS OUTPUT? + + """ E = list(self._matroid.groundset()) Q = [] flats_containing = {x: [] for x in E} @@ -356,7 +416,15 @@ def _gens_constructor(self, poly_ring): return Q - def __repr__(self): + def _repr_(self): + r""" + EXAMPLE:: + + sage: ch = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: ch + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases of atom-free presentation + """ return "Augmented Chow ring ideal of {} of atom-free presentation".format(self._matroid) def groebner_basis(self): From c9a138f1ac7fcd6230882a61dae6e1a58e7f62c2 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 5 Aug 2024 17:22:07 +0530 Subject: [PATCH 035/167] Corrected Doctests for Element class --- src/sage/matroids/chow_ring.py | 82 +++++++++++++++++----------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 1a8e8f2bed1..2267bb67741 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -72,6 +72,16 @@ def __init__(self, R, M, augmented, presentation=None): QuotientRing_nc.__init__(self, R=self._ideal.ring(), I=self._ideal, names=self._ideal.ring().variable_names(), category=GradedAlgebrasWithBasis(R)) def _repr_(self): + r""" + EXAMPLE:: + + sage: from sage.matroids.chow_ring import ChowRing + + sage: M1 = matroids.catalog.Fano() + sage: ch = ChowRing(M=M1, R=QQ, augmented=False) + sage: ch + Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + """ return "Chow ring of {}".format(self._matroid) def _latex_(self): @@ -84,14 +94,21 @@ def _coerce_map_from_base_ring(self): TESTS:: - sage: SGA = SymmetricGroupAlgebra(QQ, 4) - sage: GP = SGA.garsia_procesi_module([2, 2]) - sage: GP._coerce_map_from_base_ring() is None + sage: ch = ChowRing(M=matroids.Wheel(3), R=QQ, augmented=False) + sage: ch._coerce_map_from_base_ring() is None True """ return None # don't need anything special def basis(self): + r""" + Return the monomial basis of the given Chow ring. + + EXAMPLES:: + + sage: ch = ChowRing(M=matroids.Uniform(3, 6), augmented=True, presentation='fy') + sage: ch.basis() + """ flats = [Set(X) for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] flats.append(Set([])) @@ -120,7 +137,7 @@ def func(A, B): term *= flats_gen[flats[j]]**(i + 1) monomial_basis.append(term) - elif self._presentation == 'atom-free': #all double equals need spacing + elif self._presentation == 'atom-free': #all double equals need spacing DEBUG first_rank = self._matroid.rank(flats[len(flats)]) for i in range(maximum_rank): pow = [] @@ -131,7 +148,6 @@ def func(A, B): term = prod(flats_gen[flats[p[0]]] ** p[1] for p in pow) monomial_basis.append(term) - else: for i in range(maximum_rank): term = self._ideal.ring().one() @@ -146,19 +162,6 @@ def func(A, B): m_basis = PolynomialSequence(self._ideal.ring(), monomial_basis) return m_basis - - - - - - - - - - - - - class Element(QuotientRing_nc.Element): def to_vector(self, order=None): @@ -167,12 +170,11 @@ def to_vector(self, order=None): EXAMPLES:: - sage: SGA = SymmetricGroupAlgebra(GF(3), 4) - sage: GP22 = SGA.garsia_procesi_module([2, 2]) - sage: v = GP22.an_element(); v - -gp1 - gp2 - gp3 - sage: v.to_vector() - (0, 0, 2, 2, 2, 0) + sage: ch = ChowRing(M=matroids.Uniform(3, 6), R=QQ, augmented=False) + sage: v = ch.an_element(); v #WHAT IS OUTPUT? + + sage: v.to_vector() #WHAT IS OUTPUT? + """ P = self.parent() B = P.basis() @@ -188,12 +190,11 @@ def monomial_coefficients(self, copy=None): EXAMPLES:: - sage: SGA = SymmetricGroupAlgebra(GF(3), 4) - sage: GP31 = SGA.garsia_procesi_module([3, 1]) - sage: v = GP31.an_element(); v - -gp1 - gp2 - gp3 - sage: v.monomial_coefficients() - {0: 2, 1: 2, 2: 2, 3: 0} + sage: ch = ChowRing(M=matroids.catalog.NonFano(), R=QQ, augmented=True, presentation='fy') + sage: v = ch.an_element(); v #WHAT IS OUTPUT + + sage: v.monomial_coefficients() #WHAT IS OUTPUT + """ B = self.parent().basis() f = self.lift() @@ -205,9 +206,8 @@ def degree(self): EXAMPLES:: - sage: SGA = SymmetricGroupAlgebra(GF(3), 4) - sage: GP22 = SGA.garsia_procesi_module([2, 2]) - sage: for b in GP22.basis(): + sage: ch = ChowRing(M=matroids.catalog.Fano(), R=QQ, augmented=True, presentation='atom-free') + sage: for b in ch.basis(): ....: print(b, b.degree()) gp2*gp3 2 gp1*gp3 2 @@ -215,7 +215,7 @@ def degree(self): gp2 1 gp1 1 1 0 - sage: v = sum(GP22.basis()) + sage: v = sum(ch.basis()) sage: v.degree() 2 """ @@ -228,15 +228,14 @@ def homogeneous_degree(self): EXAMPLES:: - sage: SGA = SymmetricGroupAlgebra(GF(2), 4) - sage: GP31 = SGA.garsia_procesi_module([3, 1]) - sage: for b in GP31.basis(): + ch = ChowRing(M=matroids.Uniform(2, 5), R=QQ, augmented=False) + sage: for b in ch.basis(): ....: print(b, b.homogeneous_degree()) gp3 1 gp2 1 gp1 1 1 0 - sage: v = sum(GP31.basis()); v + sage: v = sum(ch.basis()); v gp1 + gp2 + gp3 + 1 sage: v.homogeneous_degree() Traceback (most recent call last): @@ -244,10 +243,9 @@ def homogeneous_degree(self): ValueError: element is not homogeneous TESTS:: - - sage: SGA = SymmetricGroupAlgebra(GF(3), 4) - sage: GP4 = SGA.garsia_procesi_module([4]) - sage: GP4.zero().homogeneous_degree() + + sage: ch = ChowRing(M=matroids.Wheel(3), R=QQ, augmented=False) + sage: ch.zero().homogeneous_degree() Traceback (most recent call last): ... ValueError: the zero element does not have a well-defined degree From 72a160df51b2e66bf6e23d764bb3b39894ea25e3 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 5 Aug 2024 17:37:40 +0530 Subject: [PATCH 036/167] Edited _repr_() method --- src/sage/matroids/chow_ring.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 2267bb67741..2ddd7f53032 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -82,6 +82,11 @@ def _repr_(self): sage: ch Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ + if self._augmented: + if self._presentation=='fy': + return "Augmented Chow ring of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) + elif self._presentation=='atom-free': + return "Augmented Chow ring of {} of atom-free presentation".format(self._matroid) return "Chow ring of {}".format(self._matroid) def _latex_(self): From 4da26f39676365cfacfb75cc3fa998183623ad86 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 5 Aug 2024 17:37:57 +0530 Subject: [PATCH 037/167] Edited chow_ring() doctest --- src/sage/matroids/matroid.pyx | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 7a5300bc59b..d7e39f3839f 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8059,10 +8059,10 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: M = matroids.Wheel(2) - sage: A = M.chow_ring(); A + sage: A = M.chow_ring(R=ZZ, augmented=False); A Chow ring of Wheel(2): Regular matroid of rank 2 on 4 elements with 5 bases over Integer Ring - sage: A.gens() # needs sage.libs.singular + sage: A._gens_constructor() # needs sage.libs.singular (A23, A23, A23) sage: A23 = A.gen(0) # needs sage.libs.singular sage: A23*A23 # needs sage.libs.singular @@ -8071,28 +8071,17 @@ cdef class Matroid(SageObject): We construct a more interesting example using the Fano matroid:: sage: M = matroids.catalog.Fano() - sage: A = M.chow_ring(QQ); A + sage: A = M.chow_ring(QQ, augmented=False); A Chow ring of Fano: Binary matroid of rank 3 on 7 elements, - type (3, 0) over Rational Field - - Next we get the non-trivial generators and do some computations:: - - sage: # needs sage.libs.singular sage.rings.finite_rings - sage: G = A.gens()[6:] - sage: Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef = G - sage: Ag * Ag - 2*Adef^2 - sage: Ag * Abeg - -Adef^2 - sage: matrix([[x * y for x in G] for y in G]) - [2*Adef^2 0 0 -Adef^2 0 -Adef^2 -Adef^2 0] - [ 0 Adef^2 0 0 0 0 0 0] - [ 0 0 Adef^2 0 0 0 0 0] - [ -Adef^2 0 0 Adef^2 0 0 0 0] - [ 0 0 0 0 Adef^2 0 0 0] - [ -Adef^2 0 0 0 0 Adef^2 0 0] - [ -Adef^2 0 0 0 0 0 Adef^2 0] - [ 0 0 0 0 0 0 0 Adef^2] + type (3, 0) over Rational Field. + + The augmented Chow ring can also be instantiated with the + Feitchner-Yuzvinsky and atom-free presentation:: + + sage: M = matroids.Wheel(3) + sage: ch = M.chow_ring(QQ, augmented=True, presentation='fy') + Augmented Chow ring of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases of Feitchner-Yuzvinsky presentation REFERENCES: From ca5ec9a83eef800b4581e1f09e76246163d31069 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 7 Aug 2024 09:54:50 +0530 Subject: [PATCH 038/167] Wrote doctests for Element class --- src/sage/matroids/chow_ring.py | 95 +++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 2ddd7f53032..25b57b6eb8b 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -90,8 +90,26 @@ def _repr_(self): return "Chow ring of {}".format(self._matroid) def _latex_(self): + r""" + Return the LaTeX output of the polynomial ring and Chow ring ideal. + + EXAMPLE:: + + sage: from sage.matroids.chow_ring import ChowRing + sage: from sage.matroids.graphic_matroid import GraphicMatroid + + sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) + sage: ch = ChowRing(M=M1, R=QQ, augmented=True, presentation='fy') + sage: ch._latex_() + \Bold{Q}[A_{0}, A_{1}, A_{2}, B_{0}, B_{1}, B_{2}]/\left(B_{0}^{2}, + B_{0} B_{1}, B_{0} B_{2}, B_{0} B_{1}, B_{1}^{2}, B_{1} B_{2}, + B_{0} B_{2}, B_{1} B_{2}, B_{2}^{2}, A_{0} - B_{1} - B_{2}, + A_{1} - B_{0} - B_{2}, A_{2} - B_{0} - B_{1}\right) + \Bold{Q}[A_{0}, A_{1}, A_{2}, B_{0}, B_{1}, B_{2}] + + """ import sage.misc.latex as latex - return "%s/%s" % (latex.latex(self.poly_ring), latex.latex(self._ideal)) + return "%s/%s" % (latex.latex(self._ideal.ring()), latex.latex(self._ideal)) def _coerce_map_from_base_ring(self): r""" @@ -99,6 +117,8 @@ def _coerce_map_from_base_ring(self): TESTS:: + sage: from sage.matroids.chow_ring import ChowRing + sage: ch = ChowRing(M=matroids.Wheel(3), R=QQ, augmented=False) sage: ch._coerce_map_from_base_ring() is None True @@ -111,8 +131,13 @@ def basis(self): EXAMPLES:: - sage: ch = ChowRing(M=matroids.Uniform(3, 6), augmented=True, presentation='fy') + sage: from sage.matroids.chow_ring import ChowRing + + sage: ch = ChowRing(M=matroids.Uniform(3, 6), R=QQ, augmented=True, presentation='fy') sage: ch.basis() + [B0*B01, 1] + sage: ch = ChowRing(M=matroids.Wheel(3), R=ZZ, augmented=False) + [A0*A013, 1] """ flats = [Set(X) for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] @@ -121,47 +146,51 @@ def basis(self): flats_gen = self._ideal.flats_generator() def func(A, B): if A.issubset(B): - return 1 - elif B.issubset(A): return -1 + elif B.issubset(A): + return 1 else: return 0 flats = sorted(flats, key=cmp_to_key(func)) + ranks = [self._matroid.rank(F) for F in flats] monomial_basis = [] if self._augmented: - if self._presentation=='fy': + if self._presentation == 'fy': for i in range(maximum_rank): term = self._ideal.ring().one() for j in range(len(flats)): if j == 0: - if i <= self._matroid.rank(flats[0]): - term *= flats_gen[flats[j]]**(i + 1) + if i <= ranks[0]: + if flats[j] in flats_gen: + term *= flats_gen[flats[j]]**(i + 1) else: - if i < (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1])): #store the ranks as a list + if i < ranks[j] - ranks[j-1]: if flats[j] in flats_gen: term *= flats_gen[flats[j]]**(i + 1) monomial_basis.append(term) - elif self._presentation == 'atom-free': #all double equals need spacing DEBUG - first_rank = self._matroid.rank(flats[len(flats)]) + elif self._presentation == 'atom-free': #all double equals need spacing + first_rank = self._matroid.rank(flats[len(flats) - 1]) + print(first_rank) for i in range(maximum_rank): pow = [] for j in range(1, len(flats) - 1): - if i >= (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1])): + if i < ranks[j] - ranks[j-1]: pow.append((j , i)) - if sum(p[1] for p in pow) == first_rank: + if sum(p[1] for p in pow) == first_rank + 1: term = prod(flats_gen[flats[p[0]]] ** p[1] for p in pow) monomial_basis.append(term) - + else: for i in range(maximum_rank): term = self._ideal.ring().one() for j in range(len(flats)): - if i > (self._matroid.rank(flats[j]) - self._matroid.rank(flats[j-1]) - 1): + if i > ranks[j] - ranks[j-1] - 1: if flats[j] in list(flats_gen): term *= flats_gen[flats[j]]**(0) else: - term *= flats_gen[flats[j]]**(i + 1) + if flats[j] in list(flats_gen): + term *= flats_gen[flats[j]]**(i + 1) monomial_basis.append(term) @@ -176,9 +205,9 @@ def to_vector(self, order=None): EXAMPLES:: sage: ch = ChowRing(M=matroids.Uniform(3, 6), R=QQ, augmented=False) - sage: v = ch.an_element(); v #WHAT IS OUTPUT? - - sage: v.to_vector() #WHAT IS OUTPUT? + sage: v = ch.an_element(); v + A0 + sage: v.to_vector() #Error in output! """ P = self.parent() @@ -196,9 +225,9 @@ def monomial_coefficients(self, copy=None): EXAMPLES:: sage: ch = ChowRing(M=matroids.catalog.NonFano(), R=QQ, augmented=True, presentation='fy') - sage: v = ch.an_element(); v #WHAT IS OUTPUT - - sage: v.monomial_coefficients() #WHAT IS OUTPUT + sage: v = ch.an_element(); v + 0 + sage: v.monomial_coefficients() #error in output! """ B = self.parent().basis() @@ -211,14 +240,10 @@ def degree(self): EXAMPLES:: - sage: ch = ChowRing(M=matroids.catalog.Fano(), R=QQ, augmented=True, presentation='atom-free') + sage: ch = ChowRing(M=matroids.Uniform(3, 6), R=QQ, augmented=False) sage: for b in ch.basis(): ....: print(b, b.degree()) - gp2*gp3 2 - gp1*gp3 2 - gp3 1 - gp2 1 - gp1 1 + A0*A01 2 1 0 sage: v = sum(ch.basis()) sage: v.degree() @@ -233,16 +258,14 @@ def homogeneous_degree(self): EXAMPLES:: - ch = ChowRing(M=matroids.Uniform(2, 5), R=QQ, augmented=False) + ch = ChowRing(M=matroids.catalog.Fano(), R=QQ, augmented=True, presentation='fy') sage: for b in ch.basis(): ....: print(b, b.homogeneous_degree()) - gp3 1 - gp2 1 - gp1 1 - 1 0 + Ba*Babf 2 + Ba^2 2 sage: v = sum(ch.basis()); v - gp1 + gp2 + gp3 + 1 - sage: v.homogeneous_degree() + Ba^2 + Ba*Babf + sage: v.homogeneous_degree() #error - basis() type is wrong! Traceback (most recent call last): ... ValueError: element is not homogeneous @@ -250,8 +273,8 @@ def homogeneous_degree(self): TESTS:: sage: ch = ChowRing(M=matroids.Wheel(3), R=QQ, augmented=False) - sage: ch.zero().homogeneous_degree() - Traceback (most recent call last): + sage: ch.zero().homogeneous_degree() #error! + Traceback (most recent call last): ... ValueError: the zero element does not have a well-defined degree """ From a90f02fc88eafe311d71fe266dd64ba6b5e00bf0 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 7 Aug 2024 09:55:10 +0530 Subject: [PATCH 039/167] Edited chow_ring() doctest --- src/sage/matroids/matroid.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index d7e39f3839f..924d2db2878 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8082,6 +8082,10 @@ cdef class Matroid(SageObject): sage: ch = M.chow_ring(QQ, augmented=True, presentation='fy') Augmented Chow ring of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + sage: M = matroids.Uniform(3, 6) + sage: ch = M.chow_ring(QQ, augmented=True, presentation='atom-free') + Augmented Chow ring of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures + {3: {{0, 1, 2, 3, 4, 5}}} of atom-free presentation REFERENCES: From 9d6489a33f6e5f368b646558e514253c85fc54f7 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 7 Aug 2024 09:56:52 +0530 Subject: [PATCH 040/167] Wrote doctests for _gens_constructor() --- src/sage/matroids/chow_ring_ideal.py | 110 ++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 9 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 73f4ed0eb86..a9abde90c2b 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -51,8 +51,16 @@ def flats_generator(self): EXAMPLE:: + sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug + sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) - sage: ch.flats_generator() #WHERE IS OUTPUT? + sage: ch.flats_generator() + {frozenset({'a'}): Aa, frozenset({'b'}): Ab, frozenset({'c'}): Ac, + frozenset({'d'}): Ad, frozenset({'e'}): Ae, frozenset({'f'}): Af, + frozenset({'g'}): Ag, frozenset({'b', 'a', 'f'}): Aabf, + frozenset({'c', 'e', 'a'}): Aace, frozenset({'d', 'g', 'a'}): Aadg, + frozenset({'c', 'b', 'd'}): Abcd, frozenset({'b', 'g', 'e'}): Abeg, + frozenset({'c', 'g', 'f'}): Acfg, frozenset({'d', 'e', 'f'}): Adef} """ return dict(self._flats_generator) @@ -107,11 +115,51 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" - Returns the generators of the Chow ring ideal. + Returns the generators of the Chow ring ideal. Takes in the + ring of Chow ring ideal as input. EXAMPLE:: + + sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug + sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.NonFano(), R=QQ) - sage: ch._gens_constructor() #WHERE IS OUTPUT? + sage: ch._gens_constructor(ch.ring()) + [Aa*Ab, Aa*Ac, Aa*Ad, Aa*Ae, Aa*Af, Aa*Ag, Aa*Abcd, Aa*Abeg, + Aa*Acfg, Aa*Ade, Aa*Adf, Aa*Aef, Ab*Ac, Ab*Ad, Ab*Ae, Ab*Af, Ab*Ag, + Ab*Aace, Ab*Aadg, Ab*Acfg, Ab*Ade, Ab*Adf, Ab*Aef, Ac*Ad, Ac*Ae, + Ac*Af, Ac*Ag, Ac*Aabf, Ac*Aadg, Ac*Abeg, Ac*Ade, Ac*Adf, Ac*Aef, + Ad*Ae, Ad*Af, Ad*Ag, Ad*Aabf, Ad*Aace, Ad*Abeg, Ad*Acfg, Ad*Aef, + Ae*Af, Ae*Ag, Ae*Aabf, Ae*Aadg, Ae*Abcd, Ae*Acfg, Ae*Adf, Af*Ag, + Af*Aace, Af*Aadg, Af*Abcd, Af*Abeg, Af*Ade, Ag*Aabf, Ag*Aace, + Ag*Abcd, Ag*Ade, Ag*Adf, Ag*Aef, Aabf*Aace, Aabf*Aadg, Aabf*Abcd, + Aabf*Abeg, Aabf*Acfg, Aabf*Ade, Aabf*Adf, Aabf*Aef, Aace*Aadg, + Aace*Abcd, Aace*Abeg, Aace*Acfg, Aace*Ade, Aace*Adf, Aace*Aef, + Aadg*Abcd, Aadg*Abeg, Aadg*Acfg, Aadg*Ade, Aadg*Adf, Aadg*Aef, + Abcd*Abeg, Abcd*Acfg, Abcd*Ade, Abcd*Adf, Abcd*Aef, Abeg*Acfg, + Abeg*Ade, Abeg*Adf, Abeg*Aef, Acfg*Ade, Acfg*Adf, Acfg*Aef, + Ade*Adf, Ade*Aef, Adf*Aef, + -Ab + Ae - Aabf + Aace - Abcd + Ade + Aef, + -Ac + Ae - Abcd + Abeg - Acfg + Ade + Aef, + Ae - Ag + Aace - Aadg - Acfg + Ade + Aef, + -Ad + Ae + Aace - Aadg - Abcd + Abeg - Adf + Aef, + -Aa + Ae - Aabf - Aadg + Abeg + Ade + Aef, + Ae - Af - Aabf + Aace + Abeg - Acfg + Ade - Adf, + Ab - Ac + Aabf - Aace + Abeg - Acfg, + Ab - Ag + Aabf - Aadg + Abcd - Acfg, + Ab - Ad + Aabf - Aadg + Abeg - Ade - Adf, + -Aa + Ab - Aace - Aadg + Abcd + Abeg, + Ab - Af + Abcd + Abeg - Acfg - Adf - Aef, + Ac - Ag + Aace - Aadg + Abcd - Abeg, + Ac - Ad + Aace - Aadg + Acfg - Ade - Adf, + -Aa + Ac - Aabf - Aadg + Abcd + Acfg, + Ac - Af - Aabf + Aace + Abcd - Adf - Aef, + -Ad + Ag - Abcd + Abeg + Acfg - Ade - Adf, + -Aa + Ag - Aabf - Aace + Abeg + Acfg, + -Af + Ag - Aabf + Aadg + Abeg - Adf - Aef, + -Aa + Ad - Aabf - Aace + Abcd + Ade + Adf, + Ad - Af - Aabf + Aadg + Abcd - Acfg + Ade - Aef, + Aa - Af + Aace + Aadg - Acfg - Adf - Aef] + """ E = list(self._matroid.groundset()) @@ -132,6 +180,8 @@ def _repr_(self): r""" EXAMPLE:: + sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug + sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) sage: ch Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) @@ -217,7 +267,7 @@ def __init__(self, M, R): sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy sage: I = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) - sage: TestSuite(I).run() + sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M self._flats = [X for i in range(1, self._matroid.rank()) @@ -240,12 +290,39 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" Return the generators of augmented Chow ring ideal of - Feitchner-Yuzvinsky presentation. + Feitchner-Yuzvinsky presentation. Takes in the ring of + that augmented Chow ring ideal as input. EXAMPLES:: + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy + sage: ch = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) - sage: ch._gens_constructor() #WHERE IS OUTPUT? + sage: ch._gens_constructor(ch.ring()) + [B0^2, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B124, B0*B15, B0*B23, + B0*B345, B0*B1, B1^2, B1*B2, B1*B3, B1*B4, B1*B5, B1*B025, B1*B04, + B1*B23, B1*B345, B0*B2, B1*B2, B2^2, B2*B3, B2*B4, B2*B5, B2*B013, + B2*B04, B2*B15, B2*B345, B0*B3, B1*B3, B2*B3, B3^2, B3*B4, B3*B5, + B3*B025, B3*B04, B3*B124, B3*B15, B0*B4, B1*B4, B2*B4, B3*B4, B4^2, + B4*B5, B4*B013, B4*B025, B4*B15, B4*B23, B0*B5, B1*B5, B2*B5, + B3*B5, B4*B5, B5^2, B5*B013, B5*B04, B5*B124, B5*B23, B2*B013, + B4*B013, B5*B013, B013^2, B013*B025, B013*B04, B013*B124, B013*B15, + B013*B23, B013*B345, B1*B025, B3*B025, B4*B025, B013*B025, B025^2, + B025*B04, B025*B124, B025*B15, B025*B23, B025*B345, B1*B04, B2*B04, + B3*B04, B5*B04, B013*B04, B025*B04, B04^2, B04*B124, B04*B15, + B04*B23, B04*B345, B0*B124, B3*B124, B5*B124, B013*B124, B025*B124, + B04*B124, B124^2, B124*B15, B124*B23, B124*B345, B0*B15, B2*B15, + B3*B15, B4*B15, B013*B15, B025*B15, B04*B15, B124*B15, B15^2, + B15*B23, B15*B345, B0*B23, B1*B23, B4*B23, B5*B23, B013*B23, + B025*B23, B04*B23, B124*B23, B15*B23, B23^2, B23*B345, B0*B345, + B1*B345, B2*B345, B013*B345, B025*B345, B04*B345, B124*B345, + B15*B345, B23*B345, B345^2, + A0 - B1 - B2 - B3 - B4 - B5 - B124 - B15 - B23 - B345, + A1 - B0 - B2 - B3 - B4 - B5 - B025 - B04 - B23 - B345, + A2 - B0 - B1 - B3 - B4 - B5 - B013 - B04 - B15 - B345, + A3 - B0 - B1 - B2 - B4 - B5 - B025 - B04 - B124 - B15, + A4 - B0 - B1 - B2 - B3 - B5 - B013 - B025 - B15 - B23, + A5 - B0 - B1 - B2 - B3 - B4 - B013 - B04 - B124 - B23] """ E = list(self._matroid.groundset()) @@ -272,6 +349,8 @@ def _repr_(self): r""" EXAMPLES:: + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy + sage: ch = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on @@ -384,12 +463,23 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" Return the generators of augmented Chow ring ideal of - atom-free presentation. + atom-free presentation. Takes in the ring of that augmented + Chow ring ideal as input. EXAMPLES:: - sage: ch = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) - sage: ch._gens_constructor() #WHERE IS OUTPUT? + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free + sage: from sage.matroids.graphic_matroid import GraphicMatroid + + sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) + sage: ch = AugmentedChowRingIdeal_atom_free(M=M1, R=QQ) + sage: ch._gens_constructor(ch.ring()) + [A0^2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, A1^2, A0*A1, + A2^2, A0*A2, A0*A2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, + A0*A1, A1^2, A2^2, A1*A2, A1^2, A0^2, A0*A1, A1^2, A2^2, A1*A2, + A1*A2, A0^2, A0*A1, A1^2, A2^2, A1*A2, A0*A2, A0^2, A0*A2, A1^2, + A1*A2, A2^2, A1*A2, A0^2, A0*A2, A1^2, A1*A2, A2^2, A2^2, A0^2, + A0*A2, A1^2, A1*A2, A2^2] """ E = list(self._matroid.groundset()) @@ -420,6 +510,8 @@ def _repr_(self): r""" EXAMPLE:: + sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free + sage: ch = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on From c7fa9eadac2291351feddcec28321d6819f0ddd6 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 7 Aug 2024 11:13:16 +0530 Subject: [PATCH 041/167] Changed ChowRing category --- src/sage/matroids/chow_ring.py | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 25b57b6eb8b..d5dd7e1f17f 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -17,17 +17,17 @@ """ from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug, AugmentedChowRingIdeal_fy, AugmentedChowRingIdeal_atom_free -from sage.rings.quotient_ring import QuotientRing_nc +from sage.rings.quotient_ring import QuotientRing_generic from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis +from sage.categories.commutative_rings import CommutativeRings from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence from sage.sets.set import Set from functools import cmp_to_key from sage.misc.misc_c import prod -class ChowRing(QuotientRing_nc): +class ChowRing(QuotientRing_generic): r""" The class of Chow ring, a multi-polynomial quotient ring. - Base class - ``QuotientRing_nc``. INPUT: @@ -69,7 +69,8 @@ def __init__(self, R, M, augmented, presentation=None): self._ideal = AugmentedChowRingIdeal_atom_free(M, R) else: self._ideal = ChowRingIdeal_nonaug(M, R) #check method to get ring - QuotientRing_nc.__init__(self, R=self._ideal.ring(), I=self._ideal, names=self._ideal.ring().variable_names(), category=GradedAlgebrasWithBasis(R)) + C = CommutativeRings().Quotients() & GradedAlgebrasWithBasis(R).FiniteDimensional() + QuotientRing_generic.__init__(self, R=self._ideal.ring(), I=self._ideal, names=self._ideal.ring().variable_names(), category=C) def _repr_(self): r""" @@ -139,19 +140,12 @@ def basis(self): sage: ch = ChowRing(M=matroids.Wheel(3), R=ZZ, augmented=False) [A0*A013, 1] """ - flats = [Set(X) for i in range(1, self._matroid.rank()) + flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] - flats.append(Set([])) - maximum_rank = max([self._matroid.rank(F) for F in flats]) + flats.append(frozenset()) + maximum_rank = max(self._matroid.rank(F) for F in flats) flats_gen = self._ideal.flats_generator() - def func(A, B): - if A.issubset(B): - return -1 - elif B.issubset(A): - return 1 - else: - return 0 - flats = sorted(flats, key=cmp_to_key(func)) + flats = sorted(flats, key=lambda X: (len(X), sorted(X))) ranks = [self._matroid.rank(F) for F in flats] monomial_basis = [] if self._augmented: @@ -193,11 +187,10 @@ def func(A, B): term *= flats_gen[flats[j]]**(i + 1) monomial_basis.append(term) + from sage.sets.family import Family + return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) - m_basis = PolynomialSequence(self._ideal.ring(), monomial_basis) - return m_basis - - class Element(QuotientRing_nc.Element): + class Element(QuotientRing_generic.Element): def to_vector(self, order=None): r""" Return ``self`` as a (dense) free module vector. From 33aa1c01e93a9ab5b4389b04e3d3daf5a35e008d Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 7 Aug 2024 11:13:42 +0530 Subject: [PATCH 042/167] Edited groebner_basis() method --- src/sage/matroids/chow_ring_ideal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index a9abde90c2b..e7f67f6b6af 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -224,7 +224,7 @@ def groebner_basis(self): for H in flats: if H > G: term += self._flats_generator[H] - if Set(F).is_empty(): + if F.is_empty(): gb.append(term**self._matroid.rank(G)) elif F < G: gb.append(term**(self._matroid.rank(G)-self._matroid.rank(F))) From 8c71e8251e8b5c57df007568f867f010764d4d47 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 10 Aug 2024 15:48:11 +0530 Subject: [PATCH 043/167] Added references --- src/doc/en/reference/references/index.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index db5afe04784..46e3bf33f3a 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -260,6 +260,9 @@ REFERENCES: .. [Ang1997] B. Anglès. 1997. *On some characteristic polynomials attached to finite Drinfeld modules.* manuscripta mathematica 93, 1 (01 Aug 1997), 369–379. https://doi.org/10.1007/BF02677478 + +.. [ANR2023] Robert Angarone, Anastasia Nathanson, and Victor Reiner. *Chow rings of + matroids as permutation representations*, 2023. :arxiv: `2309.14312`. .. [AP1986] \S. Arnborg, A. Proskurowski, *Characterization and Recognition of Partial 3-Trees*, @@ -4860,6 +4863,9 @@ REFERENCES: .. [MM2015] \J. Matherne and \G. Muller, *Computing upper cluster algebras*, Int. Math. Res. Not. IMRN, 2015, 3121-3149. +.. [MM2022] Matthew Mastroeni and Jason McCullough. Chow rings of matroids are + koszul. *Mathematische Annalen*, 387(3–4):1819–1851, November 2022. + .. [MMRS2022] Ruslan G. Marzo, Rafael A. Melo, Celso C. Ribeiro and Marcio C. Santos: *New formulations and branch-and-cut procedures for the longest induced path problem*. Computers & Operations From 6b6d0e1e752a0b35474b4bdcf159d6c7a443573b Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 10 Aug 2024 15:48:35 +0530 Subject: [PATCH 044/167] Wrote mathematical definition of Chow ring --- src/sage/matroids/chow_ring.py | 64 ++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index d5dd7e1f17f..e94be14a2cc 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -9,20 +9,72 @@ a parameter boolean ``augmented`` which creates the augmented Chow ring if given ``True``. +INPUT:: -REFERENCES +- `R` -- commutative ring +- `M` -- matroid +- `augmented` -- If `True`, returns augmented Chow ring of input presentation + and returns non-augmented Chow ring if `False`. +- `presentation` -- Takes in augmented Chow ring presentation as a string if + augmented is `True`. Implemented resentations are `fy` and `atom-free`, + default value is `None` -- :arxiv:`2309.14312` -- :arxiv:`2111.00393` +The Chow ring of a matroid is defined as the quotient ring: + +.. MATH:: + + A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M) + + where + +..MATH:: + + (Q_M + L_M) + + is the Chow ring ideal of matroid `M`. + +The augmented Chow ring of matroid `M` of Feitchner-Yuzvinsky presentation +is the quotient ring: + +..MATH:: + + A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M) + + where + +..MATH:: + + (I_M + J_M) + + is the augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky + presentation. + +The augmented Chow ring ideal of atom-free presentation is the quotient ring: + +..MATH:: + + A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_{af}M + + where + + I_{af}M + + is the augmented Chow ring ideal of matroid `M` of atom-free presentation. + +.. SEEALSO:: + + :mod: sage.matroids.chow_ring_ideal + +REFERENCES: + + - [FY2004]_ + - [AHK2015]_ """ from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug, AugmentedChowRingIdeal_fy, AugmentedChowRingIdeal_atom_free from sage.rings.quotient_ring import QuotientRing_generic from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.categories.commutative_rings import CommutativeRings -from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence -from sage.sets.set import Set -from functools import cmp_to_key from sage.misc.misc_c import prod class ChowRing(QuotientRing_generic): From 01ab04bf26c1ee9dc925b09160960a38658cadbb Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 10 Aug 2024 15:48:56 +0530 Subject: [PATCH 045/167] Wrote mathematical definition of Chow ring ideal --- src/sage/matroids/chow_ring_ideal.py | 99 +++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index e7f67f6b6af..c3a88b780e5 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -12,10 +12,102 @@ ``grobner_basis()`` methods as well, as an explicit Groebner basis is known in each case. +..INPUT:: + + - `R` -- commutative ring + - `M` -- matroid + +The Chow ring ideal is defined over a polynomial ring for a matroid `M`: + +..MATH:: + + R[x_{F_1}, \ldots, x_{F_k}] + + as + +..MATH:: + + (Q_M + L_M) + + where + + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}` where + `F_i` and `F_j` are incomparable elements in the lattice of + flats, and + - `L_M` is the ideal generated by all linear forms + +.. MATH:: + + \sum_{i_1 \in F} x_F - \sum_{i_2 \in F} x_F + + for all `i_1 \neq i_2 \in E`. + +The augmented Chow ring ideal of Feitchner-Yuzvinsky presentation is defined +over the following polynomial ring: + +..MATH:: + + R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] + + as + +..MATH:: + + (I_M + J_M) + + where + + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, + - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + where `F_i` and `F_j` are incomparable elements in the lattice of + flats, and `y_{i} x_F` for every `i \in E` and `i \notin F`, and + - `I_M` is the ideal generated by all linear forms + +..MATH:: + + y_i - \sum_{i \notin F} x_F + + for all `i \in E`. + +The augmented Chow ring ideal for the atom-free presentation is defined +over the polynomial ring: + +..MATH:: + + R[x_{F_1}, \ldots, x_{F_k}] + + as + +..MATH:: + + I_{af}(M) + + where + + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `I_{af }M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + where `F_i` and `F_j` are incomparable elements in the lattice of + flats, + +..MATH:: + + x_F \sum_{i \in F'} x_{F'} + + for all `i \in E` and `i \notin F`, and + +..MATH:: + + \sum_{i \in F'} (x_{F'})^2 + + for all `i \in E`. + + REFERENCES -- :arxiv:`2309.14312` -- :arxiv:`2111.00393` +- [ANR2023]_ +- [MM2022]_ """ from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal @@ -68,7 +160,8 @@ def flats_generator(self): class ChowRingIdeal_nonaug(ChowRingIdeal): r""" The Chow ring ideal. - + Returns the Chow ring ideal over ring `R` of matroid `M`. + INPUT: - `M` -- a matroid From f7377c8051564ee66cfb7ee4f8a4eb1457d6d01f Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 10 Aug 2024 15:49:15 +0530 Subject: [PATCH 046/167] Modified chow_ring() doctest --- src/sage/matroids/matroid.pyx | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 924d2db2878..587fed8a556 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8030,31 +8030,13 @@ cdef class Matroid(SageObject): def chow_ring(self, R, augmented=False, presentation=None): r""" Return the Chow ring of ``self`` over ``R``. + Return the augmented Chow ring of `self` over `R`of `presentation` + if `augmented` is `True`. - Let `M` be a matroid and `R` be a commutative ring. - The *Chow ring* of `M` is the quotient ring - - .. MATH:: - - A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M), - - where - - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}` where - `F_i` and `F_j` are incomparable elements in the lattice of - flats, and - - `L_M` is the ideal generated by all linear forms - - .. MATH:: - - \sum_{i_1 \in F} x_F - \sum_{i_2 \in F} x_F - - for all `i_1 \neq i_2 \in E`. - - INPUT: + .. SEEALSO:: - - ``R`` -- (default: `\ZZ`) the base ring + :mod: sage.matroids.chow_ring_ideal + :mod: sage.matroids.chow_ring EXAMPLES:: @@ -8087,10 +8069,6 @@ cdef class Matroid(SageObject): Augmented Chow ring of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} of atom-free presentation - REFERENCES: - - - [FY2004]_ - - [AHK2015]_ """ from sage.matroids.chow_ring import ChowRing return ChowRing(M=self, R=R, augmented=augmented, presentation=presentation) From e41edf87bf05f9cf48de799c56e87db82f523f90 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 10 Aug 2024 22:10:09 +0530 Subject: [PATCH 047/167] Debugged basis() method --- src/sage/matroids/chow_ring.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index e94be14a2cc..03b289f3781 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -76,6 +76,7 @@ from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.categories.commutative_rings import CommutativeRings from sage.misc.misc_c import prod +from itertools import product class ChowRing(QuotientRing_generic): r""" @@ -228,16 +229,30 @@ def basis(self): monomial_basis.append(term) else: - for i in range(maximum_rank): + print(ranks) + rank_diff = [] + for i in range(len(flats)): + max_pow = 0 + for j in range(i): + if flats[j] < flats[i]: + max_pow += ranks[j] + rank_diff.append(ranks[i] - max_pow) + print(rank_diff) + def generate_terms(current_term, index, max_powers, f_dict): + if index == len(max_powers): term = self._ideal.ring().one() - for j in range(len(flats)): - if i > ranks[j] - ranks[j-1] - 1: - if flats[j] in list(flats_gen): - term *= flats_gen[flats[j]]**(0) - else: - if flats[j] in list(flats_gen): - term *= flats_gen[flats[j]]**(i + 1) - monomial_basis.append(term) + term *= f_dict[i+1]**(current_term[i] for i in range(len(current_term))) + yield term + return + + for power in range(max_powers[index]): + current_term[index] = power + generate_terms(current_term, index + 1, max_powers, f_dict) + + current_term = [0]*len(flats) + monomial_basis = list(generate_terms(current_term, 0, rank_diff, flats_gen)) + print(monomial_basis) + from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) From 367225ae7c68036a4ca34c18a1edb538c849bc6c Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 10 Aug 2024 22:10:35 +0530 Subject: [PATCH 048/167] Wrote doctests for groebner_basis() methods --- src/sage/matroids/chow_ring_ideal.py | 45 +++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index c3a88b780e5..e3f7fab94b7 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -317,10 +317,11 @@ def groebner_basis(self): for H in flats: if H > G: term += self._flats_generator[H] - if F.is_empty(): - gb.append(term**self._matroid.rank(G)) - elif F < G: - gb.append(term**(self._matroid.rank(G)-self._matroid.rank(F))) + if term != R.zero(): + if Set(F).is_empty(): + gb.append(term**self._matroid.rank(G)) + elif F < G: + gb.append(term**(self._matroid.rank(G)-self._matroid.rank(F))) g_basis = PolynomialSequence(R, [gb]) return g_basis @@ -462,36 +463,37 @@ def groebner_basis(self): sage: ch = AugmentedChowRingIdeal_fy(M=matroids.catalog.Fano(), R=QQ) sage: ch.groebner_basis() - Polynomial Sequence with 4116 Polynomials in 21 Variables + Polynomial Sequence with 1400 Polynomials in 10 Variables + sage: ch.groebner_basis().is_groebner() + True """ gb = [] E = list(self._matroid.groundset()) poly_ring = self.ring() - for i in E: - for F in self._flats: - for G in self._flats: + for F in self._flats: + for G in self._flats: + if not (F < G or G < F): + gb.append(self._flats_generator[F]*self._flats_generator[G]) + for i in E: term = poly_ring.zero() term1 = poly_ring.zero() for H in self._flats: - if i in Set(H): + if i in H: term += self._flats_generator[H] if H > F: term1 += self._flats_generator[H] - gb.append(self._flats_generator[i] + term) - gb.append(term1**(self._matroid.rank(Set(F))) + 1) + gb.append(self._flats_generator[i] + term) + gb.append(term1**(self._matroid.rank(F)) + 1) - if i in Set(F): - gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(Set(F)))) + if i in F: + gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(F))) - elif not i in Set(F): + elif not i in F: gb.append(self._flats_generator[i]*self._flats_generator[F]) - elif not (F < G or G < F): - gb.append(self._flats_generator[F]*self._flats_generator[G]) - elif G < F: - gb.append(self._flats_generator[G]*term1**(self._matroid.rank(Set(F))-self._matroid.rank(Set(G)))) + gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis @@ -626,6 +628,8 @@ def groebner_basis(self): sage: ch = AugmentedChowRingIdeal_atom_free(M=M1, R=QQ) sage: ch.groebner_basis() [A0^2, A0*A1, A0*A2, A0*A1, A1^2, A1*A2, A0*A2, A1*A2, A2^2] + sage: ch.groebner_basis().is_groebner() + True """ gb = [] flats = [X for i in range(1, self._matroid.rank()) @@ -642,8 +646,9 @@ def groebner_basis(self): for H in flats: if H < F: term += self._flats_generator[H] - gb.append(self._flats_generator[F]*(term**self._matroid.rank(Set(G)))* - (term**(self._matroid.rank(Set(G))-self._matroid.rank(Set(F))))) + if term != poly_ring.zero(): + gb.append(self._flats_generator[F]*(term**self._matroid.rank(G))* + (term**(self._matroid.rank(G)-self._matroid.rank(F)))) g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis From 9ec9b184598b227bc68e2ed431d057a563700e56 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 13 Aug 2024 10:33:13 +0530 Subject: [PATCH 049/167] Updated references --- src/doc/en/reference/references/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index 46e3bf33f3a..5e8c70a7b7e 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -262,7 +262,7 @@ REFERENCES: 369–379. https://doi.org/10.1007/BF02677478 .. [ANR2023] Robert Angarone, Anastasia Nathanson, and Victor Reiner. *Chow rings of - matroids as permutation representations*, 2023. :arxiv: `2309.14312`. + matroids as permutation representations*, 2023. :arxiv: `2309.14312`. .. [AP1986] \S. Arnborg, A. Proskurowski, *Characterization and Recognition of Partial 3-Trees*, From c63627a043f70af1679cfd4895ef3915685de711 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 13 Aug 2024 10:34:12 +0530 Subject: [PATCH 050/167] Incorporated GitHub comments --- src/sage/matroids/chow_ring.py | 157 +++++++++++++++------------------ 1 file changed, 70 insertions(+), 87 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 03b289f3781..9b42b9a32a6 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -4,100 +4,90 @@ AUTHORS: - Shriya M +""" -These are the classes of Chow rings for matroids. It also takes in -a parameter boolean ``augmented`` which creates the augmented Chow -ring if given ``True``. - -INPUT:: +from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug, AugmentedChowRingIdeal_fy, AugmentedChowRingIdeal_atom_free +from sage.rings.quotient_ring import QuotientRing_generic +from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis +from sage.categories.commutative_rings import CommutativeRings +from sage.misc.misc_c import prod +from itertools import product -- `R` -- commutative ring -- `M` -- matroid -- `augmented` -- If `True`, returns augmented Chow ring of input presentation - and returns non-augmented Chow ring if `False`. -- `presentation` -- Takes in augmented Chow ring presentation as a string if - augmented is `True`. Implemented resentations are `fy` and `atom-free`, - default value is `None` +class ChowRing(QuotientRing_generic): + r""" + The class of Chow ring, a multi-polynomial quotient ring. -The Chow ring of a matroid is defined as the quotient ring: + INPUT: -.. MATH:: - A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M) + - `M` -- a matroid + - `R` -- a commutative ring + - ``augmented`` -- a Boolean value. When ``True``, it returns the augmented + Chow ring. If ``False``, it returns the Chow ring + - ``presentation`` -- a string literal. Takes in the presentation of + augmented Chow ring (`fy` or `atom-free`). Default value `None` - where + OUTPUT: Chow ring of matroid `M` -..MATH:: + These are the classes of Chow rings for matroids. It also takes in + a parameter boolean ``augmented`` which creates the augmented Chow + ring if given ``True``. - (Q_M + L_M) + The Chow ring of a matroid is defined as the quotient ring: - is the Chow ring ideal of matroid `M`. + .. MATH:: -The augmented Chow ring of matroid `M` of Feitchner-Yuzvinsky presentation -is the quotient ring: + A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M) -..MATH:: + where - A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M) + ..MATH:: - where + (Q_M + L_M) -..MATH:: + is the Chow ring ideal of matroid `M`. - (I_M + J_M) + The augmented Chow ring of matroid `M` of Feitchner-Yuzvinsky presentation + is the quotient ring: - is the augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky - presentation. + ..MATH:: -The augmented Chow ring ideal of atom-free presentation is the quotient ring: + A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M) -..MATH:: + where - A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_{af}M + ..MATH:: - where + (I_M + J_M) - I_{af}M - - is the augmented Chow ring ideal of matroid `M` of atom-free presentation. + is the augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky + presentation. -.. SEEALSO:: + The augmented Chow ring of atom-free presentation is the quotient ring: - :mod: sage.matroids.chow_ring_ideal + ..MATH:: -REFERENCES: + A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_{af}M - - [FY2004]_ - - [AHK2015]_ -""" + where -from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug, AugmentedChowRingIdeal_fy, AugmentedChowRingIdeal_atom_free -from sage.rings.quotient_ring import QuotientRing_generic -from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis -from sage.categories.commutative_rings import CommutativeRings -from sage.misc.misc_c import prod -from itertools import product + I_{af}M + + is the augmented Chow ring ideal of matroid `M` of atom-free presentation. -class ChowRing(QuotientRing_generic): - r""" - The class of Chow ring, a multi-polynomial quotient ring. + .. SEEALSO:: - INPUT: + :mod: sage.matroids.chow_ring_ideal + REFERENCES: - - `M` -- a matroid. - - `R` -- a ring. - - ``augmented`` -- a Boolean value. When ``True``, it returns the augmented Chow - ring. If ``False``, it returns the Chow ring - - OUTPUT: Chow ring of matroid `M`. + - [FY2004]_ + - [AHK2015]_ EXAMPLES:: - sage: from sage.matroids.chow_ring import ChowRing - sage: M1 = matroids.catalog.P8pp() - sage: ch = ChowRing(M=M1, R=QQ, augmented=False) + sage: ch = M1.chow_ring(QQ, False) sage: ch Chow ring of P8'': Matroid of rank 4 on 8 elements with 8 nonspanning circuits """ @@ -107,18 +97,16 @@ def __init__(self, R, M, augmented, presentation=None): EXAMPLES:: - sage: from sage.matroids.chow_ring import ChowRing - - sage: I = ChowRing(M=matroids.Wheel(3), R=QQ, augmented=False) + sage: I = matroids.Wheel(3).chow_ring(QQ, False) sage: TestSuite(I).run() """ self._matroid = M self._augmented = augmented self._presentation = presentation - if augmented: - if presentation=='fy': + if augmented is True: + if presentation == 'fy': self._ideal = AugmentedChowRingIdeal_fy(M, R) - elif presentation=='atom-free': + elif presentation == 'atom-free': self._ideal = AugmentedChowRingIdeal_atom_free(M, R) else: self._ideal = ChowRingIdeal_nonaug(M, R) #check method to get ring @@ -127,19 +115,17 @@ def __init__(self, R, M, augmented, presentation=None): def _repr_(self): r""" - EXAMPLE:: - - sage: from sage.matroids.chow_ring import ChowRing + EXAMPLES:: sage: M1 = matroids.catalog.Fano() - sage: ch = ChowRing(M=M1, R=QQ, augmented=False) + sage: ch = M1.chow_ring(QQ, False) sage: ch Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ - if self._augmented: - if self._presentation=='fy': + if self._augmented is True: + if self._presentation == 'fy': return "Augmented Chow ring of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) - elif self._presentation=='atom-free': + elif self._presentation == 'atom-free': return "Augmented Chow ring of {} of atom-free presentation".format(self._matroid) return "Chow ring of {}".format(self._matroid) @@ -147,13 +133,12 @@ def _latex_(self): r""" Return the LaTeX output of the polynomial ring and Chow ring ideal. - EXAMPLE:: + EXAMPLES:: - sage: from sage.matroids.chow_ring import ChowRing sage: from sage.matroids.graphic_matroid import GraphicMatroid sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) - sage: ch = ChowRing(M=M1, R=QQ, augmented=True, presentation='fy') + sage: ch = M1.chow_ring(QQ, True, 'fy') sage: ch._latex_() \Bold{Q}[A_{0}, A_{1}, A_{2}, B_{0}, B_{1}, B_{2}]/\left(B_{0}^{2}, B_{0} B_{1}, B_{0} B_{2}, B_{0} B_{1}, B_{1}^{2}, B_{1} B_{2}, @@ -171,9 +156,8 @@ def _coerce_map_from_base_ring(self): TESTS:: - sage: from sage.matroids.chow_ring import ChowRing - sage: ch = ChowRing(M=matroids.Wheel(3), R=QQ, augmented=False) + sage: ch = matroids.Wheel(3).chow_ring(QQ, False) sage: ch._coerce_map_from_base_ring() is None True """ @@ -185,12 +169,11 @@ def basis(self): EXAMPLES:: - sage: from sage.matroids.chow_ring import ChowRing - sage: ch = ChowRing(M=matroids.Uniform(3, 6), R=QQ, augmented=True, presentation='fy') + sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, True, 'fy') sage: ch.basis() [B0*B01, 1] - sage: ch = ChowRing(M=matroids.Wheel(3), R=ZZ, augmented=False) + sage: ch = matroids.Wheel(3).chow_ring(ZZ, False) [A0*A013, 1] """ flats = [X for i in range(1, self._matroid.rank()) @@ -201,7 +184,7 @@ def basis(self): flats = sorted(flats, key=lambda X: (len(X), sorted(X))) ranks = [self._matroid.rank(F) for F in flats] monomial_basis = [] - if self._augmented: + if self._augmented is True: if self._presentation == 'fy': for i in range(maximum_rank): term = self._ideal.ring().one() @@ -264,7 +247,7 @@ def to_vector(self, order=None): EXAMPLES:: - sage: ch = ChowRing(M=matroids.Uniform(3, 6), R=QQ, augmented=False) + sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, False) sage: v = ch.an_element(); v A0 sage: v.to_vector() #Error in output! @@ -284,7 +267,7 @@ def monomial_coefficients(self, copy=None): EXAMPLES:: - sage: ch = ChowRing(M=matroids.catalog.NonFano(), R=QQ, augmented=True, presentation='fy') + sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'fy') sage: v = ch.an_element(); v 0 sage: v.monomial_coefficients() #error in output! @@ -300,7 +283,7 @@ def degree(self): EXAMPLES:: - sage: ch = ChowRing(M=matroids.Uniform(3, 6), R=QQ, augmented=False) + sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, False) sage: for b in ch.basis(): ....: print(b, b.degree()) A0*A01 2 @@ -318,7 +301,7 @@ def homogeneous_degree(self): EXAMPLES:: - ch = ChowRing(M=matroids.catalog.Fano(), R=QQ, augmented=True, presentation='fy') + ch = matroids.catalog.Fano().chow_ring(QQ, True, 'fy') sage: for b in ch.basis(): ....: print(b, b.homogeneous_degree()) Ba*Babf 2 @@ -332,7 +315,7 @@ def homogeneous_degree(self): TESTS:: - sage: ch = ChowRing(M=matroids.Wheel(3), R=QQ, augmented=False) + sage: ch = matroids.Wheel(3).chow_ring(QQ, False) sage: ch.zero().homogeneous_degree() #error! Traceback (most recent call last): ... From 434c8603a73e288427b8118b2f149e5d62ae7864 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 13 Aug 2024 10:34:34 +0530 Subject: [PATCH 051/167] Incorporated GitHub comments for ideal file --- src/sage/matroids/chow_ring_ideal.py | 304 ++++++++++++--------------- 1 file changed, 137 insertions(+), 167 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index e3f7fab94b7..173efaba912 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -4,110 +4,6 @@ AUTHORS: - Shriya M - -These are the classes of Chow ring ideals for matroids. There are three classes -created - Chow ring ideal and augmented Chow ring ideal. The augmented -Chow ring ideal has two different presentations implemented - the Feitchner- -Yuzvinsky presentation and atom-free presentation. Both classes have -``grobner_basis()`` methods as well, as an explicit Groebner basis is known -in each case. - -..INPUT:: - - - `R` -- commutative ring - - `M` -- matroid - -The Chow ring ideal is defined over a polynomial ring for a matroid `M`: - -..MATH:: - - R[x_{F_1}, \ldots, x_{F_k}] - - as - -..MATH:: - - (Q_M + L_M) - - where - - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}` where - `F_i` and `F_j` are incomparable elements in the lattice of - flats, and - - `L_M` is the ideal generated by all linear forms - -.. MATH:: - - \sum_{i_1 \in F} x_F - \sum_{i_2 \in F} x_F - - for all `i_1 \neq i_2 \in E`. - -The augmented Chow ring ideal of Feitchner-Yuzvinsky presentation is defined -over the following polynomial ring: - -..MATH:: - - R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] - - as - -..MATH:: - - (I_M + J_M) - - where - - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of - flats, and `y_{i} x_F` for every `i \in E` and `i \notin F`, and - - `I_M` is the ideal generated by all linear forms - -..MATH:: - - y_i - \sum_{i \notin F} x_F - - for all `i \in E`. - -The augmented Chow ring ideal for the atom-free presentation is defined -over the polynomial ring: - -..MATH:: - - R[x_{F_1}, \ldots, x_{F_k}] - - as - -..MATH:: - - I_{af}(M) - - where - - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - - `I_{af }M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of - flats, - -..MATH:: - - x_F \sum_{i \in F'} x_{F'} - - for all `i \in E` and `i \notin F`, and - -..MATH:: - - \sum_{i \in F'} (x_{F'})^2 - - for all `i \in E`. - - -REFERENCES - -- [ANR2023]_ -- [MM2022]_ """ from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal @@ -119,16 +15,13 @@ class ChowRingIdeal(MPolynomialIdeal): @abstract_method - def _gens_constructor(): - pass - def matroid(self): r""" Return the matroid of the given Chow ring ideal. - EXAMPLE:: + EXAMPLES:: - sage: ch = ChowRingIdeal_nonaug(M=matroids.Uniform(3,6), R=QQ) + sage: ch = matroids.Uniform(3,6).chow_ring(QQ, False) sage: ch.matroid() U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} @@ -141,11 +34,9 @@ def flats_generator(self): Return the variables of every corresponding flat/groundset element of the matroid. - EXAMPLE:: - - sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug + EXAMPLES:: - sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) + sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch.flats_generator() {frozenset({'a'}): Aa, frozenset({'b'}): Ab, frozenset({'c'}): Ac, frozenset({'d'}): Ad, frozenset({'e'}): Ae, frozenset({'f'}): Af, @@ -165,21 +56,57 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): INPUT: - `M` -- a matroid - - `R` -- a ring + - `R` -- a commutative ring OUTPUT: Chow ring ideal of matroid `M` + These are the classes of Chow ring ideals for matroids. There are three classes + created - Chow ring ideal and augmented Chow ring ideal. The augmented + Chow ring ideal has two different presentations implemented - the Feitchner- + Yuzvinsky presentation and atom-free presentation. Both classes have + ``grobner_basis()`` methods as well, as an explicit Groebner basis is known + in each case. + + The Chow ring ideal is defined over a polynomial ring for a matroid `M`: + + ..MATH:: + + R[x_{F_1}, \ldots, x_{F_k}] + + as + + ..MATH:: + + (Q_M + L_M) + + where + + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}` where + `F_i` and `F_j` are incomparable elements in the lattice of + flats, and + - `L_M` is the ideal generated by all linear forms + + .. MATH:: + + \sum_{i_1 \in F} x_F - \sum_{i_2 \in F} x_F + + for all `i_1 \neq i_2 \in E`. + + REFERENCES + + - [ANR2023]_ + - [MM2022]_ + EXAMPLES: Chow ring ideal of uniform matroid of rank 3 on 6 elements:: - sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug - - sage: ch = ChowRingIdeal_nonaug(M=matroids.Uniform(3,6), R=QQ) + sage: ch = matroids.Uniform(3,6).chow_ring(QQ, False) sage: ch Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} - sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) + sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ @@ -189,9 +116,7 @@ def __init__(self, M, R): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug - - sage: I = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) + sage: I = matroids.catalog.Fano().chow_ring(QQ, False) sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M @@ -211,11 +136,9 @@ def _gens_constructor(self, poly_ring): Returns the generators of the Chow ring ideal. Takes in the ring of Chow ring ideal as input. - EXAMPLE:: - - sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug + EXAMPLES:: - sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.NonFano(), R=QQ) + sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) sage: ch._gens_constructor(ch.ring()) [Aa*Ab, Aa*Ac, Aa*Ad, Aa*Ae, Aa*Af, Aa*Ag, Aa*Abcd, Aa*Abeg, Aa*Acfg, Aa*Ade, Aa*Adf, Aa*Aef, Ab*Ac, Ab*Ad, Ab*Ae, Ab*Af, Ab*Ag, @@ -252,8 +175,6 @@ def _gens_constructor(self, poly_ring): -Aa + Ad - Aabf - Aace + Abcd + Ade + Adf, Ad - Af - Aabf + Aadg + Abcd - Acfg + Ade - Aef, Aa - Af + Aace + Aadg - Acfg - Adf - Aef] - - """ E = list(self._matroid.groundset()) flats = list(self._flats_generator.keys()) @@ -271,11 +192,9 @@ def _gens_constructor(self, poly_ring): def _repr_(self): r""" - EXAMPLE:: - - sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug + EXAMPLES:: - sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.Fano(), R=QQ) + sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ @@ -288,10 +207,9 @@ def groebner_basis(self): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug sage: from sage.matroids.basis_matroid import BasisMatroid - sage: ch = ChowRingIdeal_nonaug(M=BasisMatroid(groundset='abc', bases=['ab', 'ac']), R=QQ) + sage: ch = M=BasisMatroid(groundset='abc', bases=['ab', 'ac'])).chow_ring(QQ, False) sage: ch.groebner_basis() [Aa^2, Aa*Abc, Aa*Abc, Abc^2] sage: ch.groebner_basis().is_groebner() @@ -300,9 +218,11 @@ def groebner_basis(self): Another example would be the Groebner basis of the Chow ring ideal of the Non-Fano matroid:: - sage: ch = ChowRingIdeal_nonaug(M=matroids.catalog.NonFano(), R=QQ) + sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) sage: ch.groebner_basis() Polynomial Sequence with 232 Polynomials in 16 Variables + sage: ch.groebner_basis().is_groebner() + True """ flats = list(self._flats_generator) @@ -335,22 +255,52 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): INPUT: - - `M` -- a matroid. - - `R` -- a ring. + - `M` -- a matroid + - `R` -- a commutative ring OUTPUT: augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky presentation. + The augmented Chow ring ideal of Feitchner-Yuzvinsky presentation is defined + over the following polynomial ring: + + ..MATH:: + + R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] + + as + + ..MATH:: + + (I_M + J_M) + + where + + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, + - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + where `F_i` and `F_j` are incomparable elements in the lattice of + flats, and `y_{i} x_F` for every `i \in E` and `i \notin F`, and + - `I_M` is the ideal generated by all linear forms + + ..MATH:: + + y_i - \sum_{i \notin F} x_F + + for all `i \in E`. + EXAMPLES:: Augmented Chow ring ideal of Wheel matroid of rank 3:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy - - sage: ch = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + + REFERENCES + + - [MM2022]_ """ def __init__(self, M, R): r""" @@ -358,9 +308,7 @@ def __init__(self, M, R): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy - - sage: I = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: I = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M @@ -389,9 +337,7 @@ def _gens_constructor(self, poly_ring): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy - - sage: ch = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch._gens_constructor(ch.ring()) [B0^2, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B124, B0*B15, B0*B23, B0*B345, B0*B1, B1^2, B1*B2, B1*B3, B1*B4, B1*B5, B1*B025, B1*B04, @@ -443,9 +389,7 @@ def _repr_(self): r""" EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy - - sage: ch = AugmentedChowRingIdeal_fy(M=matroids.Wheel(3), R=QQ) + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation @@ -459,9 +403,7 @@ def groebner_basis(self): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_fy - - sage: ch = AugmentedChowRingIdeal_fy(M=matroids.catalog.Fano(), R=QQ) + sage: ch = matroids.catalog.Fano().chow_ring(QQ, True, 'fy') sage: ch.groebner_basis() Polynomial Sequence with 1400 Polynomials in 10 Variables sage: ch.groebner_basis().is_groebner() @@ -506,21 +448,55 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): INPUT: - ``M`` -- a matroid - - ``R`` -- a ring + - ``R`` -- a commutative ring OUTPUT: augmented Chow ring ideal of matroid `M` of atom-free presentation. + The augmented Chow ring ideal for the atom-free presentation is defined + over the polynomial ring: + + ..MATH:: + + R[x_{F_1}, \ldots, x_{F_k}] + + as + + ..MATH:: + + I_{af}(M) + + where + + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `I_{af }M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + where `F_i` and `F_j` are incomparable elements in the lattice of + flats, + + ..MATH:: + + x_F \sum_{i \in F'} x_{F'} + + for all `i \in E` and `i \notin F`, and + + ..MATH:: + + \sum_{i \in F'} (x_{F'})^2 + + for all `i \in E`. + EXAMPLES: Augmented Chow ring ideal of Wheel matroid of rank 3:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free - - sage: ch = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation + + REFERENCES + + - [MM2022]_ """ def __init__(self, M, R): r""" @@ -528,9 +504,7 @@ def __init__(self, M, R): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free - - sage: I = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: I = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M @@ -563,11 +537,10 @@ def _gens_constructor(self, poly_ring): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free sage: from sage.matroids.graphic_matroid import GraphicMatroid sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) - sage: ch = AugmentedChowRingIdeal_atom_free(M=M1, R=QQ) + sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch._gens_constructor(ch.ring()) [A0^2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, @@ -605,9 +578,7 @@ def _repr_(self): r""" EXAMPLE:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free - - sage: ch = AugmentedChowRingIdeal_atom_free(M=matroids.Wheel(3), R=QQ) + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation @@ -621,11 +592,10 @@ def groebner_basis(self): EXAMPLES:: - sage: from sage.matroids.chow_ring_ideal import AugmentedChowRingIdeal_atom_free sage: from sage.matroids.graphic_matroid import GraphicMatroid sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) - sage: ch = AugmentedChowRingIdeal_atom_free(M=M1, R=QQ) + sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.groebner_basis() [A0^2, A0*A1, A0*A2, A0*A1, A1^2, A1*A2, A0*A2, A1*A2, A2^2] sage: ch.groebner_basis().is_groebner() @@ -635,8 +605,8 @@ def groebner_basis(self): flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] poly_ring = self.ring() - if Set([]) in flats: - flats.remove(Set([])) + if frozenset() in flats: + flats.remove(frozenset()) for F in flats: for G in flats: if not (F > G or G > F): From 16ffe62ba06982a05acbd50999c461ca56aba781 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 19 Aug 2024 15:18:33 +0530 Subject: [PATCH 052/167] Modified basis() method --- src/sage/matroids/chow_ring.py | 68 +++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 9b42b9a32a6..04b51341b51 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -12,6 +12,8 @@ from sage.categories.commutative_rings import CommutativeRings from sage.misc.misc_c import prod from itertools import product +from sage.combinat.posets.posets import Poset +from sage.combinat.subset import Subsets class ChowRing(QuotientRing_generic): r""" @@ -212,31 +214,55 @@ def basis(self): monomial_basis.append(term) else: - print(ranks) - rank_diff = [] - for i in range(len(flats)): - max_pow = 0 - for j in range(i): - if flats[j] < flats[i]: - max_pow += ranks[j] - rank_diff.append(ranks[i] - max_pow) - print(rank_diff) - def generate_terms(current_term, index, max_powers, f_dict): + def generate_combinations(current_combination, index, max_powers, x_dict): + # Base case: If index equals the length of max_powers, print the current combination if index == len(max_powers): - term = self._ideal.ring().one() - term *= f_dict[i+1]**(current_term[i] for i in range(len(current_term))) - yield term + expression_terms = [x_dict[i+1] if current_combination[i] == 1 + else x_dict[i+1]**{current_combination[i]} + for i in range(len(current_combination)) if current_combination[i] != 0] + if expression_terms: + term = R.one() + for t in expression_terms: + term *= t + monomial_basis.append(term) + else: + monomial_basis.append(R.one()) return - + + # Recursive case: Iterate over the range for the current index for power in range(max_powers[index]): - current_term[index] = power - generate_terms(current_term, index + 1, max_powers, f_dict) - - current_term = [0]*len(flats) - monomial_basis = list(generate_terms(current_term, 0, rank_diff, flats_gen)) - print(monomial_basis) + current_combination[index] = power + generate_combinations(current_combination, index + 1, max_powers, x_dict) + + def m_n(i): + if flats[i] == frozenset(): + return 0 + else: + sum1 = 0 + for j in range(len(flats)): + if flats[j] < flats[i]: + sum1 += m_n(j) + + return ranks[i] - sum1 - + print(ranks) + flats = list(self._ideal.flats_generator()) + R = self._ideal.ring() + if frozenset() in flats: + flats.remove(frozenset()) + reln = lambda p,q : p < q + P = Poset((flats, reln)) + chains = P.chains() + for chain in chains: + max_powers = [] + x_dict = dict() + for F in chain: + max_powers.append(m_n(flats.index(F))) + x_dict[F] = flats_gen[F] + k = len(chain) + print(max_powers, x_dict, k) + current_combination = [0] * k + generate_combinations(current_combination, 0, max_powers, x_dict) from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) From 4fc0ac0a68d8cf24544a3f9a51e4c4378003c8cd Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 19 Aug 2024 15:19:03 +0530 Subject: [PATCH 053/167] Modified ChowRingIdeal_nonaug.groebner_basis() --- src/sage/matroids/chow_ring_ideal.py | 50 +++++++++++++++++++--------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 173efaba912..c1bedad5961 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -12,6 +12,8 @@ from sage.sets.set import Set from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence from sage.misc.abstract_method import abstract_method +from sage.combinat.posets.posets import Poset +from sage.combinat.subset import Subsets class ChowRingIdeal(MPolynomialIdeal): @abstract_method @@ -227,24 +229,42 @@ def groebner_basis(self): flats = list(self._flats_generator) gb = list() - R = self.ring() - for F in flats: - for G in flats: - if not (F < G or G < F): - gb.append(self._flats_generator[F]*self._flats_generator[G]) - else: - term = R.zero() - for H in flats: - if H > G: - term += self._flats_generator[H] - if term != R.zero(): - if Set(F).is_empty(): - gb.append(term**self._matroid.rank(G)) - elif F < G: - gb.append(term**(self._matroid.rank(G)-self._matroid.rank(F))) + R = self.ring() + if frozenset() in flats: + flats.remove(frozenset()) + def m_n(i): + if flats[i] == frozenset(): + return 0 + else: + return ranks[i] - sum(m_n(j) for j in range(i)) + + reln = lambda p,q : p < q + P = LatticePoset(flats) + subsets = Subsets(flats) + for subset in subsets: + if not P.subposet(subset).is_chain(): + term = R.one() + for x in subset: + term *= self._flats_generator[x] + gb.append(term) + + else: + for F in flats: + if F > P.join(list(subset)): #Getting missing argument error here + term = R.one() + for x in subset: + term *= self._flats_generator[x] + term1 = R.zero() + for G in flats: + if G >= F: + term1 += self._flats_generator[G] + if term1 != R.zero(): + gb.append(term*(term1**m_n(flats.index(subset)))) + g_basis = PolynomialSequence(R, [gb]) return g_basis + class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" From 63a5e8dd76a66c73ff3cf82a0cc191be3cbf8072 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 19 Aug 2024 15:42:56 +0530 Subject: [PATCH 054/167] Edited ChowRingIdeal_nonaug.groebner_basis() method --- src/sage/matroids/chow_ring_ideal.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index c1bedad5961..92468e97492 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -12,7 +12,7 @@ from sage.sets.set import Set from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence from sage.misc.abstract_method import abstract_method -from sage.combinat.posets.posets import Poset +from sage.combinat.posets.lattices import LatticePoset from sage.combinat.subset import Subsets class ChowRingIdeal(MPolynomialIdeal): @@ -233,13 +233,19 @@ def groebner_basis(self): if frozenset() in flats: flats.remove(frozenset()) + ranks = [self._matroid.rank(F) for F in flats] + def m_n(i): if flats[i] == frozenset(): return 0 else: - return ranks[i] - sum(m_n(j) for j in range(i)) + sum1 = 0 + for j in range(len(flats)): + if flats[j] < flats[i]: + sum1 += m_n(j) + + return ranks[i] - sum1 - reln = lambda p,q : p < q P = LatticePoset(flats) subsets = Subsets(flats) for subset in subsets: From 3763e592c4db96a874807716fa0d44266d0cfd7a Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 27 Aug 2024 14:39:17 +0530 Subject: [PATCH 055/167] Edited groebner_basis() lattice --- src/sage/matroids/chow_ring_ideal.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 92468e97492..15c31a8c268 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -230,8 +230,8 @@ def groebner_basis(self): flats = list(self._flats_generator) gb = list() R = self.ring() - if frozenset() in flats: - flats.remove(frozenset()) + if frozenset() not in flats: + flats.append(frozenset()) ranks = [self._matroid.rank(F) for F in flats] @@ -257,7 +257,7 @@ def m_n(i): else: for F in flats: - if F > P.join(list(subset)): #Getting missing argument error here + if F > P.join(list(subset)): term = R.one() for x in subset: term *= self._flats_generator[x] @@ -440,7 +440,7 @@ def groebner_basis(self): poly_ring = self.ring() for F in self._flats: for G in self._flats: - if not (F < G or G < F): + if not (F < G or G < F): #5.2 gb.append(self._flats_generator[F]*self._flats_generator[G]) for i in E: term = poly_ring.zero() @@ -448,19 +448,21 @@ def groebner_basis(self): for H in self._flats: if i in H: term += self._flats_generator[H] - if H > F: + if H > G: term1 += self._flats_generator[H] + if term != poly_ring.zero(): + gb.append(self._flats_generator[i] + term) #5.7 + if term1 != poly_ring.zero(): + gb.append(term1**(self._matroid.rank(G)) + 1) #5.6 - gb.append(self._flats_generator[i] + term) - gb.append(term1**(self._matroid.rank(F)) + 1) - - if i in F: - gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(F))) + if i in G: #5.5 + if term1 != poly_ring.zero(): + gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(G))) - elif not i in F: + elif not i in G: #5.3 gb.append(self._flats_generator[i]*self._flats_generator[F]) - elif G < F: + elif G < F: #5.4 gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) g_basis = PolynomialSequence(poly_ring, [gb]) From 73acafea0f256d4d7bad5de57710f2e6e3a703d9 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 27 Aug 2024 14:39:38 +0530 Subject: [PATCH 056/167] Edited basis() method --- src/sage/matroids/chow_ring.py | 80 ++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 04b51341b51..1fc5e41b740 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -180,9 +180,9 @@ def basis(self): """ flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] - flats.append(frozenset()) maximum_rank = max(self._matroid.rank(F) for F in flats) flats_gen = self._ideal.flats_generator() + R = self._ideal.ring() flats = sorted(flats, key=lambda X: (len(X), sorted(X))) ranks = [self._matroid.rank(F) for F in flats] monomial_basis = [] @@ -203,15 +203,44 @@ def basis(self): elif self._presentation == 'atom-free': #all double equals need spacing first_rank = self._matroid.rank(flats[len(flats) - 1]) - print(first_rank) - for i in range(maximum_rank): - pow = [] - for j in range(1, len(flats) - 1): - if i < ranks[j] - ranks[j-1]: - pow.append((j , i)) - if sum(p[1] for p in pow) == first_rank + 1: - term = prod(flats_gen[flats[p[0]]] ** p[1] for p in pow) - monomial_basis.append(term) + reln = lambda p,q : p < q + P = Poset((flats, reln)) + chains = P.chains() + def generate_combinations(current_combination, index, max_powers, x_dict): + # Base case: If index equals the length of max_powers, print the current combination + if index == len(max_powers): + expression_terms = [x_dict[i+1] if current_combination[i] == 1 + else x_dict[i+1]**{current_combination[i]} + for i in range(len(current_combination)) if current_combination[i] != 0] + if expression_terms: + term = R.one() + for t in expression_terms: + term *= t + monomial_basis.append(term) + else: + monomial_basis.append(R.one()) + return + + # Recursive case: Iterate over the range for the current index + for power in range(max_powers[index]): + current_combination[index] = power + generate_combinations(current_combination, index + 1, max_powers, x_dict) + + for chain in chains: + x_dict = dict() + for i, F in enumerate(chain): + if F == frozenset(): + x_dict[i] = R.one() + else: + x_dict[i] = flats_gen[F] + ranks = [self._matroid.rank(F) for F in chain] + max_powers = [ranks[i-1] - ranks[i] for i in range(1, len(chain))] + k = len(chain) + current_combination = [0] * k + print(max_powers, k, x_dict, chain) + if sum(max_powers) == (first_rank + 1) and max_powers[len(chain) - 1] <= self._matroid.rank(chain[len(chain) - 1]): + generate_combinations(current_combination, 0, max_powers, x_dict) + else: def generate_combinations(current_combination, index, max_powers, x_dict): @@ -233,36 +262,29 @@ def generate_combinations(current_combination, index, max_powers, x_dict): for power in range(max_powers[index]): current_combination[index] = power generate_combinations(current_combination, index + 1, max_powers, x_dict) - - def m_n(i): - if flats[i] == frozenset(): - return 0 - else: - sum1 = 0 - for j in range(len(flats)): - if flats[j] < flats[i]: - sum1 += m_n(j) - - return ranks[i] - sum1 print(ranks) - flats = list(self._ideal.flats_generator()) R = self._ideal.ring() - if frozenset() in flats: - flats.remove(frozenset()) - reln = lambda p,q : p < q - P = Poset((flats, reln)) - chains = P.chains() + lattice_flats = self._matroid.lattice_of_flats() + chains = lattice_flats.chains() for chain in chains: + print(chain) + print(flats) max_powers = [] x_dict = dict() for F in chain: - max_powers.append(m_n(flats.index(F))) - x_dict[F] = flats_gen[F] + if F == frozenset(): + max_powers.append(0) + x_dict[F] = 1 + else: + max_powers.append(ranks[flats.index(F)] - ranks[flats.index(F) - 1]) + x_dict[F] = flats_gen[F] k = len(chain) print(max_powers, x_dict, k) current_combination = [0] * k generate_combinations(current_combination, 0, max_powers, x_dict) + + print(monomial_basis) from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) From b32359c1bebe28ca4c06156751ce4e9b25dcf26e Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Fri, 6 Sep 2024 12:35:48 +0530 Subject: [PATCH 057/167] Edited basis() method --- src/sage/matroids/chow_ring.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 1fc5e41b740..22b814dd6e4 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -10,8 +10,7 @@ from sage.rings.quotient_ring import QuotientRing_generic from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.categories.commutative_rings import CommutativeRings -from sage.misc.misc_c import prod -from itertools import product +from sage.sets.set import Set from sage.combinat.posets.posets import Poset from sage.combinat.subset import Subsets @@ -180,11 +179,12 @@ def basis(self): """ flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] + flats.append(frozenset()) maximum_rank = max(self._matroid.rank(F) for F in flats) flats_gen = self._ideal.flats_generator() R = self._ideal.ring() flats = sorted(flats, key=lambda X: (len(X), sorted(X))) - ranks = [self._matroid.rank(F) for F in flats] + ranks = {F:self._matroid.rank(F) for F in flats} monomial_basis = [] if self._augmented is True: if self._presentation == 'fy': @@ -263,24 +263,32 @@ def generate_combinations(current_combination, index, max_powers, x_dict): current_combination[index] = power generate_combinations(current_combination, index + 1, max_powers, x_dict) - print(ranks) R = self._ideal.ring() lattice_flats = self._matroid.lattice_of_flats() chains = lattice_flats.chains() for chain in chains: print(chain) - print(flats) + for chain in chains: + print(chain) + print(subset) + flag = False + for i in range(len(subset)): + if len(subset) != 1: + if (i != 0) & ((len(subset[i]) == len(subset[i-1]))): + flag = True + break + if flag is True: + break max_powers = [] x_dict = dict() - for F in chain: - if F == frozenset(): + for i in range(len(subset)): + if subset[i] == frozenset(): max_powers.append(0) - x_dict[F] = 1 + x_dict[subset[i]] = 1 else: - max_powers.append(ranks[flats.index(F)] - ranks[flats.index(F) - 1]) - x_dict[F] = flats_gen[F] - k = len(chain) - print(max_powers, x_dict, k) + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + x_dict[subset[i]] = flats_gen[subset[i]] + k = len(subset) current_combination = [0] * k generate_combinations(current_combination, 0, max_powers, x_dict) From 1cede4bc18b3e76a1750c0c462fe0918823f74c0 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 10 Sep 2024 09:55:51 +0530 Subject: [PATCH 058/167] Edited basis() method- added product func --- src/sage/matroids/chow_ring.py | 60 ++++++++++------------------------ 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 22b814dd6e4..cd12ec00912 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -13,6 +13,7 @@ from sage.sets.set import Set from sage.combinat.posets.posets import Poset from sage.combinat.subset import Subsets +from itertools import product class ChowRing(QuotientRing_generic): r""" @@ -177,7 +178,7 @@ def basis(self): sage: ch = matroids.Wheel(3).chow_ring(ZZ, False) [A0*A013, 1] """ - flats = [X for i in range(1, self._matroid.rank()) + flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] flats.append(frozenset()) maximum_rank = max(self._matroid.rank(F) for F in flats) @@ -242,57 +243,30 @@ def generate_combinations(current_combination, index, max_powers, x_dict): generate_combinations(current_combination, 0, max_powers, x_dict) - else: - def generate_combinations(current_combination, index, max_powers, x_dict): - # Base case: If index equals the length of max_powers, print the current combination - if index == len(max_powers): - expression_terms = [x_dict[i+1] if current_combination[i] == 1 - else x_dict[i+1]**{current_combination[i]} - for i in range(len(current_combination)) if current_combination[i] != 0] - if expression_terms: - term = R.one() - for t in expression_terms: - term *= t - monomial_basis.append(term) - else: - monomial_basis.append(R.one()) - return - - # Recursive case: Iterate over the range for the current index - for power in range(max_powers[index]): - current_combination[index] = power - generate_combinations(current_combination, index + 1, max_powers, x_dict) - + else: R = self._ideal.ring() lattice_flats = self._matroid.lattice_of_flats() chains = lattice_flats.chains() for chain in chains: - print(chain) - for chain in chains: - print(chain) - print(subset) - flag = False - for i in range(len(subset)): - if len(subset) != 1: - if (i != 0) & ((len(subset[i]) == len(subset[i-1]))): - flag = True - break - if flag is True: - break max_powers = [] x_dict = dict() - for i in range(len(subset)): - if subset[i] == frozenset(): + for i in range(len(chain)): + if chain[i] == frozenset(): max_powers.append(0) - x_dict[subset[i]] = 1 + x_dict[chain[i]] = 1 + elif i == 0: + max_powers.append(ranks[chain[i]]) + x_dict[chain[i]] = flats_gen[chain[i]] else: - max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - x_dict[subset[i]] = flats_gen[subset[i]] - k = len(subset) - current_combination = [0] * k - generate_combinations(current_combination, 0, max_powers, x_dict) + max_powers.append(ranks[chain[i]] - ranks[chain[i-1]]) + x_dict[chain[i]] = flats_gen[chain[i]] + k = len(chain) + for combination in product(*(range(p) for p in max_powers)): + expression = R.one() + for i in range(k): + expression *= x_dict[chain[i]]**combination[i] + monomial_basis.append(expression) - print(monomial_basis) from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) From dc8e3809a6b3fbe86d73e6cd872af1a5ef1761ba Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 10 Sep 2024 09:56:11 +0530 Subject: [PATCH 059/167] Debugged groebner_basis() method --- src/sage/matroids/chow_ring_ideal.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 15c31a8c268..b73a9e63592 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -122,13 +122,13 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - flats = [X for i in range(1, self._matroid.rank()) + flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] try: poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names - poly_ring = PolynomialRing(R, 'A', len(self.flats)) + poly_ring = PolynomialRing(R, 'A', len(flats)) gens = poly_ring.gens() self._flats_generator = dict(zip(flats, gens)) MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) @@ -233,18 +233,7 @@ def groebner_basis(self): if frozenset() not in flats: flats.append(frozenset()) - ranks = [self._matroid.rank(F) for F in flats] - - def m_n(i): - if flats[i] == frozenset(): - return 0 - else: - sum1 = 0 - for j in range(len(flats)): - if flats[j] < flats[i]: - sum1 += m_n(j) - - return ranks[i] - sum1 + ranks = {F:self._matroid.rank(F) for F in flats} P = LatticePoset(flats) subsets = Subsets(flats) @@ -266,7 +255,7 @@ def m_n(i): if G >= F: term1 += self._flats_generator[G] if term1 != R.zero(): - gb.append(term*(term1**m_n(flats.index(subset)))) + gb.append(term*(term1**())) g_basis = PolynomialSequence(R, [gb]) return g_basis @@ -338,7 +327,7 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - self._flats = [X for i in range(1, self._matroid.rank()) + self._flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) self._flats_generator = dict() @@ -536,7 +525,7 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - self._flats = [X for i in range(1, self._matroid.rank()) + self._flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) @@ -630,7 +619,7 @@ def groebner_basis(self): True """ gb = [] - flats = [X for i in range(1, self._matroid.rank()) + flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] poly_ring = self.ring() if frozenset() in flats: From 5e6bf99549167e1e81cba5da69aa64e5898ccb30 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 10 Sep 2024 11:18:25 +0530 Subject: [PATCH 060/167] Debugged groebner_basis() method for ChowRingIdeal_nonaug --- src/sage/matroids/chow_ring_ideal.py | 45 +++++++++++++++++++++------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index b73a9e63592..6c21492e3ae 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -9,11 +9,10 @@ from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal from sage.matroids.utilities import cmp_elements_key from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.sets.set import Set from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence from sage.misc.abstract_method import abstract_method -from sage.combinat.posets.lattices import LatticePoset from sage.combinat.subset import Subsets +from functools import reduce class ChowRingIdeal(MPolynomialIdeal): @abstract_method @@ -233,29 +232,53 @@ def groebner_basis(self): if frozenset() not in flats: flats.append(frozenset()) + def d(F, G): + lattice_flats = self._matroid.lattice_of_flats() + B = lattice_flats.bottom() + atoms = [x for x in B if B.is_cover(B, x)] + subsets = Subsets(atoms) + n = 0 + i = 0 + while (F != G): + if i == len(subsets): + break + l = [] + for j in list(subsets)[i]: + l.append(j) + l.append(F) + F = lattice_flats.join(l) + n += len(list(subsets)[i]) + i += 1 + return n + ranks = {F:self._matroid.rank(F) for F in flats} - - P = LatticePoset(flats) + flats_gen = self._flats_generator + flats_gen[frozenset()] = R.zero() subsets = Subsets(flats) for subset in subsets: - if not P.subposet(subset).is_chain(): + flag = True + for i in range (len(subset)): + if i != 0 & len(subset[i]) == len(subset[i-1]): + flag = False + + if not flag: term = R.one() for x in subset: - term *= self._flats_generator[x] + term *= flats_gen[x] gb.append(term) - else: + elif list(subset) != []: for F in flats: - if F > P.join(list(subset)): + if F > reduce(lambda a, b: a.union(b), list(subset)): term = R.one() for x in subset: - term *= self._flats_generator[x] + term *= flats_gen[x] term1 = R.zero() for G in flats: if G >= F: - term1 += self._flats_generator[G] + term1 += flats_gen[G] if term1 != R.zero(): - gb.append(term*(term1**())) + gb.append(term*(term1**(d(list(subset)[len(list(subset)) - 1], F)))) g_basis = PolynomialSequence(R, [gb]) return g_basis From 4ed084f1a3dd0b83fcba613bdaf8b642d5ff81fd Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 10 Sep 2024 12:45:37 +0530 Subject: [PATCH 061/167] Edited max_powers --- src/sage/matroids/chow_ring_ideal.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 6c21492e3ae..1515736ef95 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -231,25 +231,6 @@ def groebner_basis(self): R = self.ring() if frozenset() not in flats: flats.append(frozenset()) - - def d(F, G): - lattice_flats = self._matroid.lattice_of_flats() - B = lattice_flats.bottom() - atoms = [x for x in B if B.is_cover(B, x)] - subsets = Subsets(atoms) - n = 0 - i = 0 - while (F != G): - if i == len(subsets): - break - l = [] - for j in list(subsets)[i]: - l.append(j) - l.append(F) - F = lattice_flats.join(l) - n += len(list(subsets)[i]) - i += 1 - return n ranks = {F:self._matroid.rank(F) for F in flats} flats_gen = self._flats_generator @@ -260,6 +241,8 @@ def d(F, G): for i in range (len(subset)): if i != 0 & len(subset[i]) == len(subset[i-1]): flag = False + break + if not flag: term = R.one() @@ -278,7 +261,7 @@ def d(F, G): if G >= F: term1 += flats_gen[G] if term1 != R.zero(): - gb.append(term*(term1**(d(list(subset)[len(list(subset)) - 1], F)))) + gb.append(term*(term1**(ranks[F] - ranks[list(subset)[len(subset) - 1]]))) g_basis = PolynomialSequence(R, [gb]) return g_basis From 9e11b4117ff55217daf654558cc219db48f0ed66 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Fri, 13 Sep 2024 12:54:24 +0530 Subject: [PATCH 062/167] Debugged groebner_basis() method as per hand calculation --- src/sage/matroids/chow_ring_ideal.py | 54 +++++++++++++++++----------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 1515736ef95..2d849082f97 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -10,8 +10,9 @@ from sage.matroids.utilities import cmp_elements_key from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence +from sage.sets.set import Set from sage.misc.abstract_method import abstract_method -from sage.combinat.subset import Subsets +from itertools import combinations from functools import reduce class ChowRingIdeal(MPolynomialIdeal): @@ -229,39 +230,50 @@ def groebner_basis(self): flats = list(self._flats_generator) gb = list() R = self.ring() - if frozenset() not in flats: - flats.append(frozenset()) + if frozenset() in flats: + flats.remove(frozenset()) ranks = {F:self._matroid.rank(F) for F in flats} + flats_gen = self._flats_generator - flats_gen[frozenset()] = R.zero() - subsets = Subsets(flats) + subsets = [] + # Generate all subsets of the frozenset using combinations + for r in range(len(flats) + 1): # r is the size of the subset + subsets.extend(list(subset) for subset in combinations(flats, r)) + for subset in subsets: flag = True - for i in range (len(subset)): - if i != 0 & len(subset[i]) == len(subset[i-1]): + sorted_list = sorted(subset, key=len) + for i in range (len(sorted_list)): + if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): flag = False break - - if not flag: + if flag is False: term = R.one() for x in subset: term *= flats_gen[x] gb.append(term) - elif list(subset) != []: - for F in flats: - if F > reduce(lambda a, b: a.union(b), list(subset)): - term = R.one() - for x in subset: - term *= flats_gen[x] - term1 = R.zero() - for G in flats: - if G >= F: - term1 += flats_gen[G] - if term1 != R.zero(): - gb.append(term*(term1**(ranks[F] - ranks[list(subset)[len(subset) - 1]]))) + elif sorted_list != []: + for j in range(len(subset)): + for k in range(j+1, len(subset)): + if (sorted_list[j] != sorted_list[k]) & (sorted_list[j].issubset(sorted_list[k])): + flag = False + break + + if flag is True: + for F in flats: + if F > reduce(lambda a, b: a.union(b), sorted_list): + term = R.one() + for x in subset: + term *= flats_gen[x] + term1 = R.zero() + for G in flats: + if G >= F: + term1 += flats_gen[G] + if term1 != R.zero(): + gb.append(term*(term1**(ranks[F] - ranks[sorted_list[len(subset) - 1]]))) g_basis = PolynomialSequence(R, [gb]) return g_basis From ec079dc3b20b5e84dd779ac3d6185e52a2301ecd Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Fri, 13 Sep 2024 15:44:54 +0530 Subject: [PATCH 063/167] Added test case for empty subset --- src/sage/matroids/chow_ring_ideal.py | 45 +++++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 2d849082f97..ac5c5c7e513 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -255,25 +255,34 @@ def groebner_basis(self): term *= flats_gen[x] gb.append(term) - elif sorted_list != []: - for j in range(len(subset)): - for k in range(j+1, len(subset)): - if (sorted_list[j] != sorted_list[k]) & (sorted_list[j].issubset(sorted_list[k])): - flag = False - break - - if flag is True: + else: + if subset == []: for F in flats: - if F > reduce(lambda a, b: a.union(b), sorted_list): - term = R.one() - for x in subset: - term *= flats_gen[x] - term1 = R.zero() - for G in flats: - if G >= F: - term1 += flats_gen[G] - if term1 != R.zero(): - gb.append(term*(term1**(ranks[F] - ranks[sorted_list[len(subset) - 1]]))) + term = R.zero() + for G in flats: + if G >= F: + term += flats_gen[G] + gb.append((term)**(ranks[F])) + + else: + for j in range(len(subset)): + for k in range(j+1, len(subset)): + if (sorted_list[j] != sorted_list[k]) & (sorted_list[j].issubset(sorted_list[k])): + flag = False + break + + if flag is True: + for F in flats: + if F > reduce(lambda a, b: a.union(b), sorted_list): + term = R.one() + for x in subset: + term *= flats_gen[x] + term1 = R.zero() + for G in flats: + if G >= F: + term1 += flats_gen[G] + if term1 != R.zero(): + gb.append(term*(term1**(ranks[F] - ranks[sorted_list[len(subset) - 1]]))) g_basis = PolynomialSequence(R, [gb]) return g_basis From 9ad914589a0a070902efc79d585ec12d5916b58e Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 17 Sep 2024 12:30:31 +0530 Subject: [PATCH 064/167] Added comments and edited doctests --- src/sage/matroids/chow_ring_ideal.py | 90 +++++++++++++++------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index ac5c5c7e513..026383c3982 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -10,7 +10,6 @@ from sage.matroids.utilities import cmp_elements_key from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence -from sage.sets.set import Set from sage.misc.abstract_method import abstract_method from itertools import combinations from functools import reduce @@ -106,11 +105,12 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): sage: ch = matroids.Uniform(3,6).chow_ring(QQ, False) sage: ch - Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures - {3: {{0, 1, 2, 3, 4, 5}}} + Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with + circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch - Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, + type (3, 0) """ def __init__(self, M, R): r""" @@ -122,7 +122,7 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - flats = [X for i in range(1, self._matroid.rank() + 1) + flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] try: @@ -141,7 +141,7 @@ def _gens_constructor(self, poly_ring): EXAMPLES:: sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) - sage: ch._gens_constructor(ch.ring()) + sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal.ring()) [Aa*Ab, Aa*Ac, Aa*Ad, Aa*Ae, Aa*Af, Aa*Ag, Aa*Abcd, Aa*Abeg, Aa*Acfg, Aa*Ade, Aa*Adf, Aa*Aef, Ab*Ac, Ab*Ad, Ab*Ae, Ab*Af, Ab*Ag, Ab*Aace, Ab*Aadg, Ab*Acfg, Ab*Ade, Ab*Adf, Ab*Aef, Ac*Ad, Ac*Ae, @@ -186,10 +186,10 @@ def _gens_constructor(self, poly_ring): flats_containing[x].append(i) gens = poly_ring.gens() Q = [gens[i] * gens[i+j+1] for i,F in enumerate(flats) - for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] + for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] #Quadratic Generators L = [sum(gens[i] for i in flats_containing[x]) - sum(gens[i] for i in flats_containing[y]) - for j,x in enumerate(E) for y in E[j+1:]] + for j,x in enumerate(E) for y in E[j+1:]] #Linear Generators return Q + L def _repr_(self): @@ -211,18 +211,20 @@ def groebner_basis(self): sage: from sage.matroids.basis_matroid import BasisMatroid - sage: ch = M=BasisMatroid(groundset='abc', bases=['ab', 'ac'])).chow_ring(QQ, False) + sage: ch = BasisMatroid(groundset='abc', bases=['ab', 'ac'])).chow_ring(QQ, False) sage: ch.groebner_basis() - [Aa^2, Aa*Abc, Aa*Abc, Abc^2] + [Aa, Abc] sage: ch.groebner_basis().is_groebner() True Another example would be the Groebner basis of the Chow ring ideal of - the Non-Fano matroid:: + the Graphic matroid of CycleGraph(3):: - sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) + sage: from sage.matroids.graphic_matroid import GraphicMatroid + + sage: ch = GraphicMatroid(graphs.CycleGraph(3)).chow_ring(QQ, False) sage: ch.groebner_basis() - Polynomial Sequence with 232 Polynomials in 16 Variables + [A0, A1, A2, A0*A1, A0*A2, A1*A2, A0*A1*A2] sage: ch.groebner_basis().is_groebner() True """ @@ -231,25 +233,25 @@ def groebner_basis(self): gb = list() R = self.ring() if frozenset() in flats: - flats.remove(frozenset()) + flats.remove(frozenset()) #Non-empty proper flats needed ranks = {F:self._matroid.rank(F) for F in flats} flats_gen = self._flats_generator subsets = [] - # Generate all subsets of the frozenset using combinations + # Generate all subsets of flats using combinations for r in range(len(flats) + 1): # r is the size of the subset subsets.extend(list(subset) for subset in combinations(flats, r)) for subset in subsets: flag = True sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): + for i in range (len(sorted_list)): #Checking whether the subset is a chain if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): flag = False break - if flag is False: + if flag is False: term = R.one() for x in subset: term *= flats_gen[x] @@ -266,7 +268,7 @@ def groebner_basis(self): else: for j in range(len(subset)): - for k in range(j+1, len(subset)): + for k in range(j+1, len(subset)): #Checking if every element in the chain is maximal if (sorted_list[j] != sorted_list[k]) & (sorted_list[j].issubset(sorted_list[k])): flag = False break @@ -354,15 +356,15 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - self._flats = [X for i in range(1, self._matroid.rank() + 1) + self._flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) self._flats_generator = dict() try: names_groundset = ['A{}'.format(''.join(str(x))) for x in E] names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] - poly_ring = PolynomialRing(R, names_groundset + names_flats) - except ValueError: + poly_ring = PolynomialRing(R, names_groundset + names_flats) #self.ring() + except ValueError: #variables are not proper names poly_ring = PolynomialRing(R, 'A', len(E) + len(self._flats)) for i,x in enumerate(E): self._flats_generator[x] = poly_ring.gens()[i] @@ -417,14 +419,14 @@ def _gens_constructor(self, poly_ring): for F in self._flats: for G in self._flats: if not (F < G or G < F): - Q.append(self._flats_generator[F] * self._flats_generator[G]) + Q.append(self._flats_generator[F] * self._flats_generator[G]) #Quadratic Generators L = list() for x in E: term = poly_ring.zero() for F in self._flats: if F not in flats_containing[x]: term += self._flats_generator[F] - L.append(self._flats_generator[x] - term) + L.append(self._flats_generator[x] - term) #Linear Generators return Q + L def _repr_(self): @@ -445,10 +447,12 @@ def groebner_basis(self): EXAMPLES:: - sage: ch = matroids.catalog.Fano().chow_ring(QQ, True, 'fy') - sage: ch.groebner_basis() - Polynomial Sequence with 1400 Polynomials in 10 Variables - sage: ch.groebner_basis().is_groebner() + sage: ch = matroids.Uniform(2,5).chow_ring(QQ, True, 'fy') + sage: ch.defining_ideal().groebner_basis() + Polynomial Sequence with 250 Polynomials in 10 Variables + sage: ch.defining_ideal().groebner_basis().is_groebner() + True + sage: ch.defining_ideal().basis_is_groebner() True """ gb = [] @@ -456,7 +460,7 @@ def groebner_basis(self): poly_ring = self.ring() for F in self._flats: for G in self._flats: - if not (F < G or G < F): #5.2 + if not (F < G or G < F): #Non-nested flats gb.append(self._flats_generator[F]*self._flats_generator[G]) for i in E: term = poly_ring.zero() @@ -471,14 +475,14 @@ def groebner_basis(self): if term1 != poly_ring.zero(): gb.append(term1**(self._matroid.rank(G)) + 1) #5.6 - if i in G: #5.5 + if i in G: #if element in flat if term1 != poly_ring.zero(): gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(G))) - elif not i in G: #5.3 + elif not i in G: #if element not in flat gb.append(self._flats_generator[i]*self._flats_generator[F]) - elif G < F: #5.4 + elif G < F: #nested flats gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) g_basis = PolynomialSequence(poly_ring, [gb]) @@ -552,7 +556,7 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - self._flats = [X for i in range(1, self._matroid.rank() + 1) + self._flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) @@ -595,22 +599,22 @@ def _gens_constructor(self, poly_ring): """ E = list(self._matroid.groundset()) - Q = [] + Q = [] #Quadratic Generators flats_containing = {x: [] for x in E} for F in self._flats: for x in F: flats_containing[x].append(F) for F in self._flats: for G in self._flats: - if not (G > F or F > G): + if not (G > F or F > G): #generators for every pair of non-nested flats Q.append(self._flats_generator[F]*self._flats_generator[G]) - for x in E: + for x in E: #generators for every set of flats containing element term = poly_ring.zero() for H in flats_containing[x]: term += self._flats_generator[H] Q.append(term**2) - if F not in flats_containing[x]: + if F not in flats_containing[x]: #generators for every set of flats not containing element term = poly_ring.zero() for H in flats_containing[x]: term += self._flats_generator[H] @@ -640,22 +644,24 @@ def groebner_basis(self): sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') - sage: ch.groebner_basis() + sage: ch.defining_ideal().groebner_basis() [A0^2, A0*A1, A0*A2, A0*A1, A1^2, A1*A2, A0*A2, A1*A2, A2^2] - sage: ch.groebner_basis().is_groebner() + sage: ch.defining_ideal().groebner_basis().is_groebner() + True + sage: ch.defining_ideal().basis_is_groebner() True """ gb = [] - flats = [X for i in range(1, self._matroid.rank() + 1) + flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] poly_ring = self.ring() - if frozenset() in flats: + if frozenset() in flats: #Non empty proper flats flats.remove(frozenset()) for F in flats: for G in flats: - if not (F > G or G > F): + if not (F > G or G > F): #Non nested flats gb.append(self._flats_generator[F]*self._flats_generator[G]) - elif F < G: + elif F < G: #Nested flats term = poly_ring.zero() for H in flats: if H < F: From 8b8ab5d496c90914ff7f7de24fc9920a1ee1c8b5 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 18 Sep 2024 09:50:27 +0530 Subject: [PATCH 065/167] Edited basis() method for augmented ChowRing (fy presentation) --- src/sage/matroids/chow_ring.py | 89 +++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index cd12ec00912..23272de19c2 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -10,10 +10,8 @@ from sage.rings.quotient_ring import QuotientRing_generic from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.categories.commutative_rings import CommutativeRings -from sage.sets.set import Set from sage.combinat.posets.posets import Poset -from sage.combinat.subset import Subsets -from itertools import product +from itertools import product, combinations class ChowRing(QuotientRing_generic): r""" @@ -111,7 +109,7 @@ def __init__(self, R, M, augmented, presentation=None): elif presentation == 'atom-free': self._ideal = AugmentedChowRingIdeal_atom_free(M, R) else: - self._ideal = ChowRingIdeal_nonaug(M, R) #check method to get ring + self._ideal = ChowRingIdeal_nonaug(M, R) C = CommutativeRings().Quotients() & GradedAlgebrasWithBasis(R).FiniteDimensional() QuotientRing_generic.__init__(self, R=self._ideal.ring(), I=self._ideal, names=self._ideal.ring().variable_names(), category=C) @@ -178,10 +176,9 @@ def basis(self): sage: ch = matroids.Wheel(3).chow_ring(ZZ, False) [A0*A013, 1] """ - flats = [X for i in range(1, self._matroid.rank() + 1) + flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] flats.append(frozenset()) - maximum_rank = max(self._matroid.rank(F) for F in flats) flats_gen = self._ideal.flats_generator() R = self._ideal.ring() flats = sorted(flats, key=lambda X: (len(X), sorted(X))) @@ -189,18 +186,22 @@ def basis(self): monomial_basis = [] if self._augmented is True: if self._presentation == 'fy': - for i in range(maximum_rank): - term = self._ideal.ring().one() - for j in range(len(flats)): - if j == 0: - if i <= ranks[0]: - if flats[j] in flats_gen: - term *= flats_gen[flats[j]]**(i + 1) - else: - if i < ranks[j] - ranks[j-1]: - if flats[j] in flats_gen: - term *= flats_gen[flats[j]]**(i + 1) - monomial_basis.append(term) + flats.remove(frozenset()) + max_powers = [] + max_powers[0] = ranks[flats[0]] + for i in range(1, len(flats)): + max_powers = ranks[flats[i]] - ranks[flats[i-1]] + for combination in product(*(range(p) for p in max_powers)): + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + max_powers.remove(ranks[flats[0]]) + for combination in product(*(range(p) for p in max_powers)): + expression = flats_gen[flats[0]]**ranks[flats[0]] + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) elif self._presentation == 'atom-free': #all double equals need spacing first_rank = self._matroid.rank(flats[len(flats) - 1]) @@ -245,27 +246,37 @@ def generate_combinations(current_combination, index, max_powers, x_dict): else: R = self._ideal.ring() - lattice_flats = self._matroid.lattice_of_flats() - chains = lattice_flats.chains() - for chain in chains: - max_powers = [] - x_dict = dict() - for i in range(len(chain)): - if chain[i] == frozenset(): - max_powers.append(0) - x_dict[chain[i]] = 1 - elif i == 0: - max_powers.append(ranks[chain[i]]) - x_dict[chain[i]] = flats_gen[chain[i]] - else: - max_powers.append(ranks[chain[i]] - ranks[chain[i-1]]) - x_dict[chain[i]] = flats_gen[chain[i]] - k = len(chain) - for combination in product(*(range(p) for p in max_powers)): - expression = R.one() - for i in range(k): - expression *= x_dict[chain[i]]**combination[i] - monomial_basis.append(expression) + subsets = [] + # Generate all subsets of the frozenset using combinations + for r in range(len(flats) + 1): # r is the size of the subset + subsets.extend(list(subset) for subset in combinations(flats, r)) + for subset in subsets: + flag = True + sorted_list = sorted(subset, key=len) + for i in range (len(sorted_list)): + if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): + flag = False + break + + if flag is True: + max_powers = [] + x_dict = dict() + for i in range(len(subset)): + if subset[i] == frozenset(): + max_powers.append(0) + x_dict[subset[i]] = 1 + elif i == 0: + max_powers.append(ranks[subset[i]]) + x_dict[subset[i]] = flats_gen[subset[i]] + else: + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + x_dict[subset[i]] = flats_gen[subset[i]] + k = len(subset) + for combination in product(*(range(p) for p in max_powers)): + expression = R.one() + for i in range(k): + expression *= x_dict[subset[i]]**combination[i] + monomial_basis.append(expression) from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) From 91a757a29e89e3dcce325c789a704c4808665f30 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 18 Sep 2024 10:40:58 +0530 Subject: [PATCH 066/167] Edited basis() method for augmented Chow Ring (atom-free presentation) --- src/sage/matroids/chow_ring.py | 107 ++++++++++++++++----------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 23272de19c2..1fbc10580cf 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -178,7 +178,6 @@ def basis(self): """ flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] - flats.append(frozenset()) flats_gen = self._ideal.flats_generator() R = self._ideal.ring() flats = sorted(flats, key=lambda X: (len(X), sorted(X))) @@ -186,66 +185,69 @@ def basis(self): monomial_basis = [] if self._augmented is True: if self._presentation == 'fy': - flats.remove(frozenset()) + flats.remove(frozenset()) #Non empty proper flats max_powers = [] max_powers[0] = ranks[flats[0]] for i in range(1, len(flats)): max_powers = ranks[flats[i]] - ranks[flats[i-1]] - for combination in product(*(range(p) for p in max_powers)): + for combination in product(*(range(p) for p in max_powers)): #Generating combinations for all powers up to max_powers expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - max_powers.remove(ranks[flats[0]]) - for combination in product(*(range(p) for p in max_powers)): - expression = flats_gen[flats[0]]**ranks[flats[0]] - for i in range(k): + for i in range(len(flats)): expression *= flats_gen[subset[i]]**combination[i] monomial_basis.append(expression) + if combination[0] == 0: #Generating combinations for all powers including first max_powers + expression *= flats_gen[subset[0]]**max_powers[0] + monomial_basis.append(expression) - elif self._presentation == 'atom-free': #all double equals need spacing - first_rank = self._matroid.rank(flats[len(flats) - 1]) - reln = lambda p,q : p < q - P = Poset((flats, reln)) - chains = P.chains() - def generate_combinations(current_combination, index, max_powers, x_dict): - # Base case: If index equals the length of max_powers, print the current combination - if index == len(max_powers): - expression_terms = [x_dict[i+1] if current_combination[i] == 1 - else x_dict[i+1]**{current_combination[i]} - for i in range(len(current_combination)) if current_combination[i] != 0] - if expression_terms: - term = R.one() - for t in expression_terms: - term *= t - monomial_basis.append(term) - else: - monomial_basis.append(R.one()) - return - - # Recursive case: Iterate over the range for the current index - for power in range(max_powers[index]): - current_combination[index] = power - generate_combinations(current_combination, index + 1, max_powers, x_dict) - - for chain in chains: + elif self._presentation == 'atom-free': + subsets = [] + # Generate all subsets of the frozenset using combinations + for r in range(len(flats) + 1): # r is the size of the subset + subsets.extend(list(subset) for subset in combinations(flats, r)) + for subset in subsets: + flag = True + sorted_list = sorted(subset, key=len) + for i in range (len(sorted_list)): #Taking only chains + if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): + flag = False + break + if flag is True: #For every chain + max_powers = [] x_dict = dict() - for i, F in enumerate(chain): - if F == frozenset(): - x_dict[i] = R.one() + k = len(subset) + for i in range(k-1): + if i == 0: + max_powers.append(ranks[subset[i]]) + x_dict[subset[i]] = flats_gen[subset[i]] else: - x_dict[i] = flats_gen[F] - ranks = [self._matroid.rank(F) for F in chain] - max_powers = [ranks[i-1] - ranks[i] for i in range(1, len(chain))] - k = len(chain) - current_combination = [0] * k - print(max_powers, k, x_dict, chain) - if sum(max_powers) == (first_rank + 1) and max_powers[len(chain) - 1] <= self._matroid.rank(chain[len(chain) - 1]): - generate_combinations(current_combination, 0, max_powers, x_dict) - + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + x_dict[subset[i]] = flats_gen[subset[i]] + x_dict[subset[k-1]] = flats_gen[subset[k-1]] + max_powers[k-1] = ranks[subset[k-1]] + first_rank = ranks[subset[0]] + 1 + last_rank = ranks[subset[k-1]] + for combination in product(*(range(1, p) for p in max_powers)): #Generating combinations for all powers from 1 to max_powers + expression = R.one() + if sum(combination) == first_rank: + for i in range(k): + expression *= x_dict[subset[i]]**combination[i] + monomial_basis.append(expression) + max_powers.remove(last_rank) + for combination in product(*(range(1, p) for p in max_powers)): #Generating all combinations including 0 power and max_power for first flat + expression = R.one() + if sum(combination) == first_rank: + for i in range(len(combination)): + expression *= x_dict[subset[i]]**combination[i] + monomial_basis.append(expression) + else: + expression *= x_dict[subset[k-1]]**last_rank + if sum(combination) + last_rank == first_rank: + for i in range(k): + expression *= x_dict[subset[i]]**combination[i] + monomial_basis.append(expression) - else: - R = self._ideal.ring() + else: + flats.remove(frozenset()) #Non empty proper flats subsets = [] # Generate all subsets of the frozenset using combinations for r in range(len(flats) + 1): # r is the size of the subset @@ -262,10 +264,7 @@ def generate_combinations(current_combination, index, max_powers, x_dict): max_powers = [] x_dict = dict() for i in range(len(subset)): - if subset[i] == frozenset(): - max_powers.append(0) - x_dict[subset[i]] = 1 - elif i == 0: + if i == 0: max_powers.append(ranks[subset[i]]) x_dict[subset[i]] = flats_gen[subset[i]] else: From 12c0d5f65bc75a812601eca48886687b862e8f08 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 18 Sep 2024 10:53:49 +0530 Subject: [PATCH 067/167] Added 'algorithm' parameter to all groebner_basis() methods --- src/sage/matroids/chow_ring_ideal.py | 236 ++++++++++++++------------- 1 file changed, 123 insertions(+), 113 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 026383c3982..c80ba21f5c2 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -202,7 +202,7 @@ def _repr_(self): """ return "Chow ring ideal of {}".format(self._matroid) - def groebner_basis(self): + def groebner_basis(self, algorithm='constructed'): r""" Returns the Groebner basis of the Chow ring ideal. Return type - ``PolynomialSequence``. @@ -228,66 +228,69 @@ def groebner_basis(self): sage: ch.groebner_basis().is_groebner() True """ - - flats = list(self._flats_generator) - gb = list() - R = self.ring() - if frozenset() in flats: - flats.remove(frozenset()) #Non-empty proper flats needed - - ranks = {F:self._matroid.rank(F) for F in flats} - - flats_gen = self._flats_generator - subsets = [] - # Generate all subsets of flats using combinations - for r in range(len(flats) + 1): # r is the size of the subset - subsets.extend(list(subset) for subset in combinations(flats, r)) - - for subset in subsets: - flag = True - sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): #Checking whether the subset is a chain - if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): - flag = False - break - - if flag is False: - term = R.one() - for x in subset: - term *= flats_gen[x] - gb.append(term) - - else: - if subset == []: - for F in flats: - term = R.zero() - for G in flats: - if G >= F: - term += flats_gen[G] - gb.append((term)**(ranks[F])) - + if algorithm == 'constructed': + flats = list(self._flats_generator) + gb = list() + R = self.ring() + if frozenset() in flats: + flats.remove(frozenset()) #Non-empty proper flats needed + + ranks = {F:self._matroid.rank(F) for F in flats} + + flats_gen = self._flats_generator + subsets = [] + # Generate all subsets of flats using combinations + for r in range(len(flats) + 1): # r is the size of the subset + subsets.extend(list(subset) for subset in combinations(flats, r)) + + for subset in subsets: + flag = True + sorted_list = sorted(subset, key=len) + for i in range (len(sorted_list)): #Checking whether the subset is a chain + if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): + flag = False + break + + if flag is False: + term = R.one() + for x in subset: + term *= flats_gen[x] + gb.append(term) + else: - for j in range(len(subset)): - for k in range(j+1, len(subset)): #Checking if every element in the chain is maximal - if (sorted_list[j] != sorted_list[k]) & (sorted_list[j].issubset(sorted_list[k])): - flag = False - break - - if flag is True: + if subset == []: for F in flats: - if F > reduce(lambda a, b: a.union(b), sorted_list): - term = R.one() - for x in subset: - term *= flats_gen[x] - term1 = R.zero() - for G in flats: - if G >= F: - term1 += flats_gen[G] - if term1 != R.zero(): - gb.append(term*(term1**(ranks[F] - ranks[sorted_list[len(subset) - 1]]))) - - g_basis = PolynomialSequence(R, [gb]) - return g_basis + term = R.zero() + for G in flats: + if G >= F: + term += flats_gen[G] + gb.append((term)**(ranks[F])) + + else: + for j in range(len(subset)): + for k in range(j+1, len(subset)): #Checking if every element in the chain is maximal + if (sorted_list[j] != sorted_list[k]) & (sorted_list[j].issubset(sorted_list[k])): + flag = False + break + + if flag is True: + for F in flats: + if F > reduce(lambda a, b: a.union(b), sorted_list): + term = R.one() + for x in subset: + term *= flats_gen[x] + term1 = R.zero() + for G in flats: + if G >= F: + term1 += flats_gen[G] + if term1 != R.zero(): + gb.append(term*(term1**(ranks[F] - ranks[sorted_list[len(subset) - 1]]))) + + g_basis = PolynomialSequence(R, [gb]) + return g_basis + + elif algorithm == 'generic': + super().groebner_basis() class AugmentedChowRingIdeal_fy(ChowRingIdeal): @@ -440,7 +443,7 @@ def _repr_(self): """ return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) - def groebner_basis(self): + def groebner_basis(self, algorithm='constructed'): r""" Returns the Groebner basis of the augmented Chow ring ideal. Return type - ``PolynomialSequence``. @@ -455,38 +458,41 @@ def groebner_basis(self): sage: ch.defining_ideal().basis_is_groebner() True """ - gb = [] - E = list(self._matroid.groundset()) - poly_ring = self.ring() - for F in self._flats: - for G in self._flats: - if not (F < G or G < F): #Non-nested flats - gb.append(self._flats_generator[F]*self._flats_generator[G]) - for i in E: - term = poly_ring.zero() - term1 = poly_ring.zero() - for H in self._flats: - if i in H: - term += self._flats_generator[H] - if H > G: - term1 += self._flats_generator[H] - if term != poly_ring.zero(): - gb.append(self._flats_generator[i] + term) #5.7 - if term1 != poly_ring.zero(): - gb.append(term1**(self._matroid.rank(G)) + 1) #5.6 - - if i in G: #if element in flat + if algorithm == 'constructed': + gb = [] + E = list(self._matroid.groundset()) + poly_ring = self.ring() + for F in self._flats: + for G in self._flats: + if not (F < G or G < F): #Non-nested flats + gb.append(self._flats_generator[F]*self._flats_generator[G]) + for i in E: + term = poly_ring.zero() + term1 = poly_ring.zero() + for H in self._flats: + if i in H: + term += self._flats_generator[H] + if H > G: + term1 += self._flats_generator[H] + if term != poly_ring.zero(): + gb.append(self._flats_generator[i] + term) #5.7 if term1 != poly_ring.zero(): - gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(G))) - - elif not i in G: #if element not in flat - gb.append(self._flats_generator[i]*self._flats_generator[F]) - - elif G < F: #nested flats - gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) - - g_basis = PolynomialSequence(poly_ring, [gb]) - return g_basis + gb.append(term1**(self._matroid.rank(G)) + 1) #5.6 + + if i in G: #if element in flat + if term1 != poly_ring.zero(): + gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(G))) + + elif not i in G: #if element not in flat + gb.append(self._flats_generator[i]*self._flats_generator[F]) + + elif G < F: #nested flats + gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) + + g_basis = PolynomialSequence(poly_ring, [gb]) + return g_basis + elif algorithm == 'generic': + super().groebner_basis() class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): r""" @@ -633,7 +639,7 @@ def _repr_(self): """ return "Augmented Chow ring ideal of {} of atom-free presentation".format(self._matroid) - def groebner_basis(self): + def groebner_basis(self, algorithm='constructed'): """ Returns the Groebner basis of the augmented Chow ring ideal. Return type - ``PolynomialSequence``. @@ -651,27 +657,31 @@ def groebner_basis(self): sage: ch.defining_ideal().basis_is_groebner() True """ - gb = [] - flats = [X for i in range(1, self._matroid.rank()) - for X in self._matroid.flats(i)] - poly_ring = self.ring() - if frozenset() in flats: #Non empty proper flats - flats.remove(frozenset()) - for F in flats: - for G in flats: - if not (F > G or G > F): #Non nested flats - gb.append(self._flats_generator[F]*self._flats_generator[G]) - elif F < G: #Nested flats - term = poly_ring.zero() - for H in flats: - if H < F: - term += self._flats_generator[H] - if term != poly_ring.zero(): - gb.append(self._flats_generator[F]*(term**self._matroid.rank(G))* - (term**(self._matroid.rank(G)-self._matroid.rank(F)))) - - g_basis = PolynomialSequence(poly_ring, [gb]) - return g_basis + if algorithm == 'constructed': + gb = [] + flats = [X for i in range(1, self._matroid.rank()) + for X in self._matroid.flats(i)] + poly_ring = self.ring() + if frozenset() in flats: #Non empty proper flats + flats.remove(frozenset()) + for F in flats: + for G in flats: + if not (F > G or G > F): #Non nested flats + gb.append(self._flats_generator[F]*self._flats_generator[G]) + elif F < G: #Nested flats + term = poly_ring.zero() + for H in flats: + if H < F: + term += self._flats_generator[H] + if term != poly_ring.zero(): + gb.append(self._flats_generator[F]*(term**self._matroid.rank(G))* + (term**(self._matroid.rank(G)-self._matroid.rank(F)))) + + g_basis = PolynomialSequence(poly_ring, [gb]) + return g_basis + + elif algorithm == 'generic': + super().groebner_basis() From 369db7f88d215062a4f072aab97298eb274a0305 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 23 Sep 2024 12:01:31 +0530 Subject: [PATCH 068/167] Edited and formatted doctests --- src/sage/matroids/chow_ring_ideal.py | 180 +++++++++++---------------- 1 file changed, 73 insertions(+), 107 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index c80ba21f5c2..66107410070 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -51,22 +51,7 @@ def flats_generator(self): class ChowRingIdeal_nonaug(ChowRingIdeal): r""" - The Chow ring ideal. - Returns the Chow ring ideal over ring `R` of matroid `M`. - - INPUT: - - - `M` -- a matroid - - `R` -- a commutative ring - - OUTPUT: Chow ring ideal of matroid `M` - - These are the classes of Chow ring ideals for matroids. There are three classes - created - Chow ring ideal and augmented Chow ring ideal. The augmented - Chow ring ideal has two different presentations implemented - the Feitchner- - Yuzvinsky presentation and atom-free presentation. Both classes have - ``grobner_basis()`` methods as well, as an explicit Groebner basis is known - in each case. + The Chow ring ideal of a matroid `M`. The Chow ring ideal is defined over a polynomial ring for a matroid `M`: @@ -74,30 +59,32 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): R[x_{F_1}, \ldots, x_{F_k}] - as - - ..MATH:: - - (Q_M + L_M) + as `(Q_M + L_M)` - where + where - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}` where - `F_i` and `F_j` are incomparable elements in the lattice of - flats, and - - `L_M` is the ideal generated by all linear forms + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}` where + `F_i` and `F_j` are incomparable elements in the lattice of + flats, and + - `L_M` is the ideal generated by all linear forms .. MATH:: \sum_{i_1 \in F} x_F - \sum_{i_2 \in F} x_F - for all `i_1 \neq i_2 \in E`. + for all `i_1 \neq i_2 \in E`. + + INPUT: + + - `M` -- a matroid + - `R` -- a commutative ring + + OUTPUT: Chow ring ideal of matroid `M` - REFERENCES + REFERENCES: - [ANR2023]_ - - [MM2022]_ EXAMPLES: @@ -202,19 +189,18 @@ def _repr_(self): """ return "Chow ring ideal of {}".format(self._matroid) - def groebner_basis(self, algorithm='constructed'): + def groebner_basis(self, algorithm='constructed'): #can you reduce it? - consider every antichain of size 2, and chains? r""" Returns the Groebner basis of the Chow ring ideal. - Return type - ``PolynomialSequence``. EXAMPLES:: sage: from sage.matroids.basis_matroid import BasisMatroid sage: ch = BasisMatroid(groundset='abc', bases=['ab', 'ac'])).chow_ring(QQ, False) - sage: ch.groebner_basis() + sage: ch.defining_ideal().groebner_basis(algorithm='') [Aa, Abc] - sage: ch.groebner_basis().is_groebner() + sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True Another example would be the Groebner basis of the Chow ring ideal of @@ -223,12 +209,12 @@ def groebner_basis(self, algorithm='constructed'): sage: from sage.matroids.graphic_matroid import GraphicMatroid sage: ch = GraphicMatroid(graphs.CycleGraph(3)).chow_ring(QQ, False) - sage: ch.groebner_basis() + sage: ch.defining_ideal().groebner_basis(algorithm='') [A0, A1, A2, A0*A1, A0*A2, A1*A2, A0*A1*A2] - sage: ch.groebner_basis().is_groebner() + sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True """ - if algorithm == 'constructed': + if algorithm == '': flats = list(self._flats_generator) gb = list() R = self.ring() @@ -251,7 +237,7 @@ def groebner_basis(self, algorithm='constructed'): flag = False break - if flag is False: + if not flag: term = R.one() for x in subset: term *= flats_gen[x] @@ -273,7 +259,7 @@ def groebner_basis(self, algorithm='constructed'): flag = False break - if flag is True: + if flag: for F in flats: if F > reduce(lambda a, b: a.union(b), sorted_list): term = R.one() @@ -289,52 +275,49 @@ def groebner_basis(self, algorithm='constructed'): g_basis = PolynomialSequence(R, [gb]) return g_basis - elif algorithm == 'generic': + elif algorithm == 'constructed': #*args **kwds super().groebner_basis() class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" - The class of augmented Chow ring ideal of Feitchner-Yuzvinsky - presentation, a multi-polynomial ideal. - Base class - ``MPolynomialIdeal``. - - INPUT: - - - - `M` -- a matroid - - `R` -- a commutative ring + The augmented Chow ring ideal of matroid `M` over ring `R` in + Feitchner-Yuzvinsky presentation. - OUTPUT: augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky - presentation. - - The augmented Chow ring ideal of Feitchner-Yuzvinsky presentation is defined - over the following polynomial ring: + The augmented Chow ring ideal of Feitchner-Yuzvinsky presentation + is defined over the following polynomial ring: ..MATH:: R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] - as + as `(I_M + J_M)` where + + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, + - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + where `F_i` and `F_j` are incomparable elements in the lattice of + flats, and `y_{i} x_F` for every `i \in E` and `i \notin F`, and + - `I_M` is the ideal generated by all linear forms ..MATH:: - (I_M + J_M) + y_i - \sum_{i \notin F} x_F - where + for all `i \in E`. + + REFERENCES: - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of - flats, and `y_{i} x_F` for every `i \in E` and `i \notin F`, and - - `I_M` is the ideal generated by all linear forms + - [MM2022]_ + + INPUT: - ..MATH:: - y_i - \sum_{i \notin F} x_F + - `M` -- a matroid + - `R` -- a commutative ring - for all `i \in E`. + OUTPUT: augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky + presentation EXAMPLES:: @@ -344,10 +327,6 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation - - REFERENCES - - - [MM2022]_ """ def __init__(self, M, R): r""" @@ -446,19 +425,16 @@ def _repr_(self): def groebner_basis(self, algorithm='constructed'): r""" Returns the Groebner basis of the augmented Chow ring ideal. - Return type - ``PolynomialSequence``. EXAMPLES:: sage: ch = matroids.Uniform(2,5).chow_ring(QQ, True, 'fy') - sage: ch.defining_ideal().groebner_basis() + sage: ch.defining_ideal().groebner_basis(algorithm='') Polynomial Sequence with 250 Polynomials in 10 Variables - sage: ch.defining_ideal().groebner_basis().is_groebner() - True - sage: ch.defining_ideal().basis_is_groebner() + sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True """ - if algorithm == 'constructed': + if algorithm == '': gb = [] E = list(self._matroid.groundset()) poly_ring = self.ring() @@ -491,20 +467,12 @@ def groebner_basis(self, algorithm='constructed'): g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis - elif algorithm == 'generic': + elif algorithm == 'constructed': super().groebner_basis() class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): r""" - The augmented Chow ring ideal in the atom-free - presentation. - - INPUT: - - - ``M`` -- a matroid - - ``R`` -- a commutative ring - - OUTPUT: augmented Chow ring ideal of matroid `M` of atom-free + The augmented Chow ring ideal of matroid `M` over ring `R` in the atom-free presentation. The augmented Chow ring ideal for the atom-free presentation is defined @@ -514,13 +482,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): R[x_{F_1}, \ldots, x_{F_k}] - as - - ..MATH:: - - I_{af}(M) - - where + as `I_{af}(M)` where - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - `I_{af }M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` @@ -531,13 +493,24 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): x_F \sum_{i \in F'} x_{F'} - for all `i \in E` and `i \notin F`, and + for all `i \in E` and `i \notin F`, and ..MATH:: \sum_{i \in F'} (x_{F'})^2 - for all `i \in E`. + for all `i \in E`. + + REFERENCES: + + - [MM2022]_ + + INPUT: + + - ``M`` -- a matroid + - ``R`` -- a commutative ring + + OUTPUT: augmented Chow ring ideal of matroid `M` of atom-free presentation EXAMPLES: @@ -547,10 +520,6 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): sage: ch Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation - - REFERENCES - - - [MM2022]_ """ def __init__(self, M, R): r""" @@ -586,7 +555,7 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" Return the generators of augmented Chow ring ideal of - atom-free presentation. Takes in the ring of that augmented + atom-free presentation. Takes in the ring of the augmented Chow ring ideal as input. EXAMPLES:: @@ -642,7 +611,6 @@ def _repr_(self): def groebner_basis(self, algorithm='constructed'): """ Returns the Groebner basis of the augmented Chow ring ideal. - Return type - ``PolynomialSequence``. EXAMPLES:: @@ -650,14 +618,12 @@ def groebner_basis(self, algorithm='constructed'): sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') - sage: ch.defining_ideal().groebner_basis() + sage: ch.defining_ideal().groebner_basis(algorithm='') [A0^2, A0*A1, A0*A2, A0*A1, A1^2, A1*A2, A0*A2, A1*A2, A2^2] - sage: ch.defining_ideal().groebner_basis().is_groebner() - True - sage: ch.defining_ideal().basis_is_groebner() + sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True """ - if algorithm == 'constructed': + if algorithm == '': gb = [] flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] @@ -680,7 +646,7 @@ def groebner_basis(self, algorithm='constructed'): g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis - elif algorithm == 'generic': + elif algorithm == 'constructed': super().groebner_basis() From 54276307c329fd3c1ef213c02c99fe3e1b63b4ce Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 23 Sep 2024 12:01:57 +0530 Subject: [PATCH 069/167] Edited and formatted doctests for the Chow ring class --- src/sage/matroids/chow_ring.py | 84 +++++++++++++--------------------- 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 1fbc10580cf..32816a36890 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -15,78 +15,58 @@ class ChowRing(QuotientRing_generic): r""" - The class of Chow ring, a multi-polynomial quotient ring. + The Chow ring of a matroid. - INPUT: - - - - `M` -- a matroid - - `R` -- a commutative ring - - ``augmented`` -- a Boolean value. When ``True``, it returns the augmented - Chow ring. If ``False``, it returns the Chow ring - - ``presentation`` -- a string literal. Takes in the presentation of - augmented Chow ring (`fy` or `atom-free`). Default value `None` - - OUTPUT: Chow ring of matroid `M` - - These are the classes of Chow rings for matroids. It also takes in - a parameter boolean ``augmented`` which creates the augmented Chow - ring if given ``True``. - - The Chow ring of a matroid is defined as the quotient ring: + The *Chow ring of a matroid* `M` is defined as the quotient ring: .. MATH:: A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M) - where - - ..MATH:: - - (Q_M + L_M) - - is the Chow ring ideal of matroid `M`. + where `(Q_M + L_M)` is the Chow ring ideal of matroid `M`. - The augmented Chow ring of matroid `M` of Feitchner-Yuzvinsky presentation + The *augmented Chow ring of matroid* `M` in the Feitchner-Yuzvinsky presentation is the quotient ring: ..MATH:: A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M) - where - - ..MATH:: - - (I_M + J_M) + where `(I_M + J_M)` is the augmented Chow ring ideal of matroid `M` + of Feitchner-Yuzvinsky presentation. - is the augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky - presentation. - - The augmented Chow ring of atom-free presentation is the quotient ring: + The *augmented Chow ring of atom-free presentation* is the quotient ring: ..MATH:: A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_{af}M - where - - I_{af}M - - is the augmented Chow ring ideal of matroid `M` of atom-free presentation. + where `I_{af}M` is the augmented Chow ring ideal of matroid `M` of atom-free presentation. .. SEEALSO:: - :mod: sage.matroids.chow_ring_ideal + :mod:`sage.matroids.chow_ring_ideal` + + INPUT: + + - `M` -- a matroid + - `R` -- a commutative ring + - ``augmented`` -- boolean; when ``True``, this is the augmented + Chow ring and if ``False``, this is the non-augmented Chow ring + - ``presentation`` -- string (default: ``None``); one of the following: + + * ``"fy"`` - Feitchner-Yuzvinsky presentation* + * ``"atom-free" - Atom-free presentation* + REFERENCES: - - [FY2004]_ - - [AHK2015]_ + - [FY2004]_ + - [AHK2015]_ EXAMPLES:: - sage: M1 = matroids.catalog.P8pp() + sage: M1 = matroids.catalog.P8pp() #more examples sage: ch = M1.chow_ring(QQ, False) sage: ch Chow ring of P8'': Matroid of rank 4 on 8 elements with 8 nonspanning circuits @@ -97,8 +77,8 @@ def __init__(self, R, M, augmented, presentation=None): EXAMPLES:: - sage: I = matroids.Wheel(3).chow_ring(QQ, False) - sage: TestSuite(I).run() + sage: ch = matroids.Wheel(3).chow_ring(QQ, False) + sage: TestSuite(ch).run() """ self._matroid = M self._augmented = augmented @@ -117,10 +97,10 @@ def _repr_(self): r""" EXAMPLES:: - sage: M1 = matroids.catalog.Fano() - sage: ch = M1.chow_ring(QQ, False) - sage: ch - Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + sage: M1 = matroids.catalog.Fano() + sage: ch = M1.chow_ring(QQ, False) + sage: ch + Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ if self._augmented is True: if self._presentation == 'fy': @@ -290,7 +270,7 @@ def to_vector(self, order=None): sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, False) sage: v = ch.an_element(); v A0 - sage: v.to_vector() #Error in output! + sage: v.to_vector() """ P = self.parent() @@ -310,7 +290,7 @@ def monomial_coefficients(self, copy=None): sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'fy') sage: v = ch.an_element(); v 0 - sage: v.monomial_coefficients() #error in output! + sage: v.monomial_coefficients() """ B = self.parent().basis() From 53ea5fcd5fc2e1d68115c133fb21b4b014c88d3b Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 23 Sep 2024 16:12:00 +0530 Subject: [PATCH 070/167] Edited suggested changes to chow_ring.py --- src/sage/matroids/chow_ring.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 32816a36890..2f66aab6d89 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -30,7 +30,7 @@ class ChowRing(QuotientRing_generic): ..MATH:: - A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M) + A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M), where `(I_M + J_M)` is the augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky presentation. @@ -39,9 +39,10 @@ class ChowRing(QuotientRing_generic): ..MATH:: - A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_{af}M + A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_M^{af} - where `I_{af}M` is the augmented Chow ring ideal of matroid `M` of atom-free presentation. + where `I_M^{af}` is the augmented Chow ring ideal of matroid `M` in the + atom-free presentation. .. SEEALSO:: @@ -91,7 +92,10 @@ def __init__(self, R, M, augmented, presentation=None): else: self._ideal = ChowRingIdeal_nonaug(M, R) C = CommutativeRings().Quotients() & GradedAlgebrasWithBasis(R).FiniteDimensional() - QuotientRing_generic.__init__(self, R=self._ideal.ring(), I=self._ideal, names=self._ideal.ring().variable_names(), category=C) + QuotientRing_generic.__init__(self, R=self._ideal.ring(), + I=self._ideal, + names=self._ideal.ring().variable_names(), + category=C) def _repr_(self): r""" @@ -127,8 +131,8 @@ def _latex_(self): \Bold{Q}[A_{0}, A_{1}, A_{2}, B_{0}, B_{1}, B_{2}] """ - import sage.misc.latex as latex - return "%s/%s" % (latex.latex(self._ideal.ring()), latex.latex(self._ideal)) + from sage.misc.latex import latex + return "{} / {}".format(latex(self._ideal.ring()), latex(self._ideal)) def _coerce_map_from_base_ring(self): r""" @@ -136,7 +140,6 @@ def _coerce_map_from_base_ring(self): TESTS:: - sage: ch = matroids.Wheel(3).chow_ring(QQ, False) sage: ch._coerce_map_from_base_ring() is None True @@ -149,7 +152,6 @@ def basis(self): EXAMPLES:: - sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, True, 'fy') sage: ch.basis() [B0*B01, 1] @@ -161,9 +163,9 @@ def basis(self): flats_gen = self._ideal.flats_generator() R = self._ideal.ring() flats = sorted(flats, key=lambda X: (len(X), sorted(X))) - ranks = {F:self._matroid.rank(F) for F in flats} + ranks = {F: self._matroid.rank(F) for F in flats} monomial_basis = [] - if self._augmented is True: + if self._augmented: if self._presentation == 'fy': flats.remove(frozenset()) #Non empty proper flats max_powers = [] From d631779709fe8e2c95b624626f9cefc628d634c7 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 23 Sep 2024 16:12:41 +0530 Subject: [PATCH 071/167] Edited suggested changes to chow_ring_ideal.py --- src/sage/matroids/chow_ring_ideal.py | 140 +++++++++++++-------------- 1 file changed, 66 insertions(+), 74 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 66107410070..baeddd71156 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -53,35 +53,32 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): r""" The Chow ring ideal of a matroid `M`. - The Chow ring ideal is defined over a polynomial ring for a matroid `M`: - + The *Chow ring ideal* for a matroid `M` is defined as the ideal + `(Q_M + L_M)` of the polynomial ring: + ..MATH:: R[x_{F_1}, \ldots, x_{F_k}] - as `(Q_M + L_M)` - where - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `F_1, \ldots, F_k` are the non-empty flats of `M`, - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}` where - `F_i` and `F_j` are incomparable elements in the lattice of - flats, and + `F_i` and `F_j` are incomparable elements in the lattice of + flats, and - `L_M` is the ideal generated by all linear forms - .. MATH:: + .. MATH:: - \sum_{i_1 \in F} x_F - \sum_{i_2 \in F} x_F + \sum_{i_1 \in F} x_F - \sum_{i_2 \in F} x_F - for all `i_1 \neq i_2 \in E`. + for all `i_1 \neq i_2 \in E`. INPUT: - `M` -- a matroid - `R` -- a commutative ring - OUTPUT: Chow ring ideal of matroid `M` - REFERENCES: - [ANR2023]_ @@ -91,11 +88,11 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): Chow ring ideal of uniform matroid of rank 3 on 6 elements:: sage: ch = matroids.Uniform(3,6).chow_ring(QQ, False) - sage: ch + sage: ch.defining_ideal() Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) - sage: ch + sage: ch.defining_ideal() Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ @@ -105,7 +102,7 @@ def __init__(self, M, R): EXAMPLES:: - sage: I = matroids.catalog.Fano().chow_ring(QQ, False) + sage: I = matroids.catalog.Fano().chow_ring(QQ, False).defining_ideal() sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M @@ -122,7 +119,7 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" - Returns the generators of the Chow ring ideal. Takes in the + Returns the generators of `self`. Takes in the ring of Chow ring ideal as input. EXAMPLES:: @@ -184,14 +181,14 @@ def _repr_(self): EXAMPLES:: sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) - sage: ch + sage: ch.defining_ideal() Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ - return "Chow ring ideal of {}".format(self._matroid) + return "Chow ring ideal of {}- non augmented".format(self._matroid) def groebner_basis(self, algorithm='constructed'): #can you reduce it? - consider every antichain of size 2, and chains? r""" - Returns the Groebner basis of the Chow ring ideal. + Returns the Groebner basis of `self`. EXAMPLES:: @@ -281,60 +278,58 @@ def groebner_basis(self, algorithm='constructed'): #can you reduce it? - conside class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" - The augmented Chow ring ideal of matroid `M` over ring `R` in - Feitchner-Yuzvinsky presentation. - - The augmented Chow ring ideal of Feitchner-Yuzvinsky presentation - is defined over the following polynomial ring: + The augmented Chow ring ideal of matroid `M` over ring `R` in + Feitchner-Yuzvinsky presentation. - ..MATH:: + The augmented Chow ring ideal in the Feitchner-Yuzvinsky presentation + for a matroid `M` is defined as the ideal + `(I_M + J_M)` of the following polynomial ring: - R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] + ..MATH:: - as `(I_M + J_M)` where + R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of - flats, and `y_{i} x_F` for every `i \in E` and `i \notin F`, and - - `I_M` is the ideal generated by all linear forms + as - ..MATH:: + - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, + - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + where `F_i` and `F_j` are incomparable elements in the lattice of + flats, and `y_{i} x_F` for every `i \in E` and `i \notin F`, and + - `I_M` is the ideal generated by all linear forms - y_i - \sum_{i \notin F} x_F + ..MATH:: - for all `i \in E`. - - REFERENCES: + y_i - \sum_{i \notin F} x_F - - [MM2022]_ + for all `i \in E`. - INPUT: + REFERENCES: + - [MM2022]_ - - `M` -- a matroid - - `R` -- a commutative ring + INPUT: - OUTPUT: augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky - presentation - EXAMPLES:: + - `M` -- a matroid + - `R` -- a commutative ring - Augmented Chow ring ideal of Wheel matroid of rank 3:: + EXAMPLES:: - sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') - sage: ch - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on - 6 elements with 16 bases of Feitchner-Yuzvinsky presentation - """ + Augmented Chow ring ideal of Wheel matroid of rank 3:: + + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') + sage: ch.defining_ideal() + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + """ def __init__(self, M, R): r""" Initialize ``self``. EXAMPLES:: - sage: I = matroids.Wheel(3).chow_ring(QQ, True, 'fy') + sage: I = matroids.Wheel(3).chow_ring(QQ, True, 'fy').defining_ideal() sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M @@ -357,14 +352,13 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" - Return the generators of augmented Chow ring ideal of - Feitchner-Yuzvinsky presentation. Takes in the ring of + Return the generators of `self`. Takes in the ring of that augmented Chow ring ideal as input. EXAMPLES:: sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') - sage: ch._gens_constructor(ch.ring()) + sage: ch.defining_ideal()._gens_constructor(ch.ring()) [B0^2, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B124, B0*B15, B0*B23, B0*B345, B0*B1, B1^2, B1*B2, B1*B3, B1*B4, B1*B5, B1*B025, B1*B04, B1*B23, B1*B345, B0*B2, B1*B2, B2^2, B2*B3, B2*B4, B2*B5, B2*B013, @@ -416,7 +410,7 @@ def _repr_(self): EXAMPLES:: sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') - sage: ch + sage: ch.defining_ideal() Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation """ @@ -424,7 +418,7 @@ def _repr_(self): def groebner_basis(self, algorithm='constructed'): r""" - Returns the Groebner basis of the augmented Chow ring ideal. + Returns the Groebner basis of `self`. EXAMPLES:: @@ -472,22 +466,23 @@ def groebner_basis(self, algorithm='constructed'): class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): r""" - The augmented Chow ring ideal of matroid `M` over ring `R` in the atom-free - presentation. + The augmented Chow ring ideal for a matroid `M` over ring `R` in the + atom-free presentation. - The augmented Chow ring ideal for the atom-free presentation is defined - over the polynomial ring: + The augmented Chow ring ideal in the atom-free presentation for a matroid + `M` is defined as the ideal + `I_{af}(M)` of the polynomial ring: ..MATH:: R[x_{F_1}, \ldots, x_{F_k}] - as `I_{af}(M)` where + as - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, - `I_{af }M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of - flats, + where `F_i` and `F_j` are incomparable elements in the lattice of + flats, ..MATH:: @@ -510,14 +505,12 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): - ``M`` -- a matroid - ``R`` -- a commutative ring - OUTPUT: augmented Chow ring ideal of matroid `M` of atom-free presentation - EXAMPLES: Augmented Chow ring ideal of Wheel matroid of rank 3:: sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') - sage: ch + sage: ch.defining_ideal() Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation """ @@ -527,7 +520,7 @@ def __init__(self, M, R): EXAMPLES:: - sage: I = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') + sage: I = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free').defining_ideal() sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M @@ -554,8 +547,7 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" - Return the generators of augmented Chow ring ideal of - atom-free presentation. Takes in the ring of the augmented + Return the generators of `self`. Takes in the ring of the augmented Chow ring ideal as input. EXAMPLES:: @@ -564,7 +556,7 @@ def _gens_constructor(self, poly_ring): sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') - sage: ch._gens_constructor(ch.ring()) + sage: ch.defining_ideal()._gens_constructor(ch.ring()) [A0^2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, A0*A1, A1^2, A2^2, A1*A2, A1^2, A0^2, A0*A1, A1^2, A2^2, A1*A2, @@ -602,15 +594,15 @@ def _repr_(self): EXAMPLE:: sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') - sage: ch + sage: ch.defining_ideal() Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of atom-free presentation """ - return "Augmented Chow ring ideal of {} of atom-free presentation".format(self._matroid) + return "Augmented Chow ring ideal of {} in the atom-free presentation".format(self._matroid) def groebner_basis(self, algorithm='constructed'): """ - Returns the Groebner basis of the augmented Chow ring ideal. + Returns the Groebner basis of `self`. EXAMPLES:: From 6ddca26dcdc777ee277a339619e99af4846eeb2d Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 23 Sep 2024 16:13:50 +0530 Subject: [PATCH 072/167] Fixed doctest typos in chow_ring_ideal.py --- src/sage/matroids/chow_ring_ideal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index baeddd71156..1e4e4eb5117 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -23,7 +23,7 @@ def matroid(self): EXAMPLES:: sage: ch = matroids.Uniform(3,6).chow_ring(QQ, False) - sage: ch.matroid() + sage: ch.defining_ideal().matroid() U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} """ @@ -38,7 +38,7 @@ def flats_generator(self): EXAMPLES:: sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) - sage: ch.flats_generator() + sage: ch.defining_ideal().flats_generator() {frozenset({'a'}): Aa, frozenset({'b'}): Ab, frozenset({'c'}): Ac, frozenset({'d'}): Ad, frozenset({'e'}): Ae, frozenset({'f'}): Af, frozenset({'g'}): Ag, frozenset({'b', 'a', 'f'}): Aabf, From 80a889232bbb9920ff50de1ff5fcb26310ac6a18 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 23 Sep 2024 16:16:28 +0530 Subject: [PATCH 073/167] Fixed doctest typos in chow_ring_ideal.py --- src/sage/matroids/chow_ring_ideal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 1e4e4eb5117..e1f763b2ebc 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -125,7 +125,7 @@ def _gens_constructor(self, poly_ring): EXAMPLES:: sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) - sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal.ring()) + sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) [Aa*Ab, Aa*Ac, Aa*Ad, Aa*Ae, Aa*Af, Aa*Ag, Aa*Abcd, Aa*Abeg, Aa*Acfg, Aa*Ade, Aa*Adf, Aa*Aef, Ab*Ac, Ab*Ad, Ab*Ae, Ab*Af, Ab*Ag, Ab*Aace, Ab*Aadg, Ab*Acfg, Ab*Ade, Ab*Adf, Ab*Aef, Ac*Ad, Ac*Ae, @@ -358,7 +358,7 @@ def _gens_constructor(self, poly_ring): EXAMPLES:: sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') - sage: ch.defining_ideal()._gens_constructor(ch.ring()) + sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) [B0^2, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B124, B0*B15, B0*B23, B0*B345, B0*B1, B1^2, B1*B2, B1*B3, B1*B4, B1*B5, B1*B025, B1*B04, B1*B23, B1*B345, B0*B2, B1*B2, B2^2, B2*B3, B2*B4, B2*B5, B2*B013, @@ -556,7 +556,7 @@ def _gens_constructor(self, poly_ring): sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') - sage: ch.defining_ideal()._gens_constructor(ch.ring()) + sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) [A0^2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, A0*A1, A1^2, A2^2, A1*A2, A1^2, A0^2, A0*A1, A1^2, A2^2, A1*A2, From 17b628724d9de40710ac1bcf685262d8a510e020 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 23 Sep 2024 19:16:53 +0530 Subject: [PATCH 074/167] Fixed doctest typos in chow_ring.py --- src/sage/matroids/chow_ring.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 2f66aab6d89..f1cb86d02d2 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -10,7 +10,6 @@ from sage.rings.quotient_ring import QuotientRing_generic from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.categories.commutative_rings import CommutativeRings -from sage.combinat.posets.posets import Poset from itertools import product, combinations class ChowRing(QuotientRing_generic): From 7439ab9181132d090d6adff1cc3116346c98122f Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 24 Sep 2024 09:13:18 +0530 Subject: [PATCH 075/167] Debugged all 3 basis() method cases --- src/sage/matroids/chow_ring.py | 161 +++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 69 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index f1cb86d02d2..3fe030fdd06 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -166,69 +166,89 @@ def basis(self): monomial_basis = [] if self._augmented: if self._presentation == 'fy': - flats.remove(frozenset()) #Non empty proper flats - max_powers = [] - max_powers[0] = ranks[flats[0]] - for i in range(1, len(flats)): - max_powers = ranks[flats[i]] - ranks[flats[i-1]] - for combination in product(*(range(p) for p in max_powers)): #Generating combinations for all powers up to max_powers - expression = R.one() - for i in range(len(flats)): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - if combination[0] == 0: #Generating combinations for all powers including first max_powers - expression *= flats_gen[subset[0]]**max_powers[0] - monomial_basis.append(expression) + if frozenset() in flats: + flats.remove(frozenset()) #Non empty proper flats + subsets = [] + # Generate all subsets of the frozenset using combinations + for r in range(len(flats) + 1): # r is the size of the subset + subsets.extend(list(subset) for subset in combinations(flats, r)) + for subset in subsets: + flag = True + sorted_list = sorted(subset, key=len) + for i in range (len(sorted_list)): #Taking only chains + if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): + flag = False + break + if flag: + k = len(subset) + if k == 0: + monomial_basis.append(R.one()) + elif k == 1 & ranks[subset[0]] == 1: + monomial_basis.append(flats_gen[subset[0]]) + else: + max_powers = [] + max_powers.append(ranks[subset[0]]) + for i in range(1, k): + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + for p in max_powers: + for combination in product(*(range(1, p))): #Generating combinations for all powers up to max_powers + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + if max_powers.index(p) == 0: #Generating combinations for all powers including first max_powers + expression *= flats_gen[subset[0]]**max_powers[0] + monomial_basis.append(expression) elif self._presentation == 'atom-free': subsets = [] # Generate all subsets of the frozenset using combinations - for r in range(len(flats) + 1): # r is the size of the subset - subsets.extend(list(subset) for subset in combinations(flats, r)) - for subset in subsets: - flag = True - sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): #Taking only chains - if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): - flag = False - break - if flag is True: #For every chain - max_powers = [] - x_dict = dict() - k = len(subset) - for i in range(k-1): - if i == 0: - max_powers.append(ranks[subset[i]]) - x_dict[subset[i]] = flats_gen[subset[i]] - else: - max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - x_dict[subset[i]] = flats_gen[subset[i]] - x_dict[subset[k-1]] = flats_gen[subset[k-1]] - max_powers[k-1] = ranks[subset[k-1]] - first_rank = ranks[subset[0]] + 1 - last_rank = ranks[subset[k-1]] - for combination in product(*(range(1, p) for p in max_powers)): #Generating combinations for all powers from 1 to max_powers - expression = R.one() - if sum(combination) == first_rank: - for i in range(k): - expression *= x_dict[subset[i]]**combination[i] - monomial_basis.append(expression) - max_powers.remove(last_rank) - for combination in product(*(range(1, p) for p in max_powers)): #Generating all combinations including 0 power and max_power for first flat - expression = R.one() - if sum(combination) == first_rank: - for i in range(len(combination)): - expression *= x_dict[subset[i]]**combination[i] - monomial_basis.append(expression) + for r in range(len(flats) + 1): # r is the size of the subset + subsets.extend(list(subset) for subset in combinations(flats, r)) + for subset in subsets: + flag = True + sorted_list = sorted(subset, key=len) + for i in range (len(sorted_list)): #Taking only chains + if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): + flag = False + break + if flag: #For every chain + max_powers = [] + k = len(subset) + if subset == []: + monomial_basis.append(R.one()) else: - expression *= x_dict[subset[k-1]]**last_rank - if sum(combination) + last_rank == first_rank: - for i in range(k): - expression *= x_dict[subset[i]]**combination[i] - monomial_basis.append(expression) + for i in range(k-1): + if i == 0: + max_powers.append(ranks[subset[i]]) + else: + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + max_powers.append(ranks[subset[k-1]]) + first_rank = ranks[subset[0]] + 1 + last_rank = ranks[subset[k-1]] + for combination in product(*(range(1, p) for p in max_powers)): #Generating combinations for all powers from 1 to max_powers + expression = R.one() + if sum(combination) == first_rank: + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + max_powers.remove(last_rank) + for combination in product(*(range(1, p) for p in max_powers)): #Generating all combinations including 0 power and max_power for first flat + expression = R.one() + if sum(combination) == first_rank: + for i in range(len(combination)): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + else: + expression *= flats_gen[subset[k-1]]**last_rank + if sum(combination) + last_rank == first_rank: + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) else: - flats.remove(frozenset()) #Non empty proper flats + if frozenset() in flats: + flats.remove(frozenset()) #Non empty proper flats subsets = [] # Generate all subsets of the frozenset using combinations for r in range(len(flats) + 1): # r is the size of the subset @@ -241,22 +261,25 @@ def basis(self): flag = False break - if flag is True: + if flag: max_powers = [] - x_dict = dict() - for i in range(len(subset)): - if i == 0: - max_powers.append(ranks[subset[i]]) - x_dict[subset[i]] = flats_gen[subset[i]] - else: - max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - x_dict[subset[i]] = flats_gen[subset[i]] k = len(subset) - for combination in product(*(range(p) for p in max_powers)): - expression = R.one() + if k == 0: + monomial_basis.append(R.one()) + elif k == 1 & ranks[subset[0]] == 1: + monomial_basis.append(flats_gen[subset[0]]) + else: for i in range(k): - expression *= x_dict[subset[i]]**combination[i] - monomial_basis.append(expression) + if i == 0: + max_powers.append(ranks[subset[i]]) + else: + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + for combination in product(*(range(1, p) for p in max_powers)): + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) From 96a7dc81060005af5fe84a19bed1839d125d2e47 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 24 Sep 2024 09:15:45 +0530 Subject: [PATCH 076/167] Optimized groebner_basis() method --- src/sage/matroids/chow_ring_ideal.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index e1f763b2ebc..84dbe458760 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -227,6 +227,7 @@ def groebner_basis(self, algorithm='constructed'): #can you reduce it? - conside subsets.extend(list(subset) for subset in combinations(flats, r)) for subset in subsets: + k = len(subset) flag = True sorted_list = sorted(subset, key=len) for i in range (len(sorted_list)): #Checking whether the subset is a chain @@ -235,13 +236,14 @@ def groebner_basis(self, algorithm='constructed'): #can you reduce it? - conside break if not flag: - term = R.one() - for x in subset: - term *= flats_gen[x] - gb.append(term) + if k == 2: #Taking only antichains of length 2 + term = R.one() + for x in subset: + term *= flats_gen[x] + gb.append(term) else: - if subset == []: + if k == 0: for F in flats: term = R.zero() for G in flats: @@ -250,7 +252,7 @@ def groebner_basis(self, algorithm='constructed'): #can you reduce it? - conside gb.append((term)**(ranks[F])) else: - for j in range(len(subset)): + for i in range(len(subset)): for k in range(j+1, len(subset)): #Checking if every element in the chain is maximal if (sorted_list[j] != sorted_list[k]) & (sorted_list[j].issubset(sorted_list[k])): flag = False From f01279ad6f1fdf9ed62596af9bf3d663b764ed13 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 24 Sep 2024 09:53:49 +0530 Subject: [PATCH 077/167] Fixed typos in groebner_basis() method --- src/sage/matroids/chow_ring_ideal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 84dbe458760..b5a30986e54 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -253,8 +253,8 @@ def groebner_basis(self, algorithm='constructed'): #can you reduce it? - conside else: for i in range(len(subset)): - for k in range(j+1, len(subset)): #Checking if every element in the chain is maximal - if (sorted_list[j] != sorted_list[k]) & (sorted_list[j].issubset(sorted_list[k])): + for j in range(i+1, len(subset)): #Checking if every element in the chain is maximal + if (sorted_list[i] != sorted_list[j]) & (sorted_list[i].issubset(sorted_list[j])): flag = False break From d0fb2baaa094fdc8e05d200b9045af229cf9ab14 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 24 Sep 2024 10:14:30 +0530 Subject: [PATCH 078/167] Added LaTeX method for the ideals --- src/sage/matroids/chow_ring_ideal.py | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index b5a30986e54..3c99fa85683 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -185,6 +185,27 @@ def _repr_(self): Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ return "Chow ring ideal of {}- non augmented".format(self._matroid) + + def _latex_(self): + r""" + Return the LaTeX output of the ring and generators of `self`. + + EXAMPLES:: + + sage: from sage.matroids.basis_matroid import BasisMatroid + + sage: M1 = BasisMatroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: ch = M1.chow_ring(QQ, False) + sage: ch.defining_ideal()._latex_() + '\\left(\\mathit{Aac} \\mathit{Abd}, 0, + \\mathit{Aac} - \\mathit{Abd}, \\mathit{Aac} - \\mathit{Abd}, + \\mathit{Aac} - \\mathit{Abd}, \\mathit{Aac} - \\mathit{Abd}, + 0\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' + """ + from sage.misc.latex import latex + return '\\left(%s\\right)%s' % (", ".join(latex(g) + for g in self.gens()), + latex(self.ring())) def groebner_basis(self, algorithm='constructed'): #can you reduce it? - consider every antichain of size 2, and chains? r""" @@ -418,6 +439,29 @@ def _repr_(self): """ return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) + def _latex_(self): + r""" + Return the LaTeX output of the ring and generators of `self`. + + EXAMPLES:: + + sage: from sage.matroids.basis_matroid import BasisMatroid + + sage: M1 = BasisMatroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: ch = M1.chow_ring(QQ, True, 'fy') + sage: ch.defining_ideal()._latex_() + '\\left(\\mathit{Bac}^{2}, \\mathit{Bac} \\mathit{Bbd}, + \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bbd}^{2}, + \\mathit{Ad} - \\mathit{Bac}, \\mathit{Ab} - \\mathit{Bac}, + \\mathit{Aa} - \\mathit{Bbd}, \\mathit{Ac} - \\mathit{Bbd}\\right) + \\Bold{Q}[\\mathit{Ad}, \\mathit{Ab}, \\mathit{Aa}, \\mathit{Ac}, + \\mathit{Bac}, \\mathit{Bbd}]' + """ + from sage.misc.latex import latex + return '\\left(%s\\right)%s' % (", ".join(latex(g) + for g in self.gens()), + latex(self.ring())) + def groebner_basis(self, algorithm='constructed'): r""" Returns the Groebner basis of `self`. @@ -602,6 +646,35 @@ def _repr_(self): """ return "Augmented Chow ring ideal of {} in the atom-free presentation".format(self._matroid) + def _latex_(self): + r""" + Return the LaTeX output of the ring and generators of `self`. + + EXAMPLES:: + + sage: from sage.matroids.basis_matroid import BasisMatroid + + sage: M1 = BasisMatroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: ch = M1.chow_ring(QQ, True, 'atom-free') + sage: ch.defining_ideal()._latex_() + '\\left(\\mathit{Aac}^{2}, \\mathit{Abd}^{2}, + \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, + \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac}^{2}, + \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, + \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, + \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac}^{2}, + \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, + \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, + \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, + \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, + \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}\\right) + \\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' + """ + from sage.misc.latex import latex + return '\\left(%s\\right)%s' % (", ".join(latex(g) + for g in self.gens()), + latex(self.ring())) + def groebner_basis(self, algorithm='constructed'): """ Returns the Groebner basis of `self`. From 3ed13fa30b42fc097f50985a086e4b79e6585d92 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 24 Sep 2024 10:46:04 +0530 Subject: [PATCH 079/167] Edited definintions for augmented Chow ring ideal --- src/sage/matroids/chow_ring_ideal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 3c99fa85683..393c0ee1629 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -314,7 +314,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): as - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `F_1, \ldots, F_k` are the proper flats of `M`, - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` where `F_i` and `F_j` are incomparable elements in the lattice of @@ -525,7 +525,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): as - - `F_1, \ldots, F_k` are the non-empty proper flats of `M`, + - `F_1, \ldots, F_k` are the non-empty flats of `M`, - `I_{af }M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` where `F_i` and `F_j` are incomparable elements in the lattice of flats, From db165d7202e2065b858ec51ab4c48a6fe3abcce6 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 24 Sep 2024 10:52:16 +0530 Subject: [PATCH 080/167] Fixed definitions of augmented Chow ring ideals --- src/sage/matroids/chow_ring_ideal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 393c0ee1629..aba6db99ccd 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -314,7 +314,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): as - - `F_1, \ldots, F_k` are the proper flats of `M`, + - `F_1, \ldots, F_k` are the flats of `M`, - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` where `F_i` and `F_j` are incomparable elements in the lattice of @@ -526,7 +526,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): as - `F_1, \ldots, F_k` are the non-empty flats of `M`, - - `I_{af }M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + - `I_{af}M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` where `F_i` and `F_j` are incomparable elements in the lattice of flats, From 88b20fb09714184381e5536db98358b7e9269fbb Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 24 Sep 2024 11:08:31 +0530 Subject: [PATCH 081/167] Edited groebner_basis() method for all 3 ideals --- src/sage/matroids/chow_ring_ideal.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index aba6db99ccd..3efcdbc4e54 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -207,7 +207,7 @@ def _latex_(self): for g in self.gens()), latex(self.ring())) - def groebner_basis(self, algorithm='constructed'): #can you reduce it? - consider every antichain of size 2, and chains? + def groebner_basis(self, algorithm='constructed', *args, **kwargs): #can you reduce it? - consider every antichain of size 2, and chains? r""" Returns the Groebner basis of `self`. @@ -295,8 +295,8 @@ def groebner_basis(self, algorithm='constructed'): #can you reduce it? - conside g_basis = PolynomialSequence(R, [gb]) return g_basis - elif algorithm == 'constructed': #*args **kwds - super().groebner_basis() + elif algorithm == 'constructed': + super().groebner_basis(*args, **kwargs) class AugmentedChowRingIdeal_fy(ChowRingIdeal): @@ -462,7 +462,7 @@ def _latex_(self): for g in self.gens()), latex(self.ring())) - def groebner_basis(self, algorithm='constructed'): + def groebner_basis(self, algorithm='constructed', *args, **kwargs): r""" Returns the Groebner basis of `self`. @@ -508,7 +508,7 @@ def groebner_basis(self, algorithm='constructed'): g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis elif algorithm == 'constructed': - super().groebner_basis() + super().groebner_basis(*args, **kwargs) class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): r""" @@ -675,7 +675,7 @@ def _latex_(self): for g in self.gens()), latex(self.ring())) - def groebner_basis(self, algorithm='constructed'): + def groebner_basis(self, algorithm='constructed', *args, **kwargs): """ Returns the Groebner basis of `self`. @@ -714,7 +714,7 @@ def groebner_basis(self, algorithm='constructed'): return g_basis elif algorithm == 'constructed': - super().groebner_basis() + super().groebner_basis(*args, **kwargs) From 4669fd61c77458b679e007216382dec62f5f2445 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 25 Sep 2024 17:02:32 +0530 Subject: [PATCH 082/167] Edited chow_ring() function examples --- src/sage/matroids/matroid.pyx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 428d565b2b8..6999c30252a 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8030,14 +8030,12 @@ cdef class Matroid(SageObject): def chow_ring(self, R, augmented=False, presentation=None): r""" - Return the Chow ring of ``self`` over ``R``. - Return the augmented Chow ring of `self` over `R`of `presentation` - if `augmented` is `True`. + Return the (augmented) Chow ring of ``self`` over ``R``. .. SEEALSO:: - :mod: sage.matroids.chow_ring_ideal - :mod: sage.matroids.chow_ring + - :mod:`sage.matroids.chow_ring_ideal` + - :mod:`sage.matroids.chow_ring` EXAMPLES:: @@ -8058,7 +8056,7 @@ cdef class Matroid(SageObject): Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) over Rational Field. - The augmented Chow ring can also be instantiated with the + The augmented Chow ring can also be constructed with the Feitchner-Yuzvinsky and atom-free presentation:: sage: M = matroids.Wheel(3) @@ -8069,7 +8067,6 @@ cdef class Matroid(SageObject): sage: ch = M.chow_ring(QQ, augmented=True, presentation='atom-free') Augmented Chow ring of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} of atom-free presentation - """ from sage.matroids.chow_ring import ChowRing return ChowRing(M=self, R=R, augmented=augmented, presentation=presentation) From a84a41d371dfa177d15ad68e0339efca2780d403 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 25 Sep 2024 17:03:12 +0530 Subject: [PATCH 083/167] Edited Doctests --- src/sage/matroids/chow_ring.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 3fe030fdd06..46edaacdf95 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -16,29 +16,29 @@ class ChowRing(QuotientRing_generic): r""" The Chow ring of a matroid. - The *Chow ring of a matroid* `M` is defined as the quotient ring: + The *Chow ring of a matroid* `M` is defined as the quotient ring .. MATH:: - A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M) + A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M), where `(Q_M + L_M)` is the Chow ring ideal of matroid `M`. The *augmented Chow ring of matroid* `M` in the Feitchner-Yuzvinsky presentation - is the quotient ring: + is the quotient ring - ..MATH:: + .. MATH:: A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M), where `(I_M + J_M)` is the augmented Chow ring ideal of matroid `M` of Feitchner-Yuzvinsky presentation. - The *augmented Chow ring of atom-free presentation* is the quotient ring: + The *augmented Chow ring of atom-free presentation* is the quotient ring - ..MATH:: + .. MATH:: - A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_M^{af} + A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_M^{af}, where `I_M^{af}` is the augmented Chow ring ideal of matroid `M` in the atom-free presentation. @@ -49,15 +49,14 @@ class ChowRing(QuotientRing_generic): INPUT: - - `M` -- a matroid - - `R` -- a commutative ring + - ``M`` -- matroid + - ``R`` -- commutative ring - ``augmented`` -- boolean; when ``True``, this is the augmented - Chow ring and if ``False``, this is the non-augmented Chow ring + Chow ring and if ``False``, this is the non-augmented Chow ring - ``presentation`` -- string (default: ``None``); one of the following: - * ``"fy"`` - Feitchner-Yuzvinsky presentation* - * ``"atom-free" - Atom-free presentation* - + * ``"fy"`` - the Feitchner-Yuzvinsky presentation + * ``"atom-free" - the atom-free presentation REFERENCES: @@ -295,7 +294,6 @@ def to_vector(self, order=None): sage: v = ch.an_element(); v A0 sage: v.to_vector() - """ P = self.parent() B = P.basis() @@ -315,7 +313,6 @@ def monomial_coefficients(self, copy=None): sage: v = ch.an_element(); v 0 sage: v.monomial_coefficients() - """ B = self.parent().basis() f = self.lift() From e45f4b991ac14a2da4038970126dd06d68f817ce Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 25 Sep 2024 17:03:40 +0530 Subject: [PATCH 084/167] Edited doctests for ideals --- src/sage/matroids/chow_ring_ideal.py | 197 +++++++++++++-------------- 1 file changed, 96 insertions(+), 101 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 3efcdbc4e54..8785360f3b0 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -54,16 +54,16 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): The Chow ring ideal of a matroid `M`. The *Chow ring ideal* for a matroid `M` is defined as the ideal - `(Q_M + L_M)` of the polynomial ring: + `(Q_M + L_M)` of the polynomial ring - ..MATH:: + .. MATH:: - R[x_{F_1}, \ldots, x_{F_k}] + R[x_{F_1}, \ldots, x_{F_k}], where - `F_1, \ldots, F_k` are the non-empty flats of `M`, - - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}` where + - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}`, where `F_i` and `F_j` are incomparable elements in the lattice of flats, and - `L_M` is the ideal generated by all linear forms @@ -76,8 +76,8 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): INPUT: - - `M` -- a matroid - - `R` -- a commutative ring + - `M` -- matroid + - `R` -- commutative ring REFERENCES: @@ -119,8 +119,7 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" - Returns the generators of `self`. Takes in the - ring of Chow ring ideal as input. + Return the generators of ``self``. EXAMPLES:: @@ -178,6 +177,8 @@ def _gens_constructor(self, poly_ring): def _repr_(self): r""" + Return a string representation of ``self``. + EXAMPLES:: sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) @@ -188,7 +189,7 @@ def _repr_(self): def _latex_(self): r""" - Return the LaTeX output of the ring and generators of `self`. + Return a LaTeX representation of ``self``. EXAMPLES:: @@ -207,96 +208,92 @@ def _latex_(self): for g in self.gens()), latex(self.ring())) - def groebner_basis(self, algorithm='constructed', *args, **kwargs): #can you reduce it? - consider every antichain of size 2, and chains? + def groebner_basis(self, algorithm='', *args, **kwargs): #can you reduce it? - consider every antichain of size 2, and chains? r""" - Returns the Groebner basis of `self`. + Return a Groebner basis of ``self``. EXAMPLES:: - sage: from sage.matroids.basis_matroid import BasisMatroid - - sage: ch = BasisMatroid(groundset='abc', bases=['ab', 'ac'])).chow_ring(QQ, False) - sage: ch.defining_ideal().groebner_basis(algorithm='') + sage: ch = Matroid(groundset='abc', bases=['ab', 'ac']).chow_ring(QQ, False) + sage: ch.defining_ideal().groebner_basis() [Aa, Abc] - sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() + sage: ch.defining_ideal().groebner_basis().is_groebner() True Another example would be the Groebner basis of the Chow ring ideal of - the Graphic matroid of CycleGraph(3):: + the matroid of the length 3 cycle graph:: - sage: from sage.matroids.graphic_matroid import GraphicMatroid - - sage: ch = GraphicMatroid(graphs.CycleGraph(3)).chow_ring(QQ, False) - sage: ch.defining_ideal().groebner_basis(algorithm='') + sage: ch = Matroid(graphs.CycleGraph(3)).chow_ring(QQ, False) + sage: ch.defining_ideal().groebner_basis() [A0, A1, A2, A0*A1, A0*A2, A1*A2, A0*A1*A2] - sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() + sage: ch.defining_ideal().groebner_basis().is_groebner() True """ if algorithm == '': - flats = list(self._flats_generator) - gb = list() - R = self.ring() - if frozenset() in flats: - flats.remove(frozenset()) #Non-empty proper flats needed - - ranks = {F:self._matroid.rank(F) for F in flats} - - flats_gen = self._flats_generator - subsets = [] - # Generate all subsets of flats using combinations - for r in range(len(flats) + 1): # r is the size of the subset - subsets.extend(list(subset) for subset in combinations(flats, r)) - - for subset in subsets: - k = len(subset) - flag = True - sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): #Checking whether the subset is a chain - if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): - flag = False - break - - if not flag: - if k == 2: #Taking only antichains of length 2 - term = R.one() - for x in subset: - term *= flats_gen[x] - gb.append(term) - + algorithm = 'constructed' + if algorithm != 'constructed': + return super().groebner_basis(algorithm=algorithm, *args, **kwargs) + flats = list(self._flats_generator) + gb = list() + R = self.ring() + if frozenset() in flats: + flats.remove(frozenset()) #Non-empty proper flats needed + + ranks = {F:self._matroid.rank(F) for F in flats} + + flats_gen = self._flats_generator + subsets = [] + # Generate all subsets of flats using combinations + for r in range(len(flats) + 1): # r is the size of the subset + subsets.extend(list(subset) for subset in combinations(flats, r)) + + for subset in subsets: + k = len(subset) + flag = True + sorted_list = sorted(subset, key=len) + for i in range (len(sorted_list)): #Checking whether the subset is a chain + if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): + flag = False + break + + if not flag: + if k == 2: #Taking only antichains of length 2 + term = R.one() + for x in subset: + term *= flats_gen[x] + gb.append(term) + + else: + if k == 0: + for F in flats: + term = R.zero() + for G in flats: + if G >= F: + term += flats_gen[G] + gb.append((term)**(ranks[F])) + else: - if k == 0: + for i in range(len(subset)): + for j in range(i+1, len(subset)): #Checking if every element in the chain is maximal + if (sorted_list[i] != sorted_list[j]) & (sorted_list[i].issubset(sorted_list[j])): + flag = False + break + + if flag: for F in flats: - term = R.zero() - for G in flats: - if G >= F: - term += flats_gen[G] - gb.append((term)**(ranks[F])) - - else: - for i in range(len(subset)): - for j in range(i+1, len(subset)): #Checking if every element in the chain is maximal - if (sorted_list[i] != sorted_list[j]) & (sorted_list[i].issubset(sorted_list[j])): - flag = False - break - - if flag: - for F in flats: - if F > reduce(lambda a, b: a.union(b), sorted_list): - term = R.one() - for x in subset: - term *= flats_gen[x] - term1 = R.zero() - for G in flats: - if G >= F: - term1 += flats_gen[G] - if term1 != R.zero(): - gb.append(term*(term1**(ranks[F] - ranks[sorted_list[len(subset) - 1]]))) - - g_basis = PolynomialSequence(R, [gb]) - return g_basis - - elif algorithm == 'constructed': - super().groebner_basis(*args, **kwargs) + if F > reduce(lambda a, b: a.union(b), sorted_list): + term = R.one() + for x in subset: + term *= flats_gen[x] + term1 = R.zero() + for G in flats: + if G >= F: + term1 += flats_gen[G] + if term1 != R.zero(): + gb.append(term*(term1**(ranks[F] - ranks[sorted_list[len(subset) - 1]]))) + + g_basis = PolynomialSequence(R, [gb]) + return g_basis class AugmentedChowRingIdeal_fy(ChowRingIdeal): @@ -306,26 +303,26 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): The augmented Chow ring ideal in the Feitchner-Yuzvinsky presentation for a matroid `M` is defined as the ideal - `(I_M + J_M)` of the following polynomial ring: + `(I_M + J_M)` of the following polynomial ring - ..MATH:: + .. MATH:: - R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] + R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}], - as + where - `F_1, \ldots, F_k` are the flats of `M`, - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of - flats, and `y_{i} x_F` for every `i \in E` and `i \notin F`, and - - `I_M` is the ideal generated by all linear forms + - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}`, + where `F_i` and `F_j` are incomparable elements in the lattice of + flats and `y_{i} x_F` for every `i \in E` and `i \notin F`, and + - `I_M` is the ideal generated by all linear forms - ..MATH:: + .. MATH:: - y_i - \sum_{i \notin F} x_F + y_i - \sum_{i \notin F} x_F - for all `i \in E`. + for all `i \in E`. REFERENCES: @@ -333,9 +330,8 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): INPUT: - - - `M` -- a matroid - - `R` -- a commutative ring + - ``M`` -- matroid + - ``R`` -- commutative ring EXAMPLES:: @@ -375,8 +371,7 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" - Return the generators of `self`. Takes in the ring of - that augmented Chow ring ideal as input. + Return the generators of ``self``. EXAMPLES:: @@ -441,7 +436,7 @@ def _repr_(self): def _latex_(self): r""" - Return the LaTeX output of the ring and generators of `self`. + Return a LaTeX representation`self`. EXAMPLES:: From ffd3fefa2d7e09e9d998120b422b4e1d5cf7c416 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 30 Sep 2024 12:22:21 +0530 Subject: [PATCH 085/167] Edited basis() method for all 3 cases --- src/sage/matroids/chow_ring.py | 83 +++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 46edaacdf95..d907301ac6c 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -106,9 +106,9 @@ def _repr_(self): """ if self._augmented is True: if self._presentation == 'fy': - return "Augmented Chow ring of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) + return "Augmented Chow ring of {} in Feitchner-Yuzvinsky presentation".format(self._matroid) elif self._presentation == 'atom-free': - return "Augmented Chow ring of {} of atom-free presentation".format(self._matroid) + return "Augmented Chow ring of {} in atom-free presentation".format(self._matroid) return "Chow ring of {}".format(self._matroid) def _latex_(self): @@ -190,18 +190,21 @@ def basis(self): for i in range(1, k): max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) for p in max_powers: - for combination in product(*(range(1, p))): #Generating combinations for all powers up to max_powers - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - if max_powers.index(p) == 0: #Generating combinations for all powers including first max_powers - expression *= flats_gen[subset[0]]**max_powers[0] + if p != 1 & p != 0: + for combination in product(*(range(1, p))): + #Generating combinations for all powers up to max_powers + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] monomial_basis.append(expression) + if max_powers.index(p) == 0: + #Generating combinations for all powers including first max_powers + expression *= flats_gen[subset[0]]**max_powers[0] + monomial_basis.append(expression) elif self._presentation == 'atom-free': subsets = [] - # Generate all subsets of the frozenset using combinations + # Generate all subsets of the frozenset using combinations for r in range(len(flats) + 1): # r is the size of the subset subsets.extend(list(subset) for subset in combinations(flats, r)) for subset in subsets: @@ -225,31 +228,37 @@ def basis(self): max_powers.append(ranks[subset[k-1]]) first_rank = ranks[subset[0]] + 1 last_rank = ranks[subset[k-1]] - for combination in product(*(range(1, p) for p in max_powers)): #Generating combinations for all powers from 1 to max_powers - expression = R.one() - if sum(combination) == first_rank: - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) + for p in max_powers: + if p != 1 & p != 0: + for combination in product(*(range(1, p))): + #Generating combinations for all powers from 1 to max_powers + expression = R.one() + if sum(combination) == first_rank: + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) max_powers.remove(last_rank) - for combination in product(*(range(1, p) for p in max_powers)): #Generating all combinations including 0 power and max_power for first flat - expression = R.one() - if sum(combination) == first_rank: - for i in range(len(combination)): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - else: - expression *= flats_gen[subset[k-1]]**last_rank - if sum(combination) + last_rank == first_rank: - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) + for p in max_powers: + if p != 1 & p != 0: + for combination in product(*(range(1, p))): + #Generating all combinations including 0 power and max_power for first flat + expression = R.one() + if sum(combination) == first_rank: + for i in range(len(combination)): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + else: + expression *= flats_gen[subset[k-1]]**last_rank + if sum(combination) + last_rank == first_rank: + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) else: if frozenset() in flats: flats.remove(frozenset()) #Non empty proper flats subsets = [] - # Generate all subsets of the frozenset using combinations + # Generate all subsets of the frozenset using combinations for r in range(len(flats) + 1): # r is the size of the subset subsets.extend(list(subset) for subset in combinations(flats, r)) for subset in subsets: @@ -273,11 +282,13 @@ def basis(self): max_powers.append(ranks[subset[i]]) else: max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - for combination in product(*(range(1, p) for p in max_powers)): - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) + for p in max_powers: + if p != 1 & p != 0: + for combination in product(*(range(1, p))): + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) from sage.sets.family import Family @@ -349,7 +360,7 @@ def homogeneous_degree(self): Ba^2 2 sage: v = sum(ch.basis()); v Ba^2 + Ba*Babf - sage: v.homogeneous_degree() #error - basis() type is wrong! + sage: v.homogeneous_degree() Traceback (most recent call last): ... ValueError: element is not homogeneous @@ -357,7 +368,7 @@ def homogeneous_degree(self): TESTS:: sage: ch = matroids.Wheel(3).chow_ring(QQ, False) - sage: ch.zero().homogeneous_degree() #error! + sage: ch.zero().homogeneous_degree() Traceback (most recent call last): ... ValueError: the zero element does not have a well-defined degree From e2faf65ad572cb065b09607ca3c5089d23d423ca Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 30 Sep 2024 12:32:09 +0530 Subject: [PATCH 086/167] Added hyperlinks to ideals definitions in chow_ring.py --- src/sage/matroids/chow_ring.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index d907301ac6c..7a69f289c7b 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -22,7 +22,8 @@ class ChowRing(QuotientRing_generic): A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M), - where `(Q_M + L_M)` is the Chow ring ideal of matroid `M`. + where `(Q_M + L_M)` is the :class:`Chow ring ideal + ` of matroid `M`. The *augmented Chow ring of matroid* `M` in the Feitchner-Yuzvinsky presentation is the quotient ring @@ -31,8 +32,9 @@ class ChowRing(QuotientRing_generic): A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M), - where `(I_M + J_M)` is the augmented Chow ring ideal of matroid `M` - of Feitchner-Yuzvinsky presentation. + where `(I_M + J_M)` is the :class:`augmented Chow ring ideal + ` of matroid `M` + in Feitchner-Yuzvinsky presentation. The *augmented Chow ring of atom-free presentation* is the quotient ring @@ -40,8 +42,9 @@ class ChowRing(QuotientRing_generic): A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_M^{af}, - where `I_M^{af}` is the augmented Chow ring ideal of matroid `M` in the - atom-free presentation. + where `I_M^{af}` is the :class:`augmented Chow ring ideal + ` + of matroid `M` in the atom-free presentation. .. SEEALSO:: From 8505fa7997e741b660a3e7a5e7ba2a25ec4e62ad Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 30 Sep 2024 13:09:43 +0530 Subject: [PATCH 087/167] Changed ChowRingIdeal_nonaug._gens_constructor() --- src/sage/matroids/chow_ring_ideal.py | 41 +++++++++++++++++++++------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 8785360f3b0..a8605323e17 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -76,8 +76,8 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): INPUT: - - `M` -- matroid - - `R` -- commutative ring + - ``M`` -- matroid + - ``R`` -- commutative ring REFERENCES: @@ -162,18 +162,39 @@ def _gens_constructor(self, poly_ring): Aa - Af + Aace + Aadg - Acfg - Adf - Aef] """ E = list(self._matroid.groundset()) - flats = list(self._flats_generator.keys()) + R = self.ring() + flats = list(self._flats_generator) + flats.append(E) flats_containing = {x: [] for x in E} for i,F in enumerate(flats): for x in F: flats_containing[x].append(i) - gens = poly_ring.gens() - Q = [gens[i] * gens[i+j+1] for i,F in enumerate(flats) - for j,G in enumerate(flats[i+1:]) if not (F < G or G < F)] #Quadratic Generators - L = [sum(gens[i] for i in flats_containing[x]) - - sum(gens[i] for i in flats_containing[y]) - for j,x in enumerate(E) for y in E[j+1:]] #Linear Generators - return Q + L + lattice_flats = self._matroid.lattice_of_flats() + subsets = [] + I = [] + # Generate all subsets of flats using combinations + for r in range(len(flats) + 1): # r is the size of the subset + subsets.extend(list(subset) for subset in combinations(flats, r)) + for subset in subsets: + flag = True + sorted_list = sorted(subset, key=len) + for i in range (len(sorted_list)): #Checking whether the subset is a chain + if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): + flag = False + break + if not flag: + term = R.one() + for el in subset: + self._flats_generator[el] + I.append(term) #Stanley-Reisner Ideal + atoms = lattice_flats.atoms() + J = [] + for a in atoms: + term = R.zero() + for F in flats_containing[a]: + term += self._flats_generator[F] + J.append(term) #Linear Generators + return I + J def _repr_(self): r""" From 9c928e2ce54262611194b06ffb6a6fa8ca0672fc Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 30 Sep 2024 13:19:34 +0530 Subject: [PATCH 088/167] Changed definition of the non aug ideal --- src/sage/matroids/chow_ring_ideal.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index a8605323e17..957d27047c5 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -54,7 +54,7 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): The Chow ring ideal of a matroid `M`. The *Chow ring ideal* for a matroid `M` is defined as the ideal - `(Q_M + L_M)` of the polynomial ring + `(I_M + J_M)` of the polynomial ring .. MATH:: @@ -63,16 +63,16 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): where - `F_1, \ldots, F_k` are the non-empty flats of `M`, - - `Q_M` is the ideal generated by all `x_{F_i} x_{F_j}`, where - `F_i` and `F_j` are incomparable elements in the lattice of - flats, and - - `L_M` is the ideal generated by all linear forms + - `I_M` is the Stanley-Reisner ideal, i.e., it is generated + by products `x_{F_1}, \ldots, x_{F_t}` for subsets `{F_1}, \ldots, {F_t}` + of flats that are not chains, and + - `J_M` is the ideal generated by all linear forms .. MATH:: - \sum_{i_1 \in F} x_F - \sum_{i_2 \in F} x_F + \sum_{a \in F} x_F - for all `i_1 \neq i_2 \in E`. + for all atoms `a` in the lattice of flats. INPUT: @@ -117,14 +117,14 @@ def __init__(self, M, R): self._flats_generator = dict(zip(flats, gens)) MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) - def _gens_constructor(self, poly_ring): + def _gens_constructor(self): r""" Return the generators of ``self``. EXAMPLES:: sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) - sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) + sage: ch.defining_ideal()._gens_constructor() [Aa*Ab, Aa*Ac, Aa*Ad, Aa*Ae, Aa*Af, Aa*Ag, Aa*Abcd, Aa*Abeg, Aa*Acfg, Aa*Ade, Aa*Adf, Aa*Aef, Ab*Ac, Ab*Ad, Ab*Ae, Ab*Af, Ab*Ag, Ab*Aace, Ab*Aadg, Ab*Acfg, Ab*Ade, Ab*Adf, Ab*Aef, Ac*Ad, Ac*Ae, @@ -178,7 +178,7 @@ def _gens_constructor(self, poly_ring): for subset in subsets: flag = True sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): #Checking whether the subset is a chain + for i in range (len(sorted_list)): #Checking whether the subset is not a chain if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): flag = False break From 03355c9b7e30124d7c5a59e201b945330eafb859 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 30 Sep 2024 13:27:06 +0530 Subject: [PATCH 089/167] Edited documentation of ideals file --- src/sage/matroids/chow_ring_ideal.py | 52 +++++++++++----------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 957d27047c5..6478a2f6fad 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -117,14 +117,14 @@ def __init__(self, M, R): self._flats_generator = dict(zip(flats, gens)) MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) - def _gens_constructor(self): + def _gens_constructor(self, poly_ring): r""" Return the generators of ``self``. EXAMPLES:: sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) - sage: ch.defining_ideal()._gens_constructor() + sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) [Aa*Ab, Aa*Ac, Aa*Ad, Aa*Ae, Aa*Af, Aa*Ag, Aa*Abcd, Aa*Abeg, Aa*Acfg, Aa*Ade, Aa*Adf, Aa*Aef, Ab*Ac, Ab*Ad, Ab*Ae, Ab*Af, Ab*Ag, Ab*Aace, Ab*Aadg, Ab*Acfg, Ab*Ade, Ab*Adf, Ab*Aef, Ac*Ad, Ac*Ae, @@ -162,7 +162,6 @@ def _gens_constructor(self): Aa - Af + Aace + Aadg - Acfg - Adf - Aef] """ E = list(self._matroid.groundset()) - R = self.ring() flats = list(self._flats_generator) flats.append(E) flats_containing = {x: [] for x in E} @@ -183,14 +182,14 @@ def _gens_constructor(self): flag = False break if not flag: - term = R.one() + term = poly_ring.one() for el in subset: self._flats_generator[el] I.append(term) #Stanley-Reisner Ideal atoms = lattice_flats.atoms() J = [] for a in atoms: - term = R.zero() + term = poly_ring.zero() for F in flats_containing[a]: term += self._flats_generator[F] J.append(term) #Linear Generators @@ -213,10 +212,8 @@ def _latex_(self): Return a LaTeX representation of ``self``. EXAMPLES:: - - sage: from sage.matroids.basis_matroid import BasisMatroid - sage: M1 = BasisMatroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, False) sage: ch.defining_ideal()._latex_() '\\left(\\mathit{Aac} \\mathit{Abd}, 0, @@ -533,30 +530,30 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): The augmented Chow ring ideal in the atom-free presentation for a matroid `M` is defined as the ideal - `I_{af}(M)` of the polynomial ring: + `I_{af}(M)` of the polynomial ring: - ..MATH:: + .. MATH:: R[x_{F_1}, \ldots, x_{F_k}] - as + where - `F_1, \ldots, F_k` are the non-empty flats of `M`, - `I_{af}M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` where `F_i` and `F_j` are incomparable elements in the lattice of - flats, + flats, - ..MATH:: + .. MATH:: - x_F \sum_{i \in F'} x_{F'} + x_F \sum_{i \in F'} x_{F'} - for all `i \in E` and `i \notin F`, and + for all `i \in E` and `i \notin F`, and - ..MATH:: + ..MATH:: - \sum_{i \in F'} (x_{F'})^2 + \sum_{i \in F'} (x_{F'})^2 - for all `i \in E`. + for all `i \in E`. REFERENCES: @@ -564,8 +561,8 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): INPUT: - - ``M`` -- a matroid - - ``R`` -- a commutative ring + - ``M`` -- matroid + - ``R`` -- commutative ring EXAMPLES: @@ -609,14 +606,11 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" - Return the generators of `self`. Takes in the ring of the augmented - Chow ring ideal as input. + Return the generators of ``self``. EXAMPLES:: - sage: from sage.matroids.graphic_matroid import GraphicMatroid - - sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) + sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) [A0^2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, A1^2, A0*A1, @@ -668,9 +662,7 @@ def _latex_(self): EXAMPLES:: - sage: from sage.matroids.basis_matroid import BasisMatroid - - sage: M1 = BasisMatroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: M1 = BMatroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._latex_() '\\left(\\mathit{Aac}^{2}, \\mathit{Abd}^{2}, @@ -697,9 +689,7 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): EXAMPLES:: - sage: from sage.matroids.graphic_matroid import GraphicMatroid - - sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) + sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal().groebner_basis(algorithm='') [A0^2, A0*A1, A0*A2, A0*A1, A1^2, A1*A2, A0*A2, A1*A2, A2^2] From 629baa2558284ca12d21f745800e20e1bbf44cba Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 3 Oct 2024 10:24:35 +0530 Subject: [PATCH 090/167] Formatted doctests in chow_ring.py --- src/sage/matroids/chow_ring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 7a69f289c7b..250fd427334 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -59,7 +59,7 @@ class ChowRing(QuotientRing_generic): - ``presentation`` -- string (default: ``None``); one of the following: * ``"fy"`` - the Feitchner-Yuzvinsky presentation - * ``"atom-free" - the atom-free presentation + * ``"atom-free"`` - the atom-free presentation REFERENCES: From cd3a3fcb17cf9045991a6a47783d8f90e2e4a600 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 3 Oct 2024 10:24:50 +0530 Subject: [PATCH 091/167] Formatted doctests in the ideals file --- src/sage/matroids/chow_ring_ideal.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 6478a2f6fad..bbba88b1261 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -351,7 +351,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): - ``M`` -- matroid - ``R`` -- commutative ring - EXAMPLES:: + EXAMPLES: Augmented Chow ring ideal of Wheel matroid of rank 3:: @@ -488,7 +488,7 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): True """ if algorithm == '': - gb = [] + gb = [] #Don't use flats. Get lattice of flats and use order_filter() E = list(self._matroid.groundset()) poly_ring = self.ring() for F in self._flats: @@ -498,10 +498,10 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): for i in E: term = poly_ring.zero() term1 = poly_ring.zero() - for H in self._flats: - if i in H: + for H in self._flats: #Remove it somehow + if i in H: #WASTEFUL term += self._flats_generator[H] - if H > G: + if H > G: #WASTEFUL term1 += self._flats_generator[H] if term != poly_ring.zero(): gb.append(self._flats_generator[i] + term) #5.7 @@ -683,7 +683,7 @@ def _latex_(self): for g in self.gens()), latex(self.ring())) - def groebner_basis(self, algorithm='constructed', *args, **kwargs): + def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from fy presentation """ Returns the Groebner basis of `self`. From bdfded838582644600ed80a8dd9fb1110148f672 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Fri, 4 Oct 2024 13:22:21 +0530 Subject: [PATCH 092/167] Corrected doctest outputs --- src/sage/matroids/chow_ring_ideal.py | 337 +++++++++++++-------------- 1 file changed, 163 insertions(+), 174 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index bbba88b1261..17945640495 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -10,12 +10,9 @@ from sage.matroids.utilities import cmp_elements_key from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence -from sage.misc.abstract_method import abstract_method -from itertools import combinations -from functools import reduce +from sage.combinat.posets.posets import Poset class ChowRingIdeal(MPolynomialIdeal): - @abstract_method def matroid(self): r""" Return the matroid of the given Chow ring ideal. @@ -40,11 +37,15 @@ def flats_generator(self): sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch.defining_ideal().flats_generator() {frozenset({'a'}): Aa, frozenset({'b'}): Ab, frozenset({'c'}): Ac, - frozenset({'d'}): Ad, frozenset({'e'}): Ae, frozenset({'f'}): Af, - frozenset({'g'}): Ag, frozenset({'b', 'a', 'f'}): Aabf, - frozenset({'c', 'e', 'a'}): Aace, frozenset({'d', 'g', 'a'}): Aadg, - frozenset({'c', 'b', 'd'}): Abcd, frozenset({'b', 'g', 'e'}): Abeg, - frozenset({'c', 'g', 'f'}): Acfg, frozenset({'d', 'e', 'f'}): Adef} + frozenset({'d'}): Ad, frozenset({'e'}): Ae, frozenset({'f'}): Af, + frozenset({'g'}): Ag, frozenset({'a', 'b', 'f'}): Aabf, + frozenset({'a', 'c', 'e'}): Aace, + frozenset({'a', 'd', 'g'}): Aadg, + frozenset({'b', 'c', 'd'}): Abcd, + frozenset({'b', 'e', 'g'}): Abeg, + frozenset({'c', 'f', 'g'}): Acfg, + frozenset({'d', 'e', 'f'}): Adef, + frozenset({'a', 'b', 'c', 'd', 'e', 'f', 'g'}): Aabcdefg} """ return dict(self._flats_generator) @@ -90,11 +91,11 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): sage: ch = matroids.Uniform(3,6).chow_ring(QQ, False) sage: ch.defining_ideal() Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with - circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} + circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} - non augmented sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch.defining_ideal() Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, - type (3, 0) + type (3, 0) - non augmented """ def __init__(self, M, R): r""" @@ -106,7 +107,7 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - flats = [X for i in range(1, self._matroid.rank()) + flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] try: @@ -125,74 +126,127 @@ def _gens_constructor(self, poly_ring): sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) - [Aa*Ab, Aa*Ac, Aa*Ad, Aa*Ae, Aa*Af, Aa*Ag, Aa*Abcd, Aa*Abeg, - Aa*Acfg, Aa*Ade, Aa*Adf, Aa*Aef, Ab*Ac, Ab*Ad, Ab*Ae, Ab*Af, Ab*Ag, - Ab*Aace, Ab*Aadg, Ab*Acfg, Ab*Ade, Ab*Adf, Ab*Aef, Ac*Ad, Ac*Ae, - Ac*Af, Ac*Ag, Ac*Aabf, Ac*Aadg, Ac*Abeg, Ac*Ade, Ac*Adf, Ac*Aef, - Ad*Ae, Ad*Af, Ad*Ag, Ad*Aabf, Ad*Aace, Ad*Abeg, Ad*Acfg, Ad*Aef, - Ae*Af, Ae*Ag, Ae*Aabf, Ae*Aadg, Ae*Abcd, Ae*Acfg, Ae*Adf, Af*Ag, - Af*Aace, Af*Aadg, Af*Abcd, Af*Abeg, Af*Ade, Ag*Aabf, Ag*Aace, - Ag*Abcd, Ag*Ade, Ag*Adf, Ag*Aef, Aabf*Aace, Aabf*Aadg, Aabf*Abcd, - Aabf*Abeg, Aabf*Acfg, Aabf*Ade, Aabf*Adf, Aabf*Aef, Aace*Aadg, - Aace*Abcd, Aace*Abeg, Aace*Acfg, Aace*Ade, Aace*Adf, Aace*Aef, - Aadg*Abcd, Aadg*Abeg, Aadg*Acfg, Aadg*Ade, Aadg*Adf, Aadg*Aef, - Abcd*Abeg, Abcd*Acfg, Abcd*Ade, Abcd*Adf, Abcd*Aef, Abeg*Acfg, - Abeg*Ade, Abeg*Adf, Abeg*Aef, Acfg*Ade, Acfg*Adf, Acfg*Aef, - Ade*Adf, Ade*Aef, Adf*Aef, - -Ab + Ae - Aabf + Aace - Abcd + Ade + Aef, - -Ac + Ae - Abcd + Abeg - Acfg + Ade + Aef, - Ae - Ag + Aace - Aadg - Acfg + Ade + Aef, - -Ad + Ae + Aace - Aadg - Abcd + Abeg - Adf + Aef, - -Aa + Ae - Aabf - Aadg + Abeg + Ade + Aef, - Ae - Af - Aabf + Aace + Abeg - Acfg + Ade - Adf, - Ab - Ac + Aabf - Aace + Abeg - Acfg, - Ab - Ag + Aabf - Aadg + Abcd - Acfg, - Ab - Ad + Aabf - Aadg + Abeg - Ade - Adf, - -Aa + Ab - Aace - Aadg + Abcd + Abeg, - Ab - Af + Abcd + Abeg - Acfg - Adf - Aef, - Ac - Ag + Aace - Aadg + Abcd - Abeg, - Ac - Ad + Aace - Aadg + Acfg - Ade - Adf, - -Aa + Ac - Aabf - Aadg + Abcd + Acfg, - Ac - Af - Aabf + Aace + Abcd - Adf - Aef, - -Ad + Ag - Abcd + Abeg + Acfg - Ade - Adf, - -Aa + Ag - Aabf - Aace + Abeg + Acfg, - -Af + Ag - Aabf + Aadg + Abeg - Adf - Aef, - -Aa + Ad - Aabf - Aace + Abcd + Ade + Adf, - Ad - Af - Aabf + Aadg + Abcd - Acfg + Ade - Aef, - Aa - Af + Aace + Aadg - Acfg - Adf - Aef] + [Aa*Ab, + Aa*Ac, + Aa*Ae, + Aa*Ad, + Aa*Ade, + Aa*Abcd, + Aa*Af, + Aa*Adf, + Aa*Aef, + Aa*Ag, + Aa*Abeg, + Aa*Acfg, + Ab*Ac, + Ab*Ae, + Ab*Aace, + Ab*Ad, + Ab*Ade, + Ab*Af, + Ab*Adf, + Ab*Aef, + Ab*Ag, + Ab*Aadg, + Ab*Acfg, + Ac*Ae, + Ac*Ad, + Ac*Ade, + Ac*Af, + Ac*Aabf, + Ac*Adf, + Ac*Aef, + Ac*Ag, + Ac*Aadg, + Ac*Abeg, + Ad*Ae, + Ae*Abcd, + Ae*Af, + Ae*Aabf, + Ae*Adf, + Ae*Ag, + Ae*Aadg, + Ae*Acfg, + Ad*Aace, + Aace*Ade, + Aace*Abcd, + Af*Aace, + Aabf*Aace, + Aace*Adf, + Aace*Aef, + Ag*Aace, + Aace*Aadg, + Aace*Abeg, + Aace*Acfg, + Ad*Af, + Ad*Aabf, + Ad*Aef, + Ad*Ag, + Ad*Abeg, + Ad*Acfg, + Abcd*Ade, + Af*Ade, + Aabf*Ade, + Ade*Adf, + Ade*Aef, + Ag*Ade, + Aadg*Ade, + Abeg*Ade, + Acfg*Ade, + Af*Abcd, + Aabf*Abcd, + Abcd*Adf, + Abcd*Aef, + Ag*Abcd, + Aadg*Abcd, + Abcd*Abeg, + Abcd*Acfg, + Af*Ag, + Af*Aadg, + Af*Abeg, + Aabf*Adf, + Aabf*Aef, + Ag*Aabf, + Aabf*Aadg, + Aabf*Abeg, + Aabf*Acfg, + Adf*Aef, + Ag*Adf, + Aadg*Adf, + Abeg*Adf, + Acfg*Adf, + Ag*Aef, + Aadg*Aef, + Abeg*Aef, + Acfg*Aef, + Aadg*Abeg, + Aadg*Acfg, + Abeg*Acfg, + Aa + Aabf + Aace + Aadg + Aabcdefg, + Ab + Aabf + Abcd + Abeg + Aabcdefg, + Ac + Aace + Abcd + Acfg + Aabcdefg, + Ad + Aadg + Abcd + Ade + Adf + Aabcdefg, + Ae + Aace + Abeg + Ade + Aef + Aabcdefg, + Af + Aabf + Acfg + Adf + Aef + Aabcdefg, + Ag + Aadg + Abeg + Acfg + Aabcdefg] """ - E = list(self._matroid.groundset()) flats = list(self._flats_generator) - flats.append(E) - flats_containing = {x: [] for x in E} - for i,F in enumerate(flats): - for x in F: - flats_containing[x].append(i) - lattice_flats = self._matroid.lattice_of_flats() - subsets = [] + reln = lambda x,y: x <= y + lattice_flats = Poset((flats, reln)) I = [] - # Generate all subsets of flats using combinations - for r in range(len(flats) + 1): # r is the size of the subset - subsets.extend(list(subset) for subset in combinations(flats, r)) + subsets = lattice_flats.antichains().elements_of_depth_iterator(2) for subset in subsets: - flag = True - sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): #Checking whether the subset is not a chain - if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): - flag = False - break - if not flag: - term = poly_ring.one() - for el in subset: - self._flats_generator[el] - I.append(term) #Stanley-Reisner Ideal - atoms = lattice_flats.atoms() - J = [] - for a in atoms: - term = poly_ring.zero() - for F in flats_containing[a]: - term += self._flats_generator[F] - J.append(term) #Linear Generators + term = poly_ring.one() + for el in subset: + term *= self._flats_generator[el] + I.append(term) #Stanley-Reisner Ideal + atoms = self._matroid.lattice_of_flats().atoms() + atoms_gen = {a:poly_ring.zero() for a in atoms} + for F in flats: + for a in atoms: + if a.issubset(F): + atoms_gen[a] += self._flats_generator[F] + J = list(atoms_gen.values()) #Linear Generators return I + J def _repr_(self): @@ -203,9 +257,9 @@ def _repr_(self): sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch.defining_ideal() - Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) - non augmented """ - return "Chow ring ideal of {}- non augmented".format(self._matroid) + return "Chow ring ideal of {} - non augmented".format(self._matroid) def _latex_(self): r""" @@ -216,17 +270,14 @@ def _latex_(self): sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, False) sage: ch.defining_ideal()._latex_() - '\\left(\\mathit{Aac} \\mathit{Abd}, 0, - \\mathit{Aac} - \\mathit{Abd}, \\mathit{Aac} - \\mathit{Abd}, - \\mathit{Aac} - \\mathit{Abd}, \\mathit{Aac} - \\mathit{Abd}, - 0\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' + '\\left(\\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} + \\mathit{Aabcd}, \\mathit{Abd} + \\mathit{Aabcd}\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}, \\mathit{Aabcd}]' """ from sage.misc.latex import latex return '\\left(%s\\right)%s' % (", ".join(latex(g) for g in self.gens()), latex(self.ring())) - def groebner_basis(self, algorithm='', *args, **kwargs): #can you reduce it? - consider every antichain of size 2, and chains? + def groebner_basis(self, algorithm='', *args, **kwargs): r""" Return a Groebner basis of ``self``. @@ -234,7 +285,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): #can you reduce it? - c sage: ch = Matroid(groundset='abc', bases=['ab', 'ac']).chow_ring(QQ, False) sage: ch.defining_ideal().groebner_basis() - [Aa, Abc] + [Aa*Abc, Aa*Aabc] sage: ch.defining_ideal().groebner_basis().is_groebner() True @@ -243,7 +294,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): #can you reduce it? - c sage: ch = Matroid(graphs.CycleGraph(3)).chow_ring(QQ, False) sage: ch.defining_ideal().groebner_basis() - [A0, A1, A2, A0*A1, A0*A2, A1*A2, A0*A1*A2] + [A0*A1, A0*A2, A1*A2, A0*A2 + A0*A3, A0*A3, A1*A3] sage: ch.defining_ideal().groebner_basis().is_groebner() True """ @@ -251,65 +302,25 @@ def groebner_basis(self, algorithm='', *args, **kwargs): #can you reduce it? - c algorithm = 'constructed' if algorithm != 'constructed': return super().groebner_basis(algorithm=algorithm, *args, **kwargs) - flats = list(self._flats_generator) + flats = sorted(list(self._flats_generator), key=len) gb = list() - R = self.ring() - if frozenset() in flats: - flats.remove(frozenset()) #Non-empty proper flats needed - - ranks = {F:self._matroid.rank(F) for F in flats} - + R = self.ring() + reln = lambda x,y: x<=y flats_gen = self._flats_generator - subsets = [] - # Generate all subsets of flats using combinations - for r in range(len(flats) + 1): # r is the size of the subset - subsets.extend(list(subset) for subset in combinations(flats, r)) - - for subset in subsets: - k = len(subset) - flag = True - sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): #Checking whether the subset is a chain - if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): - flag = False - break - - if not flag: - if k == 2: #Taking only antichains of length 2 - term = R.one() - for x in subset: - term *= flats_gen[x] - gb.append(term) - - else: - if k == 0: - for F in flats: - term = R.zero() - for G in flats: - if G >= F: - term += flats_gen[G] - gb.append((term)**(ranks[F])) - - else: - for i in range(len(subset)): - for j in range(i+1, len(subset)): #Checking if every element in the chain is maximal - if (sorted_list[i] != sorted_list[j]) & (sorted_list[i].issubset(sorted_list[j])): - flag = False - break - - if flag: - for F in flats: - if F > reduce(lambda a, b: a.union(b), sorted_list): - term = R.one() - for x in subset: - term *= flats_gen[x] - term1 = R.zero() - for G in flats: - if G >= F: - term1 += flats_gen[G] - if term1 != R.zero(): - gb.append(term*(term1**(ranks[F] - ranks[sorted_list[len(subset) - 1]]))) - + lattice_flats = Poset((flats, reln)) + antichains = lattice_flats.antichains().elements_of_depth_iterator(2) + for subset in antichains: #Taking antichains of size 2 + term = R.one() + for x in subset: + term *= flats_gen[x] + gb.append(term) + for i in range(len(flats)): #Reduced groebner basis by computing the sum first and then the product + term = R.zero() + for j in range(i+1, len(flats)): + term += flats_gen[flats[j]] + for j in range(i): + if term != R.zero(): + gb.append(flats_gen[flats[j]]*term) g_basis = PolynomialSequence(R, [gb]) return g_basis @@ -357,8 +368,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch.defining_ideal() - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on - 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation """ def __init__(self, M, R): r""" @@ -447,8 +457,7 @@ def _repr_(self): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch.defining_ideal() - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on - 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation """ return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) @@ -457,19 +466,12 @@ def _latex_(self): Return a LaTeX representation`self`. EXAMPLES:: - - sage: from sage.matroids.basis_matroid import BasisMatroid - sage: M1 = BasisMatroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, True, 'fy') sage: ch.defining_ideal()._latex_() - '\\left(\\mathit{Bac}^{2}, \\mathit{Bac} \\mathit{Bbd}, - \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bbd}^{2}, - \\mathit{Ad} - \\mathit{Bac}, \\mathit{Ab} - \\mathit{Bac}, - \\mathit{Aa} - \\mathit{Bbd}, \\mathit{Ac} - \\mathit{Bbd}\\right) - \\Bold{Q}[\\mathit{Ad}, \\mathit{Ab}, \\mathit{Aa}, \\mathit{Ac}, - \\mathit{Bac}, \\mathit{Bbd}]' - """ + '\\left(\\mathit{Bac}^{2}, \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bbd}^{2}, \\mathit{Aa} - \\mathit{Bbd}, \\mathit{Ab} - \\mathit{Bac}, \\mathit{Ac} - \\mathit{Bbd}, \\mathit{Ad} - \\mathit{Bac}\\right)\\Bold{Q}[\\mathit{Aa}, \\mathit{Ab}, \\mathit{Ac}, \\mathit{Ad}, \\mathit{Bac}, \\mathit{Bbd}]' + """ from sage.misc.latex import latex return '\\left(%s\\right)%s' % (", ".join(latex(g) for g in self.gens()), @@ -570,8 +572,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal() - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on - 6 elements with 16 bases of atom-free presentation + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases in the atom-free presentation """ def __init__(self, M, R): r""" @@ -651,8 +652,7 @@ def _repr_(self): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal() - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on - 6 elements with 16 bases of atom-free presentation + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases in the atom-free presentation """ return "Augmented Chow ring ideal of {} in the atom-free presentation".format(self._matroid) @@ -662,22 +662,11 @@ def _latex_(self): EXAMPLES:: - sage: M1 = BMatroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._latex_() - '\\left(\\mathit{Aac}^{2}, \\mathit{Abd}^{2}, - \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, - \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac}^{2}, - \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, - \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, - \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac}^{2}, - \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, - \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, - \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, - \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, - \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}\\right) - \\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' - """ + '\\left(\\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' + """ from sage.misc.latex import latex return '\\left(%s\\right)%s' % (", ".join(latex(g) for g in self.gens()), From 91bc8e082026d9ff28febddce6b2c12582c68ee3 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 5 Oct 2024 11:42:50 +0530 Subject: [PATCH 093/167] Corrected linting errors for ideals file --- src/sage/matroids/chow_ring_ideal.py | 69 ++++++++++++---------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 17945640495..e5ea38d3581 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -18,7 +18,7 @@ def matroid(self): Return the matroid of the given Chow ring ideal. EXAMPLES:: - + sage: ch = matroids.Uniform(3,6).chow_ring(QQ, False) sage: ch.defining_ideal().matroid() U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures @@ -26,7 +26,7 @@ def matroid(self): """ M = self._matroid return M - + def flats_generator(self): r""" Return the variables of every corresponding flat/groundset element @@ -48,15 +48,15 @@ def flats_generator(self): frozenset({'a', 'b', 'c', 'd', 'e', 'f', 'g'}): Aabcdefg} """ return dict(self._flats_generator) - -class ChowRingIdeal_nonaug(ChowRingIdeal): + +class ChowRingIdeal_nonaug(ChowRingIdeal): r""" The Chow ring ideal of a matroid `M`. The *Chow ring ideal* for a matroid `M` is defined as the ideal `(I_M + J_M)` of the polynomial ring - + .. MATH:: R[x_{F_1}, \ldots, x_{F_k}], @@ -74,7 +74,7 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): \sum_{a \in F} x_F for all atoms `a` in the lattice of flats. - + INPUT: - ``M`` -- matroid @@ -121,7 +121,7 @@ def __init__(self, M, R): def _gens_constructor(self, poly_ring): r""" Return the generators of ``self``. - + EXAMPLES:: sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) @@ -231,7 +231,7 @@ def _gens_constructor(self, poly_ring): Ag + Aadg + Abeg + Acfg + Aabcdefg] """ flats = list(self._flats_generator) - reln = lambda x,y: x <= y + reln = lambda x,y: x <= y lattice_flats = Poset((flats, reln)) I = [] subsets = lattice_flats.antichains().elements_of_depth_iterator(2) @@ -260,13 +260,13 @@ def _repr_(self): Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) - non augmented """ return "Chow ring ideal of {} - non augmented".format(self._matroid) - + def _latex_(self): r""" Return a LaTeX representation of ``self``. EXAMPLES:: - + sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, False) sage: ch.defining_ideal()._latex_() @@ -288,7 +288,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): [Aa*Abc, Aa*Aabc] sage: ch.defining_ideal().groebner_basis().is_groebner() True - + Another example would be the Groebner basis of the Chow ring ideal of the matroid of the length 3 cycle graph:: @@ -301,11 +301,11 @@ def groebner_basis(self, algorithm='', *args, **kwargs): if algorithm == '': algorithm = 'constructed' if algorithm != 'constructed': - return super().groebner_basis(algorithm=algorithm, *args, **kwargs) + return super().groebner_basis(algorithm=algorithm, *args, **kwargs) flats = sorted(list(self._flats_generator), key=len) gb = list() R = self.ring() - reln = lambda x,y: x<=y + reln = lambda x,y: x <= y flats_gen = self._flats_generator lattice_flats = Poset((flats, reln)) antichains = lattice_flats.antichains().elements_of_depth_iterator(2) @@ -324,7 +324,6 @@ def groebner_basis(self, algorithm='', *args, **kwargs): g_basis = PolynomialSequence(R, [gb]) return g_basis - class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" The augmented Chow ring ideal of matroid `M` over ring `R` in @@ -349,10 +348,10 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): .. MATH:: - y_i - \sum_{i \notin F} x_F + y_i - \sum_{i \notin F} x_F for all `i \in E`. - + REFERENCES: - [MM2022]_ @@ -395,8 +394,7 @@ def __init__(self, M, R): for i,F in enumerate(self._flats): self._flats_generator[F] = poly_ring.gens()[len(E) + i] MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) - - + def _gens_constructor(self, poly_ring): r""" Return the generators of ``self``. @@ -460,13 +458,13 @@ def _repr_(self): Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation """ return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) - + def _latex_(self): r""" Return a LaTeX representation`self`. EXAMPLES:: - + sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, True, 'fy') sage: ch.defining_ideal()._latex_() @@ -476,7 +474,7 @@ def _latex_(self): return '\\left(%s\\right)%s' % (", ".join(latex(g) for g in self.gens()), latex(self.ring())) - + def groebner_basis(self, algorithm='constructed', *args, **kwargs): r""" Returns the Groebner basis of `self`. @@ -513,10 +511,10 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): if i in G: #if element in flat if term1 != poly_ring.zero(): gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(G))) - - elif not i in G: #if element not in flat + + elif i not in G: #if element not in flat gb.append(self._flats_generator[i]*self._flats_generator[F]) - + elif G < F: #nested flats gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) @@ -544,7 +542,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): - `I_{af}M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` where `F_i` and `F_j` are incomparable elements in the lattice of flats, - + .. MATH:: x_F \sum_{i \in F'} x_{F'} @@ -573,7 +571,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal() Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases in the atom-free presentation - """ + """ def __init__(self, M, R): r""" Initialize ``self``. @@ -586,7 +584,7 @@ def __init__(self, M, R): self._matroid = M self._flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] - + E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} for i,F in enumerate(self._flats): @@ -603,7 +601,6 @@ def __init__(self, M, R): self._flats_generator = dict() self._flats_generator = dict(zip(self._flats, gens)) MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) - def _gens_constructor(self, poly_ring): r""" @@ -643,9 +640,8 @@ def _gens_constructor(self, poly_ring): for H in flats_containing[x]: term += self._flats_generator[H] Q.append(self._flats_generator[F]*term) - return Q - + def _repr_(self): r""" EXAMPLE:: @@ -666,12 +662,12 @@ def _latex_(self): sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._latex_() '\\left(\\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' - """ + """ from sage.misc.latex import latex return '\\left(%s\\right)%s' % (", ".join(latex(g) for g in self.gens()), latex(self.ring())) - + def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from fy presentation """ Returns the Groebner basis of `self`. @@ -707,11 +703,6 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis - - elif algorithm == 'constructed': - super().groebner_basis(*args, **kwargs) - - - - + elif algorithm == 'constructed': + super().groebner_basis(*args, **kwargs) \ No newline at end of file From b9556d861ab44798c74136ca2dca44cb6ad0aca2 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 5 Oct 2024 12:11:29 +0530 Subject: [PATCH 094/167] Corrected linting errors in ideals file --- src/sage/matroids/chow_ring_ideal.py | 137 ++++++--------------------- 1 file changed, 30 insertions(+), 107 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index e5ea38d3581..aff180557b0 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -126,102 +126,20 @@ def _gens_constructor(self, poly_ring): sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) - [Aa*Ab, - Aa*Ac, - Aa*Ae, - Aa*Ad, - Aa*Ade, - Aa*Abcd, - Aa*Af, - Aa*Adf, - Aa*Aef, - Aa*Ag, - Aa*Abeg, - Aa*Acfg, - Ab*Ac, - Ab*Ae, - Ab*Aace, - Ab*Ad, - Ab*Ade, - Ab*Af, - Ab*Adf, - Ab*Aef, - Ab*Ag, - Ab*Aadg, - Ab*Acfg, - Ac*Ae, - Ac*Ad, - Ac*Ade, - Ac*Af, - Ac*Aabf, - Ac*Adf, - Ac*Aef, - Ac*Ag, - Ac*Aadg, - Ac*Abeg, - Ad*Ae, - Ae*Abcd, - Ae*Af, - Ae*Aabf, - Ae*Adf, - Ae*Ag, - Ae*Aadg, - Ae*Acfg, - Ad*Aace, - Aace*Ade, - Aace*Abcd, - Af*Aace, - Aabf*Aace, - Aace*Adf, - Aace*Aef, - Ag*Aace, - Aace*Aadg, - Aace*Abeg, - Aace*Acfg, - Ad*Af, - Ad*Aabf, - Ad*Aef, - Ad*Ag, - Ad*Abeg, - Ad*Acfg, - Abcd*Ade, - Af*Ade, - Aabf*Ade, - Ade*Adf, - Ade*Aef, - Ag*Ade, - Aadg*Ade, - Abeg*Ade, - Acfg*Ade, - Af*Abcd, - Aabf*Abcd, - Abcd*Adf, - Abcd*Aef, - Ag*Abcd, - Aadg*Abcd, - Abcd*Abeg, - Abcd*Acfg, - Af*Ag, - Af*Aadg, - Af*Abeg, - Aabf*Adf, - Aabf*Aef, - Ag*Aabf, - Aabf*Aadg, - Aabf*Abeg, - Aabf*Acfg, - Adf*Aef, - Ag*Adf, - Aadg*Adf, - Abeg*Adf, - Acfg*Adf, - Ag*Aef, - Aadg*Aef, - Abeg*Aef, - Acfg*Aef, - Aadg*Abeg, - Aadg*Acfg, - Abeg*Acfg, + [Aa*Ab, Aa*Ac, Aa*Ae, Aa*Ad, Aa*Ade, Aa*Abcd, Aa*Af, Aa*Adf, + Aa*Aef, Aa*Ag, Aa*Abeg, Aa*Acfg, Ab*Ac, Ab*Ae, Ab*Aace, Ab*Ad, + Ab*Ade, Ab*Af, Ab*Adf, Ab*Aef, Ab*Ag, Ab*Aadg, Ab*Acfg, Ac*Ae, + Ac*Ad, Ac*Ade, Ac*Af, Ac*Aabf, Ac*Adf, Ac*Aef, Ac*Ag, Ac*Aadg, + Ac*Abeg, Ad*Ae, Ae*Abcd, Ae*Af, Ae*Aabf, Ae*Adf, Ae*Ag, Ae*Aadg, + Ae*Acfg, Ad*Aace, Aace*Ade, Aace*Abcd, Af*Aace, Aabf*Aace, + Aace*Adf, Aace*Aef, Ag*Aace, Aace*Aadg, Aace*Abeg, Aace*Acfg, + Ad*Af, Ad*Aabf, Ad*Aef, Ad*Ag, Ad*Abeg, Ad*Acfg, Abcd*Ade, Af*Ade, + Aabf*Ade, Ade*Adf, Ade*Aef, Ag*Ade, Aadg*Ade, Abeg*Ade, Acfg*Ade, + Af*Abcd, Aabf*Abcd, Abcd*Adf, Abcd*Aef, Ag*Abcd, Aadg*Abcd, + Abcd*Abeg, Abcd*Acfg, Af*Ag, Af*Aadg, Af*Abeg, Aabf*Adf, Aabf*Aef, + Ag*Aabf, Aabf*Aadg, Aabf*Abeg, Aabf*Acfg, Adf*Aef, Ag*Adf, + Aadg*Adf, Abeg*Adf, Acfg*Adf, Ag*Aef, Aadg*Aef, Abeg*Aef, + Acfg*Aef, Aadg*Abeg, Aadg*Acfg, Abeg*Acfg, Aa + Aabf + Aace + Aadg + Aabcdefg, Ab + Aabf + Abcd + Abeg + Aabcdefg, Ac + Aace + Abcd + Acfg + Aabcdefg, @@ -257,7 +175,8 @@ def _repr_(self): sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch.defining_ideal() - Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) - non augmented + Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, + type (3, 0) - non augmented """ return "Chow ring ideal of {} - non augmented".format(self._matroid) @@ -367,7 +286,8 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch.defining_ideal() - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 + elements with 16 bases of Feitchner-Yuzvinsky presentation """ def __init__(self, M, R): r""" @@ -455,7 +375,8 @@ def _repr_(self): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch.defining_ideal() - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases of Feitchner-Yuzvinsky presentation """ return "Augmented Chow ring ideal of {} of Feitchner-Yuzvinsky presentation".format(self._matroid) @@ -468,8 +389,8 @@ def _latex_(self): sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, True, 'fy') sage: ch.defining_ideal()._latex_() - '\\left(\\mathit{Bac}^{2}, \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bbd}^{2}, \\mathit{Aa} - \\mathit{Bbd}, \\mathit{Ab} - \\mathit{Bac}, \\mathit{Ac} - \\mathit{Bbd}, \\mathit{Ad} - \\mathit{Bac}\\right)\\Bold{Q}[\\mathit{Aa}, \\mathit{Ab}, \\mathit{Ac}, \\mathit{Ad}, \\mathit{Bac}, \\mathit{Bbd}]' - """ + '\\left(\\mathit{Bac}^{2}, \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bbd}^{2}, \\mathit{Ac} - \\mathit{Bbd}, \\mathit{Aa} - \\mathit{Bbd}, \\mathit{Ab} - \\mathit{Bac}, \\mathit{Ad} - \\mathit{Bac}\\right)\\Bold{Q}[\\mathit{Ac}, \\mathit{Aa}, \\mathit{Ab}, \\mathit{Ad}, \\mathit{Bac}, \\mathit{Bbd}]' + """ from sage.misc.latex import latex return '\\left(%s\\right)%s' % (", ".join(latex(g) for g in self.gens()), @@ -549,7 +470,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): for all `i \in E` and `i \notin F`, and - ..MATH:: + .. MATH:: \sum_{i \in F'} (x_{F'})^2 @@ -570,7 +491,8 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal() - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases in the atom-free presentation + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 + elements with 16 bases in the atom-free presentation """ def __init__(self, M, R): r""" @@ -648,10 +570,11 @@ def _repr_(self): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal() - Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases in the atom-free presentation + Augmented Chow ring ideal of Wheel(3): Regular matroid of rank 3 on + 6 elements with 16 bases in the atom-free presentation """ return "Augmented Chow ring ideal of {} in the atom-free presentation".format(self._matroid) - + def _latex_(self): r""" Return the LaTeX output of the ring and generators of `self`. @@ -661,7 +584,7 @@ def _latex_(self): sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._latex_() - '\\left(\\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' + '\\left(\\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' """ from sage.misc.latex import latex return '\\left(%s\\right)%s' % (", ".join(latex(g) @@ -698,7 +621,7 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f if H < F: term += self._flats_generator[H] if term != poly_ring.zero(): - gb.append(self._flats_generator[F]*(term**self._matroid.rank(G))* + gb.append(self._flats_generator[F]*(term ** self._matroid.rank(G))* (term**(self._matroid.rank(G)-self._matroid.rank(F)))) g_basis = PolynomialSequence(poly_ring, [gb]) From cfb1fbbfc5fe7b4fe2a673d9bed0bb5f9dbcfc44 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 5 Oct 2024 12:17:53 +0530 Subject: [PATCH 095/167] Corrected doctest output --- src/sage/matroids/chow_ring_ideal.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index aff180557b0..ced1ad7ed74 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -386,10 +386,10 @@ def _latex_(self): EXAMPLES:: - sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'fy') sage: ch.defining_ideal()._latex_() - '\\left(\\mathit{Bac}^{2}, \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bac} \\mathit{Bbd}, \\mathit{Bbd}^{2}, \\mathit{Ac} - \\mathit{Bbd}, \\mathit{Aa} - \\mathit{Bbd}, \\mathit{Ab} - \\mathit{Bac}, \\mathit{Ad} - \\mathit{Bac}\\right)\\Bold{Q}[\\mathit{Ac}, \\mathit{Aa}, \\mathit{Ab}, \\mathit{Ad}, \\mathit{Bac}, \\mathit{Bbd}]' + '\\left(A_{3}^{2}, A_{3} A_{4}, A_{3} A_{5}, A_{3} A_{4}, A_{4}^{2}, A_{4} A_{5}, A_{3} A_{5}, A_{4} A_{5}, A_{5}^{2}, A_{0} - A_{4} - A_{5}, A_{1} - A_{3} - A_{5}, A_{2} - A_{3} - A_{4}\\right)\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{5}]' """ from sage.misc.latex import latex return '\\left(%s\\right)%s' % (", ".join(latex(g) @@ -581,10 +581,10 @@ def _latex_(self): EXAMPLES:: - sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) + sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._latex_() - '\\left(\\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Aac}^{2}, \\mathit{Aac} \\mathit{Abd}, \\mathit{Abd}^{2}, \\mathit{Abd}^{2}\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}]' + '\\left(A_{0}^{2}, A_{0}^{2}, A_{1}^{2}, A_{0} A_{1}, A_{2}^{2}, A_{0} A_{2}, A_{0} A_{1}, A_{0}^{2}, A_{1}^{2}, A_{0} A_{1}, A_{2}^{2}, A_{0} A_{2}, A_{0} A_{2}, A_{0}^{2}, A_{1}^{2}, A_{0} A_{1}, A_{2}^{2}, A_{0} A_{2}, A_{0} A_{1}, A_{0}^{2}, A_{0} A_{1}, A_{1}^{2}, A_{2}^{2}, A_{1} A_{2}, A_{1}^{2}, A_{0}^{2}, A_{0} A_{1}, A_{1}^{2}, A_{2}^{2}, A_{1} A_{2}, A_{1} A_{2}, A_{0}^{2}, A_{0} A_{1}, A_{1}^{2}, A_{2}^{2}, A_{1} A_{2}, A_{0} A_{2}, A_{0}^{2}, A_{0} A_{2}, A_{1}^{2}, A_{1} A_{2}, A_{2}^{2}, A_{1} A_{2}, A_{0}^{2}, A_{0} A_{2}, A_{1}^{2}, A_{1} A_{2}, A_{2}^{2}, A_{2}^{2}, A_{0}^{2}, A_{0} A_{2}, A_{1}^{2}, A_{1} A_{2}, A_{2}^{2}\\right)\\Bold{Q}[A_{0}, A_{1}, A_{2}]' """ from sage.misc.latex import latex return '\\left(%s\\right)%s' % (", ".join(latex(g) From 231cb1f1aac55c9bb19b8efb117e68c716caa9aa Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 10:44:28 +0530 Subject: [PATCH 096/167] Corrected linting error --- src/sage/matroids/chow_ring_ideal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index ced1ad7ed74..240f8441269 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -622,7 +622,7 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f term += self._flats_generator[H] if term != poly_ring.zero(): gb.append(self._flats_generator[F]*(term ** self._matroid.rank(G))* - (term**(self._matroid.rank(G)-self._matroid.rank(F)))) + (term**(self._matroid.rank(G) - self._matroid.rank(F)))) g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis From 7b60d5167bf170474965f37ce335019688665a30 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 10:51:14 +0530 Subject: [PATCH 097/167] Resolved linting errors --- src/sage/matroids/chow_ring.py | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 250fd427334..348eb7b33ac 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -48,8 +48,8 @@ class ChowRing(QuotientRing_generic): .. SEEALSO:: - :mod:`sage.matroids.chow_ring_ideal` - + :mod:`sage.matroids.chow_ring_ideal + INPUT: - ``M`` -- matroid @@ -57,7 +57,7 @@ class ChowRing(QuotientRing_generic): - ``augmented`` -- boolean; when ``True``, this is the augmented Chow ring and if ``False``, this is the non-augmented Chow ring - ``presentation`` -- string (default: ``None``); one of the following: - + * ``"fy"`` - the Feitchner-Yuzvinsky presentation * ``"atom-free"`` - the atom-free presentation @@ -112,7 +112,7 @@ def _repr_(self): return "Augmented Chow ring of {} in Feitchner-Yuzvinsky presentation".format(self._matroid) elif self._presentation == 'atom-free': return "Augmented Chow ring of {} in atom-free presentation".format(self._matroid) - return "Chow ring of {}".format(self._matroid) + return "Chow ring of {}".format(self._matroid) def _latex_(self): r""" @@ -121,7 +121,7 @@ def _latex_(self): EXAMPLES:: sage: from sage.matroids.graphic_matroid import GraphicMatroid - + sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'fy') sage: ch._latex_() @@ -150,7 +150,7 @@ def _coerce_map_from_base_ring(self): def basis(self): r""" Return the monomial basis of the given Chow ring. - + EXAMPLES:: sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, True, 'fy') @@ -177,7 +177,7 @@ def basis(self): for subset in subsets: flag = True sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): #Taking only chains + for i in range(len(sorted_list)): #Taking only chains if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): flag = False break @@ -204,7 +204,7 @@ def basis(self): #Generating combinations for all powers including first max_powers expression *= flats_gen[subset[0]]**max_powers[0] monomial_basis.append(expression) - + elif self._presentation == 'atom-free': subsets = [] # Generate all subsets of the frozenset using combinations @@ -213,7 +213,7 @@ def basis(self): for subset in subsets: flag = True sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): #Taking only chains + for i in range(len(sorted_list)): #Taking only chains if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): flag = False break @@ -238,7 +238,7 @@ def basis(self): expression = R.one() if sum(combination) == first_rank: for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] + expression *= flats_gen[subset[i]]**combination[i] monomial_basis.append(expression) max_powers.remove(last_rank) for p in max_powers: @@ -248,13 +248,13 @@ def basis(self): expression = R.one() if sum(combination) == first_rank: for i in range(len(combination)): - expression *= flats_gen[subset[i]]**combination[i] + expression *= flats_gen[subset[i]]**combination[i] monomial_basis.append(expression) else: expression *= flats_gen[subset[k-1]]**last_rank if sum(combination) + last_rank == first_rank: for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] + expression *= flats_gen[subset[i]]**combination[i] monomial_basis.append(expression) else: @@ -267,7 +267,7 @@ def basis(self): for subset in subsets: flag = True sorted_list = sorted(subset, key=len) - for i in range (len(sorted_list)): + for i in range(len(sorted_list)): if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): flag = False break @@ -278,7 +278,7 @@ def basis(self): if k == 0: monomial_basis.append(R.one()) elif k == 1 & ranks[subset[0]] == 1: - monomial_basis.append(flats_gen[subset[0]]) + monomial_basis.append(flats_gen[subset[0]]) else: for i in range(k): if i == 0: @@ -290,10 +290,9 @@ def basis(self): for combination in product(*(range(1, p))): expression = R.one() for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] + expression *= flats_gen[subset[i]]**combination[i] monomial_basis.append(expression) - from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) @@ -369,10 +368,10 @@ def homogeneous_degree(self): ValueError: element is not homogeneous TESTS:: - + sage: ch = matroids.Wheel(3).chow_ring(QQ, False) sage: ch.zero().homogeneous_degree() - Traceback (most recent call last): + Traceback (most recent call last): ... ValueError: the zero element does not have a well-defined degree """ From 12e8d932c1c9cc2a75b1002701790f824d9f0659 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 11:03:35 +0530 Subject: [PATCH 098/167] Optimized basis() method for all 3 cases --- src/sage/matroids/chow_ring.py | 195 +++++++++++++-------------------- 1 file changed, 78 insertions(+), 117 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 348eb7b33ac..fe2fc0ee0a4 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -11,6 +11,7 @@ from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.categories.commutative_rings import CommutativeRings from itertools import product, combinations +from sage.combinat.posets.posets import Poset class ChowRing(QuotientRing_generic): r""" @@ -122,15 +123,10 @@ def _latex_(self): sage: from sage.matroids.graphic_matroid import GraphicMatroid - sage: M1 = GraphicMatroid(graphs.CycleGraph(3)) - sage: ch = M1.chow_ring(QQ, True, 'fy') + sage: M1 = matroids.Uniform(2,5) + sage: ch = M1.chow_ring(QQ, False) sage: ch._latex_() - \Bold{Q}[A_{0}, A_{1}, A_{2}, B_{0}, B_{1}, B_{2}]/\left(B_{0}^{2}, - B_{0} B_{1}, B_{0} B_{2}, B_{0} B_{1}, B_{1}^{2}, B_{1} B_{2}, - B_{0} B_{2}, B_{1} B_{2}, B_{2}^{2}, A_{0} - B_{1} - B_{2}, - A_{1} - B_{0} - B_{2}, A_{2} - B_{0} - B_{1}\right) - \Bold{Q}[A_{0}, A_{1}, A_{2}, B_{0}, B_{1}, B_{2}] - + '\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{01234}] / \\left(A_{0} A_{1}, A_{0} A_{2}, A_{0} A_{3}, A_{0} A_{4}, A_{1} A_{2}, A_{1} A_{3}, A_{1} A_{4}, A_{2} A_{3}, A_{2} A_{4}, A_{3} A_{4}, A_{0} + A_{01234}, A_{1} + A_{01234}, A_{2} + A_{01234}, A_{3} + A_{01234}, A_{4} + A_{01234}\\right)\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{01234}]' """ from sage.misc.latex import latex return "{} / {}".format(latex(self._ideal.ring()), latex(self._ideal)) @@ -160,138 +156,103 @@ def basis(self): [A0*A013, 1] """ flats = [X for i in range(1, self._matroid.rank()) - for X in self._matroid.flats(i)] + for X in self._matroid.flats(i)] #Non empty proper flats flats_gen = self._ideal.flats_generator() R = self._ideal.ring() flats = sorted(flats, key=lambda X: (len(X), sorted(X))) ranks = {F: self._matroid.rank(F) for F in flats} monomial_basis = [] + reln = lambda x,y: x <= y + lattice_flats = Poset((flats, reln)) + chains = lattice_flats.chains() #Only chains if self._augmented: if self._presentation == 'fy': - if frozenset() in flats: - flats.remove(frozenset()) #Non empty proper flats - subsets = [] - # Generate all subsets of the frozenset using combinations - for r in range(len(flats) + 1): # r is the size of the subset - subsets.extend(list(subset) for subset in combinations(flats, r)) - for subset in subsets: - flag = True - sorted_list = sorted(subset, key=len) - for i in range(len(sorted_list)): #Taking only chains - if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): - flag = False - break - if flag: - k = len(subset) - if k == 0: - monomial_basis.append(R.one()) - elif k == 1 & ranks[subset[0]] == 1: - monomial_basis.append(flats_gen[subset[0]]) - else: - max_powers = [] - max_powers.append(ranks[subset[0]]) - for i in range(1, k): - max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - for p in max_powers: - if p != 1 & p != 0: - for combination in product(*(range(1, p))): - #Generating combinations for all powers up to max_powers - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - if max_powers.index(p) == 0: - #Generating combinations for all powers including first max_powers - expression *= flats_gen[subset[0]]**max_powers[0] - monomial_basis.append(expression) - - elif self._presentation == 'atom-free': - subsets = [] - # Generate all subsets of the frozenset using combinations - for r in range(len(flats) + 1): # r is the size of the subset - subsets.extend(list(subset) for subset in combinations(flats, r)) - for subset in subsets: - flag = True - sorted_list = sorted(subset, key=len) - for i in range(len(sorted_list)): #Taking only chains - if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): - flag = False - break - if flag: #For every chain + for subset in chains: + k = len(subset) + if k == 0: + monomial_basis.append(R.one()) + elif k == 1 & ranks[subset[0]] == 1: + monomial_basis.append(flats_gen[subset[0]]) + else: max_powers = [] - k = len(subset) - if subset == []: - monomial_basis.append(R.one()) - else: - for i in range(k-1): - if i == 0: - max_powers.append(ranks[subset[i]]) - else: - max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - max_powers.append(ranks[subset[k-1]]) - first_rank = ranks[subset[0]] + 1 - last_rank = ranks[subset[k-1]] - for p in max_powers: - if p != 1 & p != 0: - for combination in product(*(range(1, p))): - #Generating combinations for all powers from 1 to max_powers - expression = R.one() - if sum(combination) == first_rank: - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - max_powers.remove(last_rank) - for p in max_powers: - if p != 1 & p != 0: - for combination in product(*(range(1, p))): - #Generating all combinations including 0 power and max_power for first flat + max_powers.append(ranks[subset[0]]) + for i in range(1, k): + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + for p in max_powers: + if p != 1 & p != 0: + for combination in product(*(range(1, p))): + #Generating combinations for all powers up to max_powers expression = R.one() - if sum(combination) == first_rank: - for i in range(len(combination)): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - else: - expression *= flats_gen[subset[k-1]]**last_rank - if sum(combination) + last_rank == first_rank: - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + if max_powers.index(p) == 0: + #Generating combinations for all powers including first max_powers + expression *= flats_gen[subset[0]]**max_powers[0] monomial_basis.append(expression) - else: - if frozenset() in flats: - flats.remove(frozenset()) #Non empty proper flats - subsets = [] - # Generate all subsets of the frozenset using combinations - for r in range(len(flats) + 1): # r is the size of the subset - subsets.extend(list(subset) for subset in combinations(flats, r)) - for subset in subsets: - flag = True - sorted_list = sorted(subset, key=len) - for i in range(len(sorted_list)): - if (i != 0) & (len(sorted_list[i]) == len(sorted_list[i-1])): - flag = False - break - - if flag: + elif self._presentation == 'atom-free': + for subset in chains: max_powers = [] k = len(subset) - if k == 0: + if subset == []: monomial_basis.append(R.one()) - elif k == 1 & ranks[subset[0]] == 1: - monomial_basis.append(flats_gen[subset[0]]) else: - for i in range(k): + for i in range(k-1): if i == 0: max_powers.append(ranks[subset[i]]) else: max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + max_powers.append(ranks[subset[k-1]]) + first_rank = ranks[subset[0]] + 1 + last_rank = ranks[subset[k-1]] for p in max_powers: if p != 1 & p != 0: for combination in product(*(range(1, p))): + #Generating combinations for all powers from 1 to max_powers expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) + if sum(combination) == first_rank: + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + max_powers.remove(last_rank) + for p in max_powers: + if p != 1 & p != 0: + for combination in product(*(range(1, p))): + #Generating all combinations including 0 power and max_power for first flat + expression = R.one() + if sum(combination) == first_rank: + for i in range(len(combination)): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + else: + expression *= flats_gen[subset[k-1]]**last_rank + if sum(combination) + last_rank == first_rank: + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + + else: + for subset in chains: + max_powers = [] + k = len(subset) + if k == 0: + monomial_basis.append(R.one()) + elif k == 1 & ranks[subset[0]] == 1: + monomial_basis.append(flats_gen[subset[0]]) + else: + for i in range(k): + if i == 0: + max_powers.append(ranks[subset[i]]) + else: + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + for p in max_powers: + if p != 1 & p != 0: + for combination in product(*(range(1, p))): + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) From 6a72bd39477c26a7c80bc6320e58a85cf54e4060 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 11:23:31 +0530 Subject: [PATCH 099/167] Corrected doctests for Element() subclass --- src/sage/matroids/chow_ring.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index fe2fc0ee0a4..f6aa75f21f0 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -152,8 +152,13 @@ def basis(self): sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, True, 'fy') sage: ch.basis() [B0*B01, 1] - sage: ch = matroids.Wheel(3).chow_ring(ZZ, False) + sage: len(ch.defining_ideal().normal_basis()) == ch.basis().cardinality() + True + sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) [A0*A013, 1] + sage: len(ch.defining_ideal().normal_basis()) == ch.basis().cardinality() + True + """ flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] #Non empty proper flats @@ -268,6 +273,7 @@ def to_vector(self, order=None): sage: v = ch.an_element(); v A0 sage: v.to_vector() + (0, 0, 0, 1, 0, 0, 0) """ P = self.parent() B = P.basis() @@ -285,8 +291,9 @@ def monomial_coefficients(self, copy=None): sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'fy') sage: v = ch.an_element(); v - 0 + Ag sage: v.monomial_coefficients() + {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0} """ B = self.parent().basis() f = self.lift() @@ -301,11 +308,16 @@ def degree(self): sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, False) sage: for b in ch.basis(): ....: print(b, b.degree()) - A0*A01 2 1 0 + A1 1 + A3 1 + A0 1 + A2 1 + A4 1 + A5 1 sage: v = sum(ch.basis()) sage: v.degree() - 2 + 1 """ return self.lift().degree() @@ -316,13 +328,19 @@ def homogeneous_degree(self): EXAMPLES:: - ch = matroids.catalog.Fano().chow_ring(QQ, True, 'fy') + sage: ch = matroids.catalog.Fano().chow_ring(QQ, True, 'fy') sage: for b in ch.basis(): ....: print(b, b.homogeneous_degree()) - Ba*Babf 2 - Ba^2 2 + 1 0 + Bb 1 + Ba 1 + Bc 1 + Bd 1 + Be 1 + Bf 1 + Bg 1 sage: v = sum(ch.basis()); v - Ba^2 + Ba*Babf + Ba + Bb + Bc + Bd + Be + Bf + Bg + 1 sage: v.homogeneous_degree() Traceback (most recent call last): ... From 31b7afb9d9e6dfef43671b2b319b32496b0ecc64 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 11:33:14 +0530 Subject: [PATCH 100/167] Corrected linting errors in ideals file --- src/sage/matroids/chow_ring_ideal.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 240f8441269..64643e76ac4 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -621,8 +621,7 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f if H < F: term += self._flats_generator[H] if term != poly_ring.zero(): - gb.append(self._flats_generator[F]*(term ** self._matroid.rank(G))* - (term**(self._matroid.rank(G) - self._matroid.rank(F)))) + gb.append(self._flats_generator[F]*(term ** self._matroid.rank(G))*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis From e36e4ea50a943ccf77d88716d3a6a90e5db115aa Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 11:33:35 +0530 Subject: [PATCH 101/167] Corrected linting errors in chow_ring.py --- src/sage/matroids/chow_ring.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index f6aa75f21f0..694fd5b29ed 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -113,7 +113,7 @@ def _repr_(self): return "Augmented Chow ring of {} in Feitchner-Yuzvinsky presentation".format(self._matroid) elif self._presentation == 'atom-free': return "Augmented Chow ring of {} in atom-free presentation".format(self._matroid) - return "Chow ring of {}".format(self._matroid) + return "Chow ring of {}".format(self._matroid) def _latex_(self): r""" @@ -244,7 +244,7 @@ def basis(self): if k == 0: monomial_basis.append(R.one()) elif k == 1 & ranks[subset[0]] == 1: - monomial_basis.append(flats_gen[subset[0]]) + monomial_basis.append(flats_gen[subset[0]]) else: for i in range(k): if i == 0: From 92219477d3ba88c655909d48bb46fd0da24d4571 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 11:34:35 +0530 Subject: [PATCH 102/167] Corrected linting errors in ideals file --- src/sage/matroids/chow_ring_ideal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 64643e76ac4..0cd09de5e12 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -621,7 +621,7 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f if H < F: term += self._flats_generator[H] if term != poly_ring.zero(): - gb.append(self._flats_generator[F]*(term ** self._matroid.rank(G))*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) + gb.append(self._flats_generator[F]*(term**self._matroid.rank(G))*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis From 4156022e9b81f2b3387752fb2a6939bd195d7962 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 11:43:03 +0530 Subject: [PATCH 103/167] Tested ideals file --- src/sage/matroids/chow_ring_ideal.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 0cd09de5e12..bf00e70d992 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -609,8 +609,6 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f flats = [X for i in range(1, self._matroid.rank()) for X in self._matroid.flats(i)] poly_ring = self.ring() - if frozenset() in flats: #Non empty proper flats - flats.remove(frozenset()) for F in flats: for G in flats: if not (F > G or G > F): #Non nested flats From 35fd32b2769952e2b99c7c9f49925620f451de91 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 11:47:43 +0530 Subject: [PATCH 104/167] Corrected basis() method --- src/sage/matroids/chow_ring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 694fd5b29ed..b04c5e54598 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -161,7 +161,7 @@ def basis(self): """ flats = [X for i in range(1, self._matroid.rank()) - for X in self._matroid.flats(i)] #Non empty proper flats + for X in self._matroid.flats(i)] #Non empty flats flats_gen = self._ideal.flats_generator() R = self._ideal.ring() flats = sorted(flats, key=lambda X: (len(X), sorted(X))) From 7710eb594fdc942477f09949332a0bd277dae3c3 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 7 Oct 2024 11:50:54 +0530 Subject: [PATCH 105/167] Fixed linting error in matroid.pyx --- src/sage/matroids/matroid.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 6999c30252a..310580e1d18 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8054,14 +8054,14 @@ cdef class Matroid(SageObject): sage: M = matroids.catalog.Fano() sage: A = M.chow_ring(QQ, augmented=False); A Chow ring of Fano: Binary matroid of rank 3 on 7 elements, - type (3, 0) over Rational Field. + type (3, 0) over Rational Field. The augmented Chow ring can also be constructed with the Feitchner-Yuzvinsky and atom-free presentation:: sage: M = matroids.Wheel(3) sage: ch = M.chow_ring(QQ, augmented=True, presentation='fy') - Augmented Chow ring of Wheel(3): Regular matroid of rank 3 on + Augmented Chow ring of Wheel(3): Regular matroid of rank 3 on 6 elements with 16 bases of Feitchner-Yuzvinsky presentation sage: M = matroids.Uniform(3, 6) sage: ch = M.chow_ring(QQ, augmented=True, presentation='atom-free') From d15176e222e95bebc1a356ac0d8fda18eb579ab7 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 9 Oct 2024 09:59:55 +0530 Subject: [PATCH 106/167] Edited basis() method --- src/sage/matroids/chow_ring.py | 77 +++++++++++++++------------------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index b04c5e54598..d8ad6a638d8 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -160,7 +160,7 @@ def basis(self): True """ - flats = [X for i in range(1, self._matroid.rank()) + flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] #Non empty flats flats_gen = self._ideal.flats_generator() R = self._ideal.ring() @@ -184,8 +184,8 @@ def basis(self): for i in range(1, k): max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) for p in max_powers: - if p != 1 & p != 0: - for combination in product(*(range(1, p))): + if p != 1 | p != 0: + for combination in product((range(1, p))): #Generating combinations for all powers up to max_powers expression = R.one() for i in range(k): @@ -203,61 +203,52 @@ def basis(self): if subset == []: monomial_basis.append(R.one()) else: - for i in range(k-1): + for i in range(k): if i == 0: max_powers.append(ranks[subset[i]]) else: max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - max_powers.append(ranks[subset[k-1]]) - first_rank = ranks[subset[0]] + 1 - last_rank = ranks[subset[k-1]] - for p in max_powers: - if p != 1 & p != 0: - for combination in product(*(range(1, p))): - #Generating combinations for all powers from 1 to max_powers - expression = R.one() - if sum(combination) == first_rank: - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - max_powers.remove(last_rank) - for p in max_powers: - if p != 1 & p != 0: - for combination in product(*(range(1, p))): - #Generating all combinations including 0 power and max_power for first flat - expression = R.one() - if sum(combination) == first_rank: - for i in range(len(combination)): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - else: - expression *= flats_gen[subset[k-1]]**last_rank - if sum(combination) + last_rank == first_rank: - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) + first_rank = ranks[subset[k-1]] + 1 + last_rank = ranks[subset[0]] + for combination in product(*(range(1, p) for p in max_powers)): + #Generating combinations for all powers from 1 to max_powers + if sum(combination) == first_rank: + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + max_powers[0] = 0 + for combination in product(*(range(1, p) for p in max_powers)): + #Generating all combinations including 0 power and max_power for first flat + if sum(combination) == first_rank: + expression = R.one() + for i in range(len(combination)): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + else: + expression *= flats_gen[subset[0]]**last_rank + if sum(combination) + last_rank == first_rank: + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) else: for subset in chains: max_powers = [] k = len(subset) - if k == 0: + if (k == 0): monomial_basis.append(R.one()) - elif k == 1 & ranks[subset[0]] == 1: - monomial_basis.append(flats_gen[subset[0]]) - else: + elif not ((k == 1) & (ranks[subset[0]] == 1)): for i in range(k): if i == 0: max_powers.append(ranks[subset[i]]) else: max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - for p in max_powers: - if p != 1 & p != 0: - for combination in product(*(range(1, p))): - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) + for combination in product(*(range(1, p) for p in max_powers)): + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) from sage.sets.family import Family return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) From 7614be81c52020057d82e727959dbb04af9e9c7f Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 9 Oct 2024 10:00:22 +0530 Subject: [PATCH 107/167] Edited definition of augmented Chow ring ideal for both presentations --- src/sage/matroids/chow_ring_ideal.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index bf00e70d992..5b8cc0d1d74 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -299,7 +299,7 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - self._flats = [X for i in range(1, self._matroid.rank()) + self._flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) self._flats_generator = dict() @@ -347,7 +347,6 @@ def _gens_constructor(self, poly_ring): A3 - B0 - B1 - B2 - B4 - B5 - B025 - B04 - B124 - B15, A4 - B0 - B1 - B2 - B3 - B5 - B013 - B025 - B15 - B23, A5 - B0 - B1 - B2 - B3 - B4 - B013 - B04 - B124 - B23] - """ E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} @@ -504,7 +503,7 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - self._flats = [X for i in range(1, self._matroid.rank()) + self._flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) @@ -606,16 +605,14 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f """ if algorithm == '': gb = [] - flats = [X for i in range(1, self._matroid.rank()) - for X in self._matroid.flats(i)] poly_ring = self.ring() - for F in flats: - for G in flats: + for F in self._flats: + for G in self._flats: if not (F > G or G > F): #Non nested flats gb.append(self._flats_generator[F]*self._flats_generator[G]) elif F < G: #Nested flats term = poly_ring.zero() - for H in flats: + for H in self._flats: if H < F: term += self._flats_generator[H] if term != poly_ring.zero(): From d54f0cba7f459d1c9d47af67865b1029b9e58b66 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 13 Oct 2024 19:36:57 +0530 Subject: [PATCH 108/167] Changed defn of augmented Chow ring ideal FY presentation --- src/sage/matroids/chow_ring_ideal.py | 32 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 5b8cc0d1d74..8ee112abc23 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -192,9 +192,7 @@ def _latex_(self): '\\left(\\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} + \\mathit{Aabcd}, \\mathit{Abd} + \\mathit{Aabcd}\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}, \\mathit{Aabcd}]' """ from sage.misc.latex import latex - return '\\left(%s\\right)%s' % (", ".join(latex(g) - for g in self.gens()), - latex(self.ring())) + return 'I_{M} + J_{M} of matroid ' + (latex(self._matroid)) def groebner_basis(self, algorithm='', *args, **kwargs): r""" @@ -299,7 +297,7 @@ def __init__(self, M, R): sage: TestSuite(I).run(skip="_test_category") """ self._matroid = M - self._flats = [X for i in range(1, self._matroid.rank() + 1) + self._flats = [X for i in range(self._matroid.rank() + 1) for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) self._flats_generator = dict() @@ -355,17 +353,23 @@ def _gens_constructor(self, poly_ring): flats_containing[x].append(F) Q = list() + L = list() + term = poly_ring.zero() for F in self._flats: + term += self._flats_generator[F] for G in self._flats: if not (F < G or G < F): Q.append(self._flats_generator[F] * self._flats_generator[G]) #Quadratic Generators - L = list() + L.append(term) + for x in E: term = poly_ring.zero() for F in self._flats: if F not in flats_containing[x]: + Q.append(self._flats_generator[x] * self._flats_generator[F]) + else: term += self._flats_generator[F] - L.append(self._flats_generator[x] - term) #Linear Generators + L.append(self._flats_generator[x] + term) #Linear Generators return Q + L def _repr_(self): @@ -408,25 +412,26 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): True """ if algorithm == '': - gb = [] #Don't use flats. Get lattice of flats and use order_filter() + gb = [] E = list(self._matroid.groundset()) poly_ring = self.ring() for F in self._flats: for G in self._flats: if not (F < G or G < F): #Non-nested flats gb.append(self._flats_generator[F]*self._flats_generator[G]) + for i in E: term = poly_ring.zero() term1 = poly_ring.zero() - for H in self._flats: #Remove it somehow - if i in H: #WASTEFUL + for H in self._flats: + if i in H: term += self._flats_generator[H] - if H > G: #WASTEFUL + if H > G: term1 += self._flats_generator[H] if term != poly_ring.zero(): gb.append(self._flats_generator[i] + term) #5.7 if term1 != poly_ring.zero(): - gb.append(term1**(self._matroid.rank(G)) + 1) #5.6 + gb.append(term1**(self._matroid.rank(F) + 1)) #5.6 if i in G: #if element in flat if term1 != poly_ring.zero(): @@ -435,8 +440,9 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): elif i not in G: #if element not in flat gb.append(self._flats_generator[i]*self._flats_generator[F]) - elif G < F: #nested flats - gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) + if G < F: #nested flats + if term1 != poly_ring.zero(): + gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis From d2720e3d984dfa42a7b8b1c07e4f3d6213e20161 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 15 Oct 2024 10:15:09 +0530 Subject: [PATCH 109/167] Debugged basis() method for atom-free case --- src/sage/matroids/chow_ring.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index d8ad6a638d8..a4f01221007 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -170,6 +170,8 @@ def basis(self): reln = lambda x,y: x <= y lattice_flats = Poset((flats, reln)) chains = lattice_flats.chains() #Only chains + for ch in chains: + print(ch) if self._augmented: if self._presentation == 'fy': for subset in chains: From f296378e98a8efe30a2b15555f4374d2035ac554 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 15 Oct 2024 10:15:34 +0530 Subject: [PATCH 110/167] Optimized definition of atom-free presentation --- src/sage/matroids/chow_ring_ideal.py | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 8ee112abc23..72b2b73107e 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -426,7 +426,7 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): for H in self._flats: if i in H: term += self._flats_generator[H] - if H > G: + if H >= G: term1 += self._flats_generator[H] if term != poly_ring.zero(): gb.append(self._flats_generator[i] + term) #5.7 @@ -511,21 +511,12 @@ def __init__(self, M, R): self._matroid = M self._flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] - - E = list(self._matroid.groundset()) - flats_containing = {x: [] for x in E} - for i,F in enumerate(self._flats): - for x in F: - flats_containing[x].append(i) - names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] - try: poly_ring = PolynomialRing(R, names) #self.ring except ValueError: # variables are not proper names poly_ring = PolynomialRing(R, 'A', len(self._flats)) gens = poly_ring.gens() - self._flats_generator = dict() self._flats_generator = dict(zip(self._flats, gens)) MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) @@ -556,17 +547,15 @@ def _gens_constructor(self, poly_ring): for G in self._flats: if not (G > F or F > G): #generators for every pair of non-nested flats Q.append(self._flats_generator[F]*self._flats_generator[G]) - for x in E: #generators for every set of flats containing element - term = poly_ring.zero() - for H in flats_containing[x]: - term += self._flats_generator[H] + for x in E: #generators for every set of flats containing element + term = poly_ring.zero() + for H in flats_containing[x]: + term += self._flats_generator[H] + if term**2 not in Q: Q.append(term**2) - if F not in flats_containing[x]: #generators for every set of flats not containing element - term = poly_ring.zero() - for H in flats_containing[x]: - term += self._flats_generator[H] - Q.append(self._flats_generator[F]*term) + if F not in flats_containing[x]: #generators for every set of flats not containing element + Q.append(self._flats_generator[F]*term) return Q def _repr_(self): From ab57cd98f70715ea96bfed1ca19a558b77842bc9 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 15 Oct 2024 11:49:27 +0530 Subject: [PATCH 111/167] Debugged groebner_basis() --- src/sage/matroids/chow_ring_ideal.py | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 72b2b73107e..29e4977d293 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -237,7 +237,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): term += flats_gen[flats[j]] for j in range(i): if term != R.zero(): - gb.append(flats_gen[flats[j]]*term) + gb.append(flats_gen[flats[j]]*(term)**(self._matroid.rank(flats[i]) - self._matroid.rank(flats[j]))) g_basis = PolynomialSequence(R, [gb]) return g_basis @@ -358,7 +358,7 @@ def _gens_constructor(self, poly_ring): for F in self._flats: term += self._flats_generator[F] for G in self._flats: - if not (F < G or G < F): + if not (F <= G or G < F): Q.append(self._flats_generator[F] * self._flats_generator[G]) #Quadratic Generators L.append(term) @@ -417,7 +417,7 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): poly_ring = self.ring() for F in self._flats: for G in self._flats: - if not (F < G or G < F): #Non-nested flats + if not (F <= G or G <= F): #Non-nested flats gb.append(self._flats_generator[F]*self._flats_generator[G]) for i in E: @@ -431,18 +431,18 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): if term != poly_ring.zero(): gb.append(self._flats_generator[i] + term) #5.7 if term1 != poly_ring.zero(): - gb.append(term1**(self._matroid.rank(F) + 1)) #5.6 + gb.append(term1**(self._matroid.rank(G) + 1)) #5.6 if i in G: #if element in flat if term1 != poly_ring.zero(): gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(G))) elif i not in G: #if element not in flat - gb.append(self._flats_generator[i]*self._flats_generator[F]) + gb.append(self._flats_generator[i]*self._flats_generator[G]) - if G < F: #nested flats + if G > F: #nested flats if term1 != poly_ring.zero(): - gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F)-self._matroid.rank(G))) + gb.append(self._flats_generator[F]*term1**(self._matroid.rank(G)-self._matroid.rank(F))) g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis @@ -545,7 +545,7 @@ def _gens_constructor(self, poly_ring): flats_containing[x].append(F) for F in self._flats: for G in self._flats: - if not (G > F or F > G): #generators for every pair of non-nested flats + if not (G >= F or F > G): #generators for every pair of non-nested flats Q.append(self._flats_generator[F]*self._flats_generator[G]) for x in E: #generators for every set of flats containing element term = poly_ring.zero() @@ -603,15 +603,16 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f poly_ring = self.ring() for F in self._flats: for G in self._flats: - if not (F > G or G > F): #Non nested flats + term = poly_ring.zero() + for H in self._flats: + if H < F: + term += self._flats_generator[H] + if not (F >= G or G > F): #Non nested flats gb.append(self._flats_generator[F]*self._flats_generator[G]) elif F < G: #Nested flats - term = poly_ring.zero() - for H in self._flats: - if H < F: - term += self._flats_generator[H] if term != poly_ring.zero(): - gb.append(self._flats_generator[F]*(term**self._matroid.rank(G))*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) + gb.append(self._flats_generator[F]*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) + gb.append((term**self._matroid.rank(F)) + 1) g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis From 8b2d98ff362f102b9dfd30df1e569a83947f31c7 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 15 Oct 2024 11:49:42 +0530 Subject: [PATCH 112/167] Debugged basis() --- src/sage/matroids/chow_ring.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index a4f01221007..5877567d87c 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -170,8 +170,6 @@ def basis(self): reln = lambda x,y: x <= y lattice_flats = Poset((flats, reln)) chains = lattice_flats.chains() #Only chains - for ch in chains: - print(ch) if self._augmented: if self._presentation == 'fy': for subset in chains: @@ -195,7 +193,7 @@ def basis(self): monomial_basis.append(expression) if max_powers.index(p) == 0: #Generating combinations for all powers including first max_powers - expression *= flats_gen[subset[0]]**max_powers[0] + expression *= flats_gen[subset[0]]**ranks[flats[0]] monomial_basis.append(expression) elif self._presentation == 'atom-free': @@ -222,7 +220,7 @@ def basis(self): max_powers[0] = 0 for combination in product(*(range(1, p) for p in max_powers)): #Generating all combinations including 0 power and max_power for first flat - if sum(combination) == first_rank: + if sum(combination) <= first_rank: expression = R.one() for i in range(len(combination)): expression *= flats_gen[subset[i]]**combination[i] From 5fea8af41a7f393f0a2770641970e2c2d919a119 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 10:12:49 +0530 Subject: [PATCH 113/167] Debugged groebner_basis() for all 3 ideals --- src/sage/matroids/chow_ring_ideal.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 29e4977d293..0d95e59f30a 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -220,6 +220,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): if algorithm != 'constructed': return super().groebner_basis(algorithm=algorithm, *args, **kwargs) flats = sorted(list(self._flats_generator), key=len) + ranks = {F: self._matroid.rank(F) for F in flats} gb = list() R = self.ring() reln = lambda x,y: x <= y @@ -231,13 +232,12 @@ def groebner_basis(self, algorithm='', *args, **kwargs): for x in subset: term *= flats_gen[x] gb.append(term) - for i in range(len(flats)): #Reduced groebner basis by computing the sum first and then the product + for F in flats: #Reduced groebner basis by computing the sum first and then the product term = R.zero() - for j in range(i+1, len(flats)): - term += flats_gen[flats[j]] - for j in range(i): - if term != R.zero(): - gb.append(flats_gen[flats[j]]*(term)**(self._matroid.rank(flats[i]) - self._matroid.rank(flats[j]))) + for G in lattice_flats.order_filter([F]): + term += flats_gen[G] + for G in lattice_flats.order_ideal([F]): + gb.append(flats_gen[G]*(term)**(ranks[F] - ranks[G])) g_basis = PolynomialSequence(R, [gb]) return g_basis From 283a45bf7d731d9a9d786f77318fe674d059a947 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 11:28:09 +0530 Subject: [PATCH 114/167] Corrected doctests --- src/sage/matroids/chow_ring_ideal.py | 226 +++++++++++++++------------ 1 file changed, 125 insertions(+), 101 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 0d95e59f30a..2953ecd4dc6 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -189,7 +189,7 @@ def _latex_(self): sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, False) sage: ch.defining_ideal()._latex_() - '\\left(\\mathit{Aac} \\mathit{Abd}, \\mathit{Aac} + \\mathit{Aabcd}, \\mathit{Abd} + \\mathit{Aabcd}\\right)\\Bold{Q}[\\mathit{Aac}, \\mathit{Abd}, \\mathit{Aabcd}]' + I_{M} + J_{M} of matroid \text{\texttt{Matroid{ }of{ }rank{ }2{ }on{ }4{ }elements{ }with{ }3{ }bases}} """ from sage.misc.latex import latex return 'I_{M} + J_{M} of matroid ' + (latex(self._matroid)) @@ -202,7 +202,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): sage: ch = Matroid(groundset='abc', bases=['ab', 'ac']).chow_ring(QQ, False) sage: ch.defining_ideal().groebner_basis() - [Aa*Abc, Aa*Aabc] + [Aa*Abc, Aa, Abc, Aa*Aabc, Abc*Aabc, Aabc] sage: ch.defining_ideal().groebner_basis().is_groebner() True @@ -211,7 +211,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): sage: ch = Matroid(graphs.CycleGraph(3)).chow_ring(QQ, False) sage: ch.defining_ideal().groebner_basis() - [A0*A1, A0*A2, A1*A2, A0*A2 + A0*A3, A0*A3, A1*A3] + [A0*A1, A0*A2, A1*A2, A0, A1, A2, A0*A3, A1*A3, A2*A3, A3] sage: ch.defining_ideal().groebner_basis().is_groebner() True """ @@ -246,8 +246,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): The augmented Chow ring ideal of matroid `M` over ring `R` in Feitchner-Yuzvinsky presentation. - The augmented Chow ring ideal in the Feitchner-Yuzvinsky presentation - for a matroid `M` is defined as the ideal + The augmented Chow ring ideal for a matroid `M` is defined as the ideal `(I_M + J_M)` of the following polynomial ring .. MATH:: @@ -256,7 +255,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): where - - `F_1, \ldots, F_k` are the flats of `M`, + - `F_1, \ldots, F_k` are the proper flats of `M`, - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}`, where `F_i` and `F_j` are incomparable elements in the lattice of @@ -268,7 +267,38 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): y_i - \sum_{i \notin F} x_F for all `i \in E`. + + The augmented Chow ring ideal in the Feitchner Yuzvinsky presentation + for a simple matroid `M` is defined as the ideal + `(I_{FY}(M))` of the following polynomial ring + + .. MATH:: + + R[y_{e_1}, \ldots, y_{e_n}, y_{F_1 \union e}, \ldots, y_{F_k \union e}], + + where + + - `F_1, \ldots, F_k` are the flats of `M`, + - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, + - `I_{FY}(M) is the ideal generated by all quadratic forms + `y_{F_i \union e} y_{F_j \union e}`, where `F_i` and `F_j` + are incomparable elements in the lattice of flats, `y_{i} y_{F \union e}` + for every `i \in E` and `i \notin F`, linear forms + + .. MATH:: + y_i + \sum_{i \in F} y_{F \union e} + + for all `i \in E` and, + + .. MATH:: + + \sum_{F} y_{F \union e}. + + Setting `x_F = y_{F \union e}` and using the last linear + form to eliminate `x_E` recovers the usual presentation of + augmented Chow ring of M. + REFERENCES: - [MM2022]_ @@ -321,30 +351,37 @@ def _gens_constructor(self, poly_ring): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) - [B0^2, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B124, B0*B15, B0*B23, - B0*B345, B0*B1, B1^2, B1*B2, B1*B3, B1*B4, B1*B5, B1*B025, B1*B04, - B1*B23, B1*B345, B0*B2, B1*B2, B2^2, B2*B3, B2*B4, B2*B5, B2*B013, - B2*B04, B2*B15, B2*B345, B0*B3, B1*B3, B2*B3, B3^2, B3*B4, B3*B5, - B3*B025, B3*B04, B3*B124, B3*B15, B0*B4, B1*B4, B2*B4, B3*B4, B4^2, - B4*B5, B4*B013, B4*B025, B4*B15, B4*B23, B0*B5, B1*B5, B2*B5, - B3*B5, B4*B5, B5^2, B5*B013, B5*B04, B5*B124, B5*B23, B2*B013, - B4*B013, B5*B013, B013^2, B013*B025, B013*B04, B013*B124, B013*B15, - B013*B23, B013*B345, B1*B025, B3*B025, B4*B025, B013*B025, B025^2, - B025*B04, B025*B124, B025*B15, B025*B23, B025*B345, B1*B04, B2*B04, - B3*B04, B5*B04, B013*B04, B025*B04, B04^2, B04*B124, B04*B15, - B04*B23, B04*B345, B0*B124, B3*B124, B5*B124, B013*B124, B025*B124, - B04*B124, B124^2, B124*B15, B124*B23, B124*B345, B0*B15, B2*B15, - B3*B15, B4*B15, B013*B15, B025*B15, B04*B15, B124*B15, B15^2, - B15*B23, B15*B345, B0*B23, B1*B23, B4*B23, B5*B23, B013*B23, - B025*B23, B04*B23, B124*B23, B15*B23, B23^2, B23*B345, B0*B345, - B1*B345, B2*B345, B013*B345, B025*B345, B04*B345, B124*B345, - B15*B345, B23*B345, B345^2, - A0 - B1 - B2 - B3 - B4 - B5 - B124 - B15 - B23 - B345, - A1 - B0 - B2 - B3 - B4 - B5 - B025 - B04 - B23 - B345, - A2 - B0 - B1 - B3 - B4 - B5 - B013 - B04 - B15 - B345, - A3 - B0 - B1 - B2 - B4 - B5 - B025 - B04 - B124 - B15, - A4 - B0 - B1 - B2 - B3 - B5 - B013 - B025 - B15 - B23, - A5 - B0 - B1 - B2 - B3 - B4 - B013 - B04 - B124 - B23] + [B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B124, B0*B15, B0*B23, + B0*B345, B0*B1, B1*B2, B1*B3, B1*B4, B1*B5, B1*B025, B1*B04, + B1*B23, B1*B345, B0*B2, B1*B2, B2*B3, B2*B4, B2*B5, B2*B013, + B2*B04, B2*B15, B2*B345, B0*B3, B1*B3, B2*B3, B3*B4, B3*B5, + B3*B025, B3*B04, B3*B124, B3*B15, B0*B4, B1*B4, B2*B4, B3*B4, + B4*B5, B4*B013, B4*B025, B4*B15, B4*B23, B0*B5, B1*B5, B2*B5, + B3*B5, B4*B5, B5*B013, B5*B04, B5*B124, B5*B23, B2*B013, B4*B013, + B5*B013, B013*B025, B013*B04, B013*B124, B013*B15, B013*B23, + B013*B345, B1*B025, B3*B025, B4*B025, B013*B025, B025*B04, + B025*B124, B025*B15, B025*B23, B025*B345, B1*B04, B2*B04, B3*B04, + B5*B04, B013*B04, B025*B04, B04*B124, B04*B15, B04*B23, B04*B345, + B0*B124, B3*B124, B5*B124, B013*B124, B025*B124, B04*B124, + B124*B15, B124*B23, B124*B345, B0*B15, B2*B15, B3*B15, B4*B15, + B013*B15, B025*B15, B04*B15, B124*B15, B15*B23, B15*B345, B0*B23, + B1*B23, B4*B23, B5*B23, B013*B23, B025*B23, B04*B23, B124*B23, + B15*B23, B23*B345, B0*B345, B1*B345, B2*B345, B013*B345, + B025*B345, B04*B345, B124*B345, B15*B345, B23*B345, A0*B, A0*B1, + A0*B2, A0*B3, A0*B4, A0*B5, A0*B124, A0*B15, A0*B23, A0*B345, + A1*B, A1*B0, A1*B2, A1*B3, A1*B4, A1*B5, A1*B025, A1*B04, A1*B23, + A1*B345, A2*B, A2*B0, A2*B1, A2*B3, A2*B4, A2*B5, A2*B013, A2*B04, + A2*B15, A2*B345, A3*B, A3*B0, A3*B1, A3*B2, A3*B4, A3*B5, A3*B025, + A3*B04, A3*B124, A3*B15, A4*B, A4*B0, A4*B1, A4*B2, A4*B3, A4*B5, + A4*B013, A4*B025, A4*B15, A4*B23, A5*B, A5*B0, A5*B1, A5*B2, + A5*B3, A5*B4, A5*B013, A5*B04, A5*B124, A5*B23, + B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, + A0 + B0 + B013 + B025 + B04 + B012345, + A1 + B1 + B013 + B124 + B15 + B012345, + A2 + B2 + B025 + B124 + B23 + B012345, + A3 + B3 + B013 + B23 + B345 + B012345, + A4 + B4 + B04 + B124 + B345 + B012345, + A5 + B5 + B025 + B15 + B345 + B012345] """ E = list(self._matroid.groundset()) flats_containing = {x: [] for x in E} @@ -392,12 +429,10 @@ def _latex_(self): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'fy') sage: ch.defining_ideal()._latex_() - '\\left(A_{3}^{2}, A_{3} A_{4}, A_{3} A_{5}, A_{3} A_{4}, A_{4}^{2}, A_{4} A_{5}, A_{3} A_{5}, A_{4} A_{5}, A_{5}^{2}, A_{0} - A_{4} - A_{5}, A_{1} - A_{3} - A_{5}, A_{2} - A_{3} - A_{4}\\right)\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{5}]' + I_{FY} of matroid \text{\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}} """ from sage.misc.latex import latex - return '\\left(%s\\right)%s' % (", ".join(latex(g) - for g in self.gens()), - latex(self.ring())) + return 'I_{FY} of matroid ' + (latex(self._matroid)) def groebner_basis(self, algorithm='constructed', *args, **kwargs): r""" @@ -407,47 +442,41 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): sage: ch = matroids.Uniform(2,5).chow_ring(QQ, True, 'fy') sage: ch.defining_ideal().groebner_basis(algorithm='') - Polynomial Sequence with 250 Polynomials in 10 Variables + Polynomial Sequence with 565 Polynomials in 12 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True """ if algorithm == '': - gb = [] - E = list(self._matroid.groundset()) - poly_ring = self.ring() - for F in self._flats: - for G in self._flats: - if not (F <= G or G <= F): #Non-nested flats - gb.append(self._flats_generator[F]*self._flats_generator[G]) - - for i in E: - term = poly_ring.zero() - term1 = poly_ring.zero() - for H in self._flats: - if i in H: - term += self._flats_generator[H] - if H >= G: - term1 += self._flats_generator[H] - if term != poly_ring.zero(): - gb.append(self._flats_generator[i] + term) #5.7 - if term1 != poly_ring.zero(): - gb.append(term1**(self._matroid.rank(G) + 1)) #5.6 - - if i in G: #if element in flat - if term1 != poly_ring.zero(): - gb.append(self._flats_generator[i]*((term1)**self._matroid.rank(G))) - - elif i not in G: #if element not in flat - gb.append(self._flats_generator[i]*self._flats_generator[G]) + algorithm = 'constructed' + if algorithm != 'constructed': + return super().groebner_basis(algorithm=algorithm, *args, **kwargs) + gb = [] #Reduced groebner basis with two eliminated cases + E = list(self._matroid.groundset()) + poly_ring = self.ring() + for F in self._flats: + for G in self._flats: + if not (F <= G or G <= F): #Non-nested flats + gb.append(self._flats_generator[F]*self._flats_generator[G]) - if G > F: #nested flats - if term1 != poly_ring.zero(): - gb.append(self._flats_generator[F]*term1**(self._matroid.rank(G)-self._matroid.rank(F))) + for i in E: + term = poly_ring.zero() + term1 = poly_ring.zero() + for H in self._flats: + if i in H: + term += self._flats_generator[H] + if H >= G: + term1 += self._flats_generator[H] + if term != poly_ring.zero(): + gb.append(self._flats_generator[i] + term) #5.7 + if term1 != poly_ring.zero(): + gb.append(term1**(self._matroid.rank(G) + 1)) #5.6 + + if G > F: #nested flats + if term1 != poly_ring.zero(): + gb.append(self._flats_generator[F]*term1**(self._matroid.rank(G)-self._matroid.rank(F))) - g_basis = PolynomialSequence(poly_ring, [gb]) - return g_basis - elif algorithm == 'constructed': - super().groebner_basis(*args, **kwargs) + g_basis = PolynomialSequence(poly_ring, [gb]) + return g_basis class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): r""" @@ -529,13 +558,10 @@ def _gens_constructor(self, poly_ring): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) - [A0^2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, A1^2, A0*A1, - A2^2, A0*A2, A0*A2, A0^2, A1^2, A0*A1, A2^2, A0*A2, A0*A1, A0^2, - A0*A1, A1^2, A2^2, A1*A2, A1^2, A0^2, A0*A1, A1^2, A2^2, A1*A2, - A1*A2, A0^2, A0*A1, A1^2, A2^2, A1*A2, A0*A2, A0^2, A0*A2, A1^2, - A1*A2, A2^2, A1*A2, A0^2, A0*A2, A1^2, A1*A2, A2^2, A2^2, A0^2, - A0*A2, A1^2, A1*A2, A2^2] - + [A0*A1, A0*A2, A0^2 + 2*A0*A3 + A3^2, A1^2 + 2*A1*A3 + A3^2, + A0*A1 + A0*A3, A2^2 + 2*A2*A3 + A3^2, A0*A2 + A0*A3, + A0*A1, A1*A2, A0*A1 + A1*A3, A1*A2 + A1*A3, A0*A2, A1*A2, + A0*A2 + A2*A3, A1*A2 + A2*A3] """ E = list(self._matroid.groundset()) Q = [] #Quadratic Generators @@ -578,12 +604,10 @@ def _latex_(self): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._latex_() - '\\left(A_{0}^{2}, A_{0}^{2}, A_{1}^{2}, A_{0} A_{1}, A_{2}^{2}, A_{0} A_{2}, A_{0} A_{1}, A_{0}^{2}, A_{1}^{2}, A_{0} A_{1}, A_{2}^{2}, A_{0} A_{2}, A_{0} A_{2}, A_{0}^{2}, A_{1}^{2}, A_{0} A_{1}, A_{2}^{2}, A_{0} A_{2}, A_{0} A_{1}, A_{0}^{2}, A_{0} A_{1}, A_{1}^{2}, A_{2}^{2}, A_{1} A_{2}, A_{1}^{2}, A_{0}^{2}, A_{0} A_{1}, A_{1}^{2}, A_{2}^{2}, A_{1} A_{2}, A_{1} A_{2}, A_{0}^{2}, A_{0} A_{1}, A_{1}^{2}, A_{2}^{2}, A_{1} A_{2}, A_{0} A_{2}, A_{0}^{2}, A_{0} A_{2}, A_{1}^{2}, A_{1} A_{2}, A_{2}^{2}, A_{1} A_{2}, A_{0}^{2}, A_{0} A_{2}, A_{1}^{2}, A_{1} A_{2}, A_{2}^{2}, A_{2}^{2}, A_{0}^{2}, A_{0} A_{2}, A_{1}^{2}, A_{1} A_{2}, A_{2}^{2}\\right)\\Bold{Q}[A_{0}, A_{1}, A_{2}]' + I_{af} of matroid \text{\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}} """ from sage.misc.latex import latex - return '\\left(%s\\right)%s' % (", ".join(latex(g) - for g in self.gens()), - latex(self.ring())) + return 'I_{af} of matroid ' + latex(self._matroid) def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from fy presentation """ @@ -594,28 +618,28 @@ def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from f sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal().groebner_basis(algorithm='') - [A0^2, A0*A1, A0*A2, A0*A1, A1^2, A1*A2, A0*A2, A1*A2, A2^2] + Polynomial Sequence with 22 Polynomials in 3 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True """ if algorithm == '': - gb = [] - poly_ring = self.ring() - for F in self._flats: - for G in self._flats: - term = poly_ring.zero() - for H in self._flats: - if H < F: - term += self._flats_generator[H] - if not (F >= G or G > F): #Non nested flats - gb.append(self._flats_generator[F]*self._flats_generator[G]) - elif F < G: #Nested flats - if term != poly_ring.zero(): - gb.append(self._flats_generator[F]*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) - gb.append((term**self._matroid.rank(F)) + 1) - - g_basis = PolynomialSequence(poly_ring, [gb]) - return g_basis - - elif algorithm == 'constructed': - super().groebner_basis(*args, **kwargs) \ No newline at end of file + algorithm = 'constructed' + if algorithm != 'constructed': + return super().groebner_basis(algorithm=algorithm, *args, **kwargs) + gb = [] + poly_ring = self.ring() + for F in self._flats: + for G in self._flats: + term = poly_ring.zero() + for H in self._flats: + if H < F: + term += self._flats_generator[H] + if not (F >= G or G > F): #Non nested flats + gb.append(self._flats_generator[F]*self._flats_generator[G]) + elif F < G: #Nested flats + if term != poly_ring.zero(): + gb.append(self._flats_generator[F]*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) + gb.append((term**self._matroid.rank(F)) + 1) + + g_basis = PolynomialSequence(poly_ring, [gb]) + return g_basis \ No newline at end of file From 058252f285cca18aecb82adb151369aa7e9e8f01 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 12:15:34 +0530 Subject: [PATCH 115/167] Debugged basis() for FY presentation of the augmented Chow ring --- src/sage/matroids/chow_ring.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 5877567d87c..b9dee33c6fa 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -176,25 +176,19 @@ def basis(self): k = len(subset) if k == 0: monomial_basis.append(R.one()) - elif k == 1 & ranks[subset[0]] == 1: - monomial_basis.append(flats_gen[subset[0]]) else: max_powers = [] max_powers.append(ranks[subset[0]]) for i in range(1, k): max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - for p in max_powers: - if p != 1 | p != 0: - for combination in product((range(1, p))): - #Generating combinations for all powers up to max_powers - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - if max_powers.index(p) == 0: - #Generating combinations for all powers including first max_powers - expression *= flats_gen[subset[0]]**ranks[flats[0]] - monomial_basis.append(expression) + ranges = [range(1, p) for p in max_powers] + ranges[0] = range(1, max_powers[0] + 1) + for combination in product(*(r for r in ranges)): + #Generating combinations for all powers up to max_powers + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) elif self._presentation == 'atom-free': for subset in chains: From 1922a1a0c768a5b465dcfaf1e817fe650051feb7 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 12:27:37 +0530 Subject: [PATCH 116/167] Debugged basis() for augmented Chow ring for both presentations --- src/sage/matroids/chow_ring.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index b9dee33c6fa..72904bbd5a4 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -202,29 +202,16 @@ def basis(self): max_powers.append(ranks[subset[i]]) else: max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + ranges = [range(1, p) for p in max_powers] + ranges[0] = range(1, max_powers[0] + 1) first_rank = ranks[subset[k-1]] + 1 - last_rank = ranks[subset[0]] - for combination in product(*(range(1, p) for p in max_powers)): + for combination in product(*(r for r in ranges)): #Generating combinations for all powers from 1 to max_powers - if sum(combination) == first_rank: - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - max_powers[0] = 0 - for combination in product(*(range(1, p) for p in max_powers)): - #Generating all combinations including 0 power and max_power for first flat if sum(combination) <= first_rank: expression = R.one() - for i in range(len(combination)): + for i in range(k): expression *= flats_gen[subset[i]]**combination[i] monomial_basis.append(expression) - else: - expression *= flats_gen[subset[0]]**last_rank - if sum(combination) + last_rank == first_rank: - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) else: for subset in chains: From 1d2e204660974f3fd6c650f5782605a8f121aef2 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 12:57:33 +0530 Subject: [PATCH 117/167] Corrected linting errors --- src/sage/matroids/chow_ring_ideal.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 2953ecd4dc6..6eb14139828 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -267,7 +267,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): y_i - \sum_{i \notin F} x_F for all `i \in E`. - + The augmented Chow ring ideal in the Feitchner Yuzvinsky presentation for a simple matroid `M` is defined as the ideal `(I_{FY}(M))` of the following polynomial ring @@ -280,7 +280,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): - `F_1, \ldots, F_k` are the flats of `M`, - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - - `I_{FY}(M) is the ideal generated by all quadratic forms + - `I_{FY}(M) is the ideal generated by all quadratic forms `y_{F_i \union e} y_{F_j \union e}`, where `F_i` and `F_j` are incomparable elements in the lattice of flats, `y_{i} y_{F \union e}` for every `i \in E` and `i \notin F`, linear forms @@ -288,17 +288,17 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): .. MATH:: y_i + \sum_{i \in F} y_{F \union e} - + for all `i \in E` and, .. MATH:: \sum_{F} y_{F \union e}. - + Setting `x_F = y_{F \union e}` and using the last linear form to eliminate `x_E` recovers the usual presentation of augmented Chow ring of M. - + REFERENCES: - [MM2022]_ @@ -609,7 +609,7 @@ def _latex_(self): from sage.misc.latex import latex return 'I_{af} of matroid ' + latex(self._matroid) - def groebner_basis(self, algorithm='constructed', *args, **kwargs): #Copy from fy presentation + def groebner_basis(self, algorithm='constructed', *args, **kwargs): """ Returns the Groebner basis of `self`. From 49276c192bd3127392962c8b3bfe5ad847b6b549 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 12:57:42 +0530 Subject: [PATCH 118/167] Corrected doctests --- src/sage/matroids/chow_ring.py | 103 +++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 23 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 72904bbd5a4..39b969d84c7 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -10,7 +10,7 @@ from sage.rings.quotient_ring import QuotientRing_generic from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.categories.commutative_rings import CommutativeRings -from itertools import product, combinations +from itertools import product from sage.combinat.posets.posets import Poset class ChowRing(QuotientRing_generic): @@ -126,7 +126,7 @@ def _latex_(self): sage: M1 = matroids.Uniform(2,5) sage: ch = M1.chow_ring(QQ, False) sage: ch._latex_() - '\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{01234}] / \\left(A_{0} A_{1}, A_{0} A_{2}, A_{0} A_{3}, A_{0} A_{4}, A_{1} A_{2}, A_{1} A_{3}, A_{1} A_{4}, A_{2} A_{3}, A_{2} A_{4}, A_{3} A_{4}, A_{0} + A_{01234}, A_{1} + A_{01234}, A_{2} + A_{01234}, A_{3} + A_{01234}, A_{4} + A_{01234}\\right)\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{01234}]' + '\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{01234}] / I_{M} + J_{M} of matroid \\begin{array}{l}\n\\text{\\texttt{U(2,{ }5):{ }Matroid{ }of{ }rank{ }2{ }on{ }5{ }elements{ }with{ }circuit{-}closures}}\\\\\n\\text{\\texttt{{\\char`\\{}2:{ }{\\char`\\{}{\\char`\\{}0,{ }1,{ }2,{ }3,{ }4{\\char`\\}}{\\char`\\}}{\\char`\\}}}}\n\\end{array}' """ from sage.misc.latex import latex return "{} / {}".format(latex(self._ideal.ring()), latex(self._ideal)) @@ -151,14 +151,28 @@ def basis(self): sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, True, 'fy') sage: ch.basis() - [B0*B01, 1] - sage: len(ch.defining_ideal().normal_basis()) == ch.basis().cardinality() + Family (1, B1, B1*B012345, B0, B0*B012345, B01, B01^2, B2, + B2*B012345, B02, B02^2, B12, B12^2, B3, B3*B012345, B03, B03^2, + B13, B13^2, B23, B23^2, B4, B4*B012345, B24, B24^2, B34, B34^2, + B04, B04^2, B14, B14^2, B5, B5*B012345, B25, B25^2, B35, B35^2, + B45, B45^2, B05, B05^2, B15, B15^2, B012345, B012345^2, + B012345^3) + sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis()) True - sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) - [A0*A013, 1] - sage: len(ch.defining_ideal().normal_basis()) == ch.basis().cardinality() + sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) + sage: ch.basis() + Family (1, Abcd, Aace, Aabf, Adef, Aadg, Abeg, Acfg, Aabcdefg, + Aabcdefg^2) + sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis()) + True + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') + sage: ch.basis() + Family (1, A0, A0*A012345, A2, A2*A012345, A3, A3*A012345, A23, + A23^2, A1, A1*A012345, A013, A013^2, A4, A4*A012345, A04, A04^2, + A124, A124^2, A5, A5*A012345, A025, A025^2, A15, A15^2, A345, + A345^2, A012345, A012345^2, A012345^3) + sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis()) True - """ flats = [X for i in range(1, self._matroid.rank() + 1) for X in self._matroid.flats(i)] #Non empty flats @@ -243,9 +257,9 @@ def to_vector(self, order=None): sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, False) sage: v = ch.an_element(); v - A0 + 0 sage: v.to_vector() - (0, 0, 0, 1, 0, 0, 0) + (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) """ P = self.parent() B = P.basis() @@ -261,11 +275,15 @@ def monomial_coefficients(self, copy=None): EXAMPLES:: - sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'fy') + sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'atom-free') sage: v = ch.an_element(); v - Ag + 0 sage: v.monomial_coefficients() - {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0} + {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, + 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, + 18: 0, 19: 0, 20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0, + 26: 0, 27: 0, 28: 0, 29: 0, 30: 0, 31: 0, 32: 0, 33: 0, + 34: 0, 35: 0} """ B = self.parent().basis() f = self.lift() @@ -281,15 +299,26 @@ def degree(self): sage: for b in ch.basis(): ....: print(b, b.degree()) 1 0 - A1 1 - A3 1 - A0 1 - A2 1 - A4 1 - A5 1 + A01 1 + A02 1 + A12 1 + A03 1 + A13 1 + A23 1 + A24 1 + A34 1 + A04 1 + A14 1 + A25 1 + A35 1 + A45 1 + A05 1 + A15 1 + A012345 1 + A012345^2 2 sage: v = sum(ch.basis()) sage: v.degree() - 1 + 0 """ return self.lift().degree() @@ -304,15 +333,43 @@ def homogeneous_degree(self): sage: for b in ch.basis(): ....: print(b, b.homogeneous_degree()) 1 0 - Bb 1 Ba 1 + Ba*Babcdefg 2 + Bb 1 + Bb*Babcdefg 2 Bc 1 + Bc*Babcdefg 2 Bd 1 + Bd*Babcdefg 2 + Bbcd 1 + Bbcd^2 2 Be 1 + Be*Babcdefg 2 + Bace 1 + Bace^2 2 Bf 1 + Bf*Babcdefg 2 + Babf 1 + Babf^2 2 + Bdef 1 + Bdef^2 2 Bg 1 + Bg*Babcdefg 2 + Badg 1 + Badg^2 2 + Bbeg 1 + Bbeg^2 2 + Bcfg 1 + Bcfg^2 2 + Babcdefg 1 + Babcdefg^2 2 + Babcdefg^3 3 sage: v = sum(ch.basis()); v - Ba + Bb + Bc + Bd + Be + Bf + Bg + 1 + Babcdefg^3 + Babf^2 + Bace^2 + Badg^2 + Bbcd^2 + Bbeg^2 + + Bcfg^2 + Bdef^2 + Ba*Babcdefg + Bb*Babcdefg + Bc*Babcdefg + + Bd*Babcdefg + Be*Babcdefg + Bf*Babcdefg + Bg*Babcdefg + + Babcdefg^2 + Ba + Bb + Bc + Bd + Be + Bf + Bg + Babf + Bace + + Badg + Bbcd + Bbeg + Bcfg + Bdef + Babcdefg + 1 sage: v.homogeneous_degree() Traceback (most recent call last): ... @@ -320,7 +377,7 @@ def homogeneous_degree(self): TESTS:: - sage: ch = matroids.Wheel(3).chow_ring(QQ, False) + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch.zero().homogeneous_degree() Traceback (most recent call last): ... From 94527d8b2fcbffef6cea32b7a4a75fef89e73203 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 14:08:54 +0530 Subject: [PATCH 119/167] Corrected doctests in chow_ring() method --- src/sage/matroids/matroid.pyx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 310580e1d18..496a76fa292 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8041,32 +8041,30 @@ cdef class Matroid(SageObject): sage: M = matroids.Wheel(2) sage: A = M.chow_ring(R=ZZ, augmented=False); A - Chow ring of Wheel(2): Regular matroid of rank 2 on 4 elements - with 5 bases over Integer Ring - sage: A._gens_constructor() # needs sage.libs.singular + Chow ring of Wheel(2): Regular matroid of rank 2 on 4 elements with 5 bases + sage: A.defining_ideal()._gens_constructor() (A23, A23, A23) - sage: A23 = A.gen(0) # needs sage.libs.singular - sage: A23*A23 # needs sage.libs.singular + sage: A23 = A.gen(0) + sage: A23*A23 0 We construct a more interesting example using the Fano matroid:: sage: M = matroids.catalog.Fano() sage: A = M.chow_ring(QQ, augmented=False); A - Chow ring of Fano: Binary matroid of rank 3 on 7 elements, - type (3, 0) over Rational Field. + Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) The augmented Chow ring can also be constructed with the Feitchner-Yuzvinsky and atom-free presentation:: sage: M = matroids.Wheel(3) - sage: ch = M.chow_ring(QQ, augmented=True, presentation='fy') + sage: ch = M.chow_ring(QQ, augmented=True, presentation='fy'); ch Augmented Chow ring of Wheel(3): Regular matroid of rank 3 on - 6 elements with 16 bases of Feitchner-Yuzvinsky presentation + 6 elements with 16 bases in Feitchner-Yuzvinsky presentation sage: M = matroids.Uniform(3, 6) - sage: ch = M.chow_ring(QQ, augmented=True, presentation='atom-free') + sage: ch = M.chow_ring(QQ, augmented=True, presentation='atom-free'); ch Augmented Chow ring of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures - {3: {{0, 1, 2, 3, 4, 5}}} of atom-free presentation + {3: {{0, 1, 2, 3, 4, 5}}} in atom-free presentation """ from sage.matroids.chow_ring import ChowRing return ChowRing(M=self, R=R, augmented=augmented, presentation=presentation) From 8fdd62544e1e7860adbecef9b8758831160d92f9 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 14:26:00 +0530 Subject: [PATCH 120/167] Corrected Doctests for chow_ring() method --- src/sage/matroids/matroid.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 496a76fa292..138ffdd4e13 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8042,7 +8042,7 @@ cdef class Matroid(SageObject): sage: M = matroids.Wheel(2) sage: A = M.chow_ring(R=ZZ, augmented=False); A Chow ring of Wheel(2): Regular matroid of rank 2 on 4 elements with 5 bases - sage: A.defining_ideal()._gens_constructor() + sage: A.defining_ideal()._gens_constructor(A.defining_ideal().ring()) (A23, A23, A23) sage: A23 = A.gen(0) sage: A23*A23 From 193ca4ed73095e4131a842516e3f726e149ce128 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 17 Oct 2024 14:43:51 +0530 Subject: [PATCH 121/167] Corrected doctests in chow_ring() method --- src/sage/matroids/matroid.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 138ffdd4e13..2bf1fd8abc3 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8043,7 +8043,7 @@ cdef class Matroid(SageObject): sage: A = M.chow_ring(R=ZZ, augmented=False); A Chow ring of Wheel(2): Regular matroid of rank 2 on 4 elements with 5 bases sage: A.defining_ideal()._gens_constructor(A.defining_ideal().ring()) - (A23, A23, A23) + [A0*A1, A0*A23, A1*A23, A0 + A0123, A1 + A0123, A23 + A0123] sage: A23 = A.gen(0) sage: A23*A23 0 From 719d270d24f14a6e3a0cb78cdb009d398700e4c6 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 19 Oct 2024 11:45:13 +0530 Subject: [PATCH 122/167] Formatted docstrings --- src/sage/matroids/chow_ring.py | 5 +---- src/sage/matroids/chow_ring_ideal.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 39b969d84c7..673b48cfa15 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -49,7 +49,7 @@ class ChowRing(QuotientRing_generic): .. SEEALSO:: - :mod:`sage.matroids.chow_ring_ideal + :mod:`sage.matroids.chow_ring_ideal` INPUT: @@ -120,9 +120,6 @@ def _latex_(self): Return the LaTeX output of the polynomial ring and Chow ring ideal. EXAMPLES:: - - sage: from sage.matroids.graphic_matroid import GraphicMatroid - sage: M1 = matroids.Uniform(2,5) sage: ch = M1.chow_ring(QQ, False) sage: ch._latex_() diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 6eb14139828..38f63c87b9f 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -287,13 +287,13 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): .. MATH:: - y_i + \sum_{i \in F} y_{F \union e} + y_i + \sum_{i \in F} y_{F \union e} for all `i \in E` and, .. MATH:: - \sum_{F} y_{F \union e}. + \sum_{F} y_{F \union e}. Setting `x_F = y_{F \union e}` and using the last linear form to eliminate `x_E` recovers the usual presentation of @@ -495,20 +495,20 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): - `F_1, \ldots, F_k` are the non-empty flats of `M`, - `I_{af}M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of - flats, + where `F_i` and `F_j` are incomparable elements in the lattice of + flats, - .. MATH:: + .. MATH:: - x_F \sum_{i \in F'} x_{F'} + x_F \sum_{i \in F'} x_{F'} - for all `i \in E` and `i \notin F`, and + for all `i \in E` and `i \notin F`, and - .. MATH:: + .. MATH:: - \sum_{i \in F'} (x_{F'})^2 + \sum_{i \in F'} (x_{F'})^2 - for all `i \in E`. + for all `i \in E`. REFERENCES: From 8caea48273db7015ff1d1cd503314d15859008c9 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 19 Oct 2024 12:24:28 +0530 Subject: [PATCH 123/167] Formatted docstrings --- src/sage/matroids/chow_ring.py | 4 ++-- src/sage/matroids/chow_ring_ideal.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 673b48cfa15..48815f53973 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -21,9 +21,9 @@ class ChowRing(QuotientRing_generic): .. MATH:: - A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (Q_M + L_M), + A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M), - where `(Q_M + L_M)` is the :class:`Chow ring ideal + where `(I_M + J_M)` is the :class:`Chow ring ideal ` of matroid `M`. The *augmented Chow ring of matroid* `M` in the Feitchner-Yuzvinsky presentation diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 38f63c87b9f..83270c7faca 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -65,7 +65,7 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): - `F_1, \ldots, F_k` are the non-empty flats of `M`, - `I_M` is the Stanley-Reisner ideal, i.e., it is generated - by products `x_{F_1}, \ldots, x_{F_t}` for subsets `{F_1}, \ldots, {F_t}` + by products `x_{F_1}, \ldots, x_{F_t}` for subsets `{F_1, \ldots, F_t}` of flats that are not chains, and - `J_M` is the ideal generated by all linear forms From 2abf2cceb61921fa02d89b0de924cfbcfcb2066f Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sat, 19 Oct 2024 12:49:46 +0530 Subject: [PATCH 124/167] Edited docstrings --- src/sage/matroids/chow_ring_ideal.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 83270c7faca..44026c74a17 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -256,7 +256,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): where - `F_1, \ldots, F_k` are the proper flats of `M`, - - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, + - `e_1, \ldots, e_n` are `n` elements of groundset of `M`, - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}`, where `F_i` and `F_j` are incomparable elements in the lattice of flats and `y_{i} x_F` for every `i \in E` and `i \notin F`, and @@ -269,8 +269,8 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): for all `i \in E`. The augmented Chow ring ideal in the Feitchner Yuzvinsky presentation - for a simple matroid `M` is defined as the ideal - `(I_{FY}(M))` of the following polynomial ring + for a simple matroid `M` is defined as the ideal `(I_{FY}(M))` of the + following polynomial ring .. MATH:: @@ -279,8 +279,8 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): where - `F_1, \ldots, F_k` are the flats of `M`, - - `e_1 \ldots, e_n` are `n` elements of groundset of `M`, - - `I_{FY}(M) is the ideal generated by all quadratic forms + - `e_1, \ldots, e_n` are `n` elements of groundset of `M`, + - `I_{FY}(M)` is the ideal generated by all quadratic forms `y_{F_i \union e} y_{F_j \union e}`, where `F_i` and `F_j` are incomparable elements in the lattice of flats, `y_{i} y_{F \union e}` for every `i \in E` and `i \notin F`, linear forms @@ -297,7 +297,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): Setting `x_F = y_{F \union e}` and using the last linear form to eliminate `x_E` recovers the usual presentation of - augmented Chow ring of M. + augmented Chow ring of `M`. REFERENCES: @@ -422,7 +422,7 @@ def _repr_(self): def _latex_(self): r""" - Return a LaTeX representation`self`. + Return a LaTeX representation of ``self``. EXAMPLES:: @@ -436,7 +436,7 @@ def _latex_(self): def groebner_basis(self, algorithm='constructed', *args, **kwargs): r""" - Returns the Groebner basis of `self`. + Returns the Groebner basis of ``self``. EXAMPLES:: @@ -484,8 +484,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): atom-free presentation. The augmented Chow ring ideal in the atom-free presentation for a matroid - `M` is defined as the ideal - `I_{af}(M)` of the polynomial ring: + `M` is defined as the ideal `I_{af}(M)` of the polynomial ring: .. MATH:: @@ -597,7 +596,7 @@ def _repr_(self): def _latex_(self): r""" - Return the LaTeX output of the ring and generators of `self`. + Return the LaTeX output of the ring and generators of ``self``. EXAMPLES:: @@ -611,7 +610,7 @@ def _latex_(self): def groebner_basis(self, algorithm='constructed', *args, **kwargs): """ - Returns the Groebner basis of `self`. + Returns the Groebner basis of ``self``. EXAMPLES:: From ef0e1d69044f7db2a7949d1ce7b82d67b27b1817 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 21 Oct 2024 13:59:21 +0530 Subject: [PATCH 125/167] Edited doctests --- src/doc/en/reference/matroids/index.rst | 4 +-- src/sage/matroids/chow_ring.py | 9 ++--- src/sage/matroids/chow_ring_ideal.py | 47 ++++++++++++------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/doc/en/reference/matroids/index.rst b/src/doc/en/reference/matroids/index.rst index 5f1bf9f5f45..59453ff2fdc 100644 --- a/src/doc/en/reference/matroids/index.rst +++ b/src/doc/en/reference/matroids/index.rst @@ -65,8 +65,8 @@ Internals sage/matroids/set_system sage/matroids/unpickling - Chow rings of matroids - ---------------------- +Chow rings of matroids +---------------------- .. toctree:: :maxdepth: 1 diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 48815f53973..95130e7f316 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -17,7 +17,7 @@ class ChowRing(QuotientRing_generic): r""" The Chow ring of a matroid. - The *Chow ring of a matroid* `M` is defined as the quotient ring + The *Chow ring of the matroid* `M` is defined as the quotient ring .. MATH:: @@ -26,8 +26,8 @@ class ChowRing(QuotientRing_generic): where `(I_M + J_M)` is the :class:`Chow ring ideal ` of matroid `M`. - The *augmented Chow ring of matroid* `M` in the Feitchner-Yuzvinsky presentation - is the quotient ring + The *augmented Chow ring of matroid* `M` in the Feitchner-Yuzvinsky + presentation is the quotient ring .. MATH:: @@ -35,7 +35,7 @@ class ChowRing(QuotientRing_generic): where `(I_M + J_M)` is the :class:`augmented Chow ring ideal ` of matroid `M` - in Feitchner-Yuzvinsky presentation. + in the Feitchner-Yuzvinsky presentation. The *augmented Chow ring of atom-free presentation* is the quotient ring @@ -120,6 +120,7 @@ def _latex_(self): Return the LaTeX output of the polynomial ring and Chow ring ideal. EXAMPLES:: + sage: M1 = matroids.Uniform(2,5) sage: ch = M1.chow_ring(QQ, False) sage: ch._latex_() diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 44026c74a17..0ddd9a6f9c7 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -65,7 +65,7 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): - `F_1, \ldots, F_k` are the non-empty flats of `M`, - `I_M` is the Stanley-Reisner ideal, i.e., it is generated - by products `x_{F_1}, \ldots, x_{F_t}` for subsets `{F_1, \ldots, F_t}` + by products `x_{F_1}, \ldots, x_{F_t}` for subsets `\{F_1, \ldots, F_t\}` of flats that are not chains, and - `J_M` is the ideal generated by all linear forms @@ -244,7 +244,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" The augmented Chow ring ideal of matroid `M` over ring `R` in - Feitchner-Yuzvinsky presentation. + the Feitchner-Yuzvinsky presentation. The augmented Chow ring ideal for a matroid `M` is defined as the ideal `(I_M + J_M)` of the following polynomial ring @@ -274,28 +274,28 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): .. MATH:: - R[y_{e_1}, \ldots, y_{e_n}, y_{F_1 \union e}, \ldots, y_{F_k \union e}], + R[y_{e_1}, \ldots, y_{e_n}, y_{F_1 \cup e}, \ldots, y_{F_k \cup e}], where - `F_1, \ldots, F_k` are the flats of `M`, - `e_1, \ldots, e_n` are `n` elements of groundset of `M`, - `I_{FY}(M)` is the ideal generated by all quadratic forms - `y_{F_i \union e} y_{F_j \union e}`, where `F_i` and `F_j` - are incomparable elements in the lattice of flats, `y_{i} y_{F \union e}` + `y_{F_i \cup e} y_{F_j \cup e}`, where `F_i` and `F_j` + are incomparable elements in the lattice of flats, `y_{i} y_{F \cup e}` for every `i \in E` and `i \notin F`, linear forms .. MATH:: - y_i + \sum_{i \in F} y_{F \union e} + y_i + \sum_{i \in F} y_{F \cup e} for all `i \in E` and, .. MATH:: - \sum_{F} y_{F \union e}. + \sum_{F} y_{F \cup e}. - Setting `x_F = y_{F \union e}` and using the last linear + Setting `x_F = y_{F \cup e}` and using the last linear form to eliminate `x_E` recovers the usual presentation of augmented Chow ring of `M`. @@ -434,9 +434,9 @@ def _latex_(self): from sage.misc.latex import latex return 'I_{FY} of matroid ' + (latex(self._matroid)) - def groebner_basis(self, algorithm='constructed', *args, **kwargs): + def groebner_basis(self, algorithm='', *args, **kwargs): r""" - Returns the Groebner basis of ``self``. + Return the Groebner basis of ``self``. EXAMPLES:: @@ -488,26 +488,25 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): .. MATH:: - R[x_{F_1}, \ldots, x_{F_k}] + R[x_{F_1}, \ldots, x_{F_k}], where - - `F_1, \ldots, F_k` are the non-empty flats of `M`, - - `I_{af}M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of - flats, + - `F_1, \ldots, F_k` are the non-empty flats of `M`, + - `I_{af}M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + where `F_i` and `F_j` are incomparable elements in the lattice of flats, - .. MATH:: + .. MATH:: - x_F \sum_{i \in F'} x_{F'} + x_F \sum_{i \in F'} x_{F'} - for all `i \in E` and `i \notin F`, and + for all `i \in E` and `i \notin F`, and - .. MATH:: + .. MATH:: - \sum_{i \in F'} (x_{F'})^2 + \sum_{i \in F'} (x_{F'})^2 - for all `i \in E`. + for all `i \in E`. REFERENCES: @@ -585,7 +584,7 @@ def _gens_constructor(self, poly_ring): def _repr_(self): r""" - EXAMPLE:: + EXAMPLES:: sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal() @@ -608,9 +607,9 @@ def _latex_(self): from sage.misc.latex import latex return 'I_{af} of matroid ' + latex(self._matroid) - def groebner_basis(self, algorithm='constructed', *args, **kwargs): + def groebner_basis(self, algorithm='', *args, **kwargs): """ - Returns the Groebner basis of ``self``. + Return the Groebner basis of ``self``. EXAMPLES:: From c9d45536e6fbf8c3433dc76e9ed75dcfaf036ffa Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 21 Oct 2024 14:01:47 +0530 Subject: [PATCH 126/167] Edited references formatting --- src/doc/en/reference/references/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index d700aa8661b..98cfe8b3fe1 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -4929,7 +4929,7 @@ REFERENCES: Int. Math. Res. Not. IMRN, 2015, 3121-3149. .. [MM2022] Matthew Mastroeni and Jason McCullough. Chow rings of matroids are - koszul. *Mathematische Annalen*, 387(3–4):1819–1851, November 2022. + Koszul. *Mathematische Annalen*, 387(3-4):1819-1851, November 2022. .. [MMRS2022] Ruslan G. Marzo, Rafael A. Melo, Celso C. Ribeiro and Marcio C. Santos: *New formulations and branch-and-cut procedures From 8f52723f9c179a9d0a9d55d4b3cfdeb55f95ca45 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 21 Oct 2024 15:39:18 +0530 Subject: [PATCH 127/167] Reformatted references file --- src/doc/en/reference/references/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index 98cfe8b3fe1..c189bf296f5 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -262,7 +262,7 @@ REFERENCES: 369–379. https://doi.org/10.1007/BF02677478 .. [ANR2023] Robert Angarone, Anastasia Nathanson, and Victor Reiner. *Chow rings of - matroids as permutation representations*, 2023. :arxiv: `2309.14312`. + matroids as permutation representations*, 2023. :arxiv:`2309.14312`. .. [AP1986] \S. Arnborg, A. Proskurowski, *Characterization and Recognition of Partial 3-Trees*, @@ -4928,8 +4928,8 @@ REFERENCES: .. [MM2015] \J. Matherne and \G. Muller, *Computing upper cluster algebras*, Int. Math. Res. Not. IMRN, 2015, 3121-3149. -.. [MM2022] Matthew Mastroeni and Jason McCullough. Chow rings of matroids are - Koszul. *Mathematische Annalen*, 387(3-4):1819-1851, November 2022. +.. [MM2022] Matthew Mastroeni and Jason McCullough. *Chow rings of matroids are + Koszul*. Mathematische Annalen, 387(3-4):1819-1851, November 2022. .. [MMRS2022] Ruslan G. Marzo, Rafael A. Melo, Celso C. Ribeiro and Marcio C. Santos: *New formulations and branch-and-cut procedures From cb6dcc6d81cf22cba59749705c05dd0e3f918ffb Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 21 Oct 2024 16:58:21 +0530 Subject: [PATCH 128/167] Formatted definitions --- src/sage/matroids/chow_ring.py | 8 ++++---- src/sage/matroids/chow_ring_ideal.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 95130e7f316..ba668f4ad4a 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -31,9 +31,9 @@ class ChowRing(QuotientRing_generic): .. MATH:: - A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M), + A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / I_{FY}(M), - where `(I_M + J_M)` is the :class:`augmented Chow ring ideal + where `I_{FY}(M)` is the :class:`augmented Chow ring ideal ` of matroid `M` in the Feitchner-Yuzvinsky presentation. @@ -41,9 +41,9 @@ class ChowRing(QuotientRing_generic): .. MATH:: - A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_M^{af}, + A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_{af}(M), - where `I_M^{af}` is the :class:`augmented Chow ring ideal + where `I_{af}(M)` is the :class:`augmented Chow ring ideal ` of matroid `M` in the atom-free presentation. diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 0ddd9a6f9c7..49f3aa0752c 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -269,7 +269,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): for all `i \in E`. The augmented Chow ring ideal in the Feitchner Yuzvinsky presentation - for a simple matroid `M` is defined as the ideal `(I_{FY}(M))` of the + for a simple matroid `M` is defined as the ideal `I_{FY}(M)` of the following polynomial ring .. MATH:: @@ -493,7 +493,7 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): where - `F_1, \ldots, F_k` are the non-empty flats of `M`, - - `I_{af}M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` + - `I_{af}(M)` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` where `F_i` and `F_j` are incomparable elements in the lattice of flats, .. MATH:: From 5b79644b44cd666649129ccc3c97115917baad47 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 27 Oct 2024 17:14:43 +0530 Subject: [PATCH 129/167] Changed index.rst for matroids --- src/doc/en/reference/matroids/index.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/doc/en/reference/matroids/index.rst b/src/doc/en/reference/matroids/index.rst index 59453ff2fdc..284caabe8d0 100644 --- a/src/doc/en/reference/matroids/index.rst +++ b/src/doc/en/reference/matroids/index.rst @@ -34,6 +34,15 @@ Concrete implementations sage/matroids/rank_matroid sage/matroids/graphic_matroid +Chow rings of matroids +---------------------- + +.. toctree:: + :maxdepth: 1 + + sage/matroids/chow_ring_ideal + sage/matroids/chow_ring + Abstract matroid classes ------------------------ @@ -65,13 +74,4 @@ Internals sage/matroids/set_system sage/matroids/unpickling -Chow rings of matroids ----------------------- - -.. toctree:: - :maxdepth: 1 - - sage/matroids/chow_ring_ideal - sage/matroids/chow_ring - .. include:: ../footer.txt From 2a5f0cabbafac3a1da346060880c12ddafe5d709 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 27 Oct 2024 17:19:28 +0530 Subject: [PATCH 130/167] Changed Documentation for augmented Chow rings definition --- src/sage/matroids/chow_ring.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index ba668f4ad4a..063cf6416ca 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -26,26 +26,28 @@ class ChowRing(QuotientRing_generic): where `(I_M + J_M)` is the :class:`Chow ring ideal ` of matroid `M`. - The *augmented Chow ring of matroid* `M` in the Feitchner-Yuzvinsky - presentation is the quotient ring + The *augmented Chow ring of matroid* `M` has two different presentations + as quotient rings: + + The *Feitchner-Yuzvinsky presentation* is the quotient ring .. MATH:: A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / I_{FY}(M), - where `I_{FY}(M)` is the :class:`augmented Chow ring ideal - ` of matroid `M` - in the Feitchner-Yuzvinsky presentation. + where `I_{FY}(M)` is the :class:`Feitchner-Yuzvinsky augmented Chow ring + ideal ` + of matroid `M`. - The *augmented Chow ring of atom-free presentation* is the quotient ring + The *atom-free presentation* is the quotient ring .. MATH:: A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_{af}(M), - where `I_{af}(M)` is the :class:`augmented Chow ring ideal + where `I_{af}(M)` is the :class:`atom-free augmented Chow ring ideal ` - of matroid `M` in the atom-free presentation. + of matroid `M`. .. SEEALSO:: From 5b7a29fa55679ee1cc96ba9d6a57736ed1271d0b Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 27 Oct 2024 17:28:06 +0530 Subject: [PATCH 131/167] Edited inputs for Chow ring class --- src/sage/matroids/chow_ring.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 063cf6416ca..ca61bd97a81 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -59,7 +59,8 @@ class ChowRing(QuotientRing_generic): - ``R`` -- commutative ring - ``augmented`` -- boolean; when ``True``, this is the augmented Chow ring and if ``False``, this is the non-augmented Chow ring - - ``presentation`` -- string (default: ``None``); one of the following: + - ``presentation`` -- string (default: ``None``); one of the following + (ignored if ``augmented=False``) * ``"fy"`` - the Feitchner-Yuzvinsky presentation * ``"atom-free"`` - the atom-free presentation From 3c6a9e11feddb5ce44e27707ad354744bbf5d234 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 27 Oct 2024 17:30:05 +0530 Subject: [PATCH 132/167] Edited _latex_() for ChowRing() class --- src/sage/matroids/chow_ring.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index ca61bd97a81..65a6a1e9eea 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -130,7 +130,10 @@ def _latex_(self): '\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{01234}] / I_{M} + J_{M} of matroid \\begin{array}{l}\n\\text{\\texttt{U(2,{ }5):{ }Matroid{ }of{ }rank{ }2{ }on{ }5{ }elements{ }with{ }circuit{-}closures}}\\\\\n\\text{\\texttt{{\\char`\\{}2:{ }{\\char`\\{}{\\char`\\{}0,{ }1,{ }2,{ }3,{ }4{\\char`\\}}{\\char`\\}}{\\char`\\}}}}\n\\end{array}' """ from sage.misc.latex import latex - return "{} / {}".format(latex(self._ideal.ring()), latex(self._ideal)) + base = "A({})_{{{}}}" + if self._augmented: + base += "^*" + return base.format(latex(self.matroid()), latex(self.base_ring())) def _coerce_map_from_base_ring(self): r""" From c0ba0c6bcf71379073f1bb98366416679eb3c595 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 27 Oct 2024 17:42:32 +0530 Subject: [PATCH 133/167] Edited basis() method --- src/sage/matroids/chow_ring.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 65a6a1e9eea..7c5615848f5 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -178,16 +178,17 @@ def basis(self): sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis()) True """ - flats = [X for i in range(1, self._matroid.rank() + 1) - for X in self._matroid.flats(i)] #Non empty flats + F = self._matroid.lattice_of_flats() + H = F.hasse_diagram() + H.delete_vertex(self._ideal.matroid().flats(0)[0]) # remove the empty flat + lattice_flats = Poset(H) + flats = list(lattice_flats) flats_gen = self._ideal.flats_generator() R = self._ideal.ring() - flats = sorted(flats, key=lambda X: (len(X), sorted(X))) + flats.sort(key=lambda X: (len(X), sorted(X))) ranks = {F: self._matroid.rank(F) for F in flats} monomial_basis = [] - reln = lambda x,y: x <= y - lattice_flats = Poset((flats, reln)) - chains = lattice_flats.chains() #Only chains + chains = lattice_flats.chains() #Only chains if self._augmented: if self._presentation == 'fy': for subset in chains: From aa11b066e094c556ae729e403d784f89ba3d6cad Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Sun, 27 Oct 2024 17:54:36 +0530 Subject: [PATCH 134/167] Edited documentation --- src/sage/matroids/chow_ring_ideal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 49f3aa0752c..e33a30b2e23 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -268,7 +268,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): for all `i \in E`. - The augmented Chow ring ideal in the Feitchner Yuzvinsky presentation + The augmented Chow ring ideal in the Feitchner-Yuzvinsky presentation for a simple matroid `M` is defined as the ideal `I_{FY}(M)` of the following polynomial ring @@ -280,7 +280,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): - `F_1, \ldots, F_k` are the flats of `M`, - `e_1, \ldots, e_n` are `n` elements of groundset of `M`, - - `I_{FY}(M)` is the ideal generated by all quadratic forms + - `I_{FY}(M)` is the ideal generated by all quadratic forms `y_{F_i \cup e} y_{F_j \cup e}`, where `F_i` and `F_j` are incomparable elements in the lattice of flats, `y_{i} y_{F \cup e}` for every `i \in E` and `i \notin F`, linear forms @@ -289,7 +289,7 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): y_i + \sum_{i \in F} y_{F \cup e} - for all `i \in E` and, + for all `i \in E` and .. MATH:: From 9c93b8497179ce482d0954be8bcfa53306daa26e Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 28 Oct 2024 22:31:51 +0530 Subject: [PATCH 135/167] Resolved suggested changes --- src/doc/en/reference/references/index.rst | 2 +- src/sage/matroids/chow_ring_ideal.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index c189bf296f5..5567eaa8bf2 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -260,7 +260,7 @@ REFERENCES: .. [Ang1997] B. Anglès. 1997. *On some characteristic polynomials attached to finite Drinfeld modules.* manuscripta mathematica 93, 1 (01 Aug 1997), 369–379. https://doi.org/10.1007/BF02677478 - + .. [ANR2023] Robert Angarone, Anastasia Nathanson, and Victor Reiner. *Chow rings of matroids as permutation representations*, 2023. :arxiv:`2309.14312`. diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index e33a30b2e23..55812198d00 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -192,7 +192,7 @@ def _latex_(self): I_{M} + J_{M} of matroid \text{\texttt{Matroid{ }of{ }rank{ }2{ }on{ }4{ }elements{ }with{ }3{ }bases}} """ from sage.misc.latex import latex - return 'I_{M} + J_{M} of matroid ' + (latex(self._matroid)) + return 'I_{M} + J_{M} of matroid '.format(latex(self._matroid)) def groebner_basis(self, algorithm='', *args, **kwargs): r""" @@ -328,7 +328,7 @@ def __init__(self, M, R): """ self._matroid = M self._flats = [X for i in range(self._matroid.rank() + 1) - for X in self._matroid.flats(i)] + for X in self._matroid.flats(i)] E = list(self._matroid.groundset()) self._flats_generator = dict() try: @@ -337,9 +337,9 @@ def __init__(self, M, R): poly_ring = PolynomialRing(R, names_groundset + names_flats) #self.ring() except ValueError: #variables are not proper names poly_ring = PolynomialRing(R, 'A', len(E) + len(self._flats)) - for i,x in enumerate(E): + for i, x in enumerate(E): self._flats_generator[x] = poly_ring.gens()[i] - for i,F in enumerate(self._flats): + for i, F in enumerate(self._flats): self._flats_generator[F] = poly_ring.gens()[len(E) + i] MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) @@ -396,7 +396,7 @@ def _gens_constructor(self, poly_ring): term += self._flats_generator[F] for G in self._flats: if not (F <= G or G < F): - Q.append(self._flats_generator[F] * self._flats_generator[G]) #Quadratic Generators + Q.append(self._flats_generator[F] * self._flats_generator[G]) # Quadratic generators L.append(term) for x in E: @@ -432,7 +432,7 @@ def _latex_(self): I_{FY} of matroid \text{\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}} """ from sage.misc.latex import latex - return 'I_{FY} of matroid ' + (latex(self._matroid)) + return 'I_{{FY}}({})'.format((latex(self._matroid))) def groebner_basis(self, algorithm='', *args, **kwargs): r""" @@ -562,16 +562,16 @@ def _gens_constructor(self, poly_ring): A0*A2 + A2*A3, A1*A2 + A2*A3] """ E = list(self._matroid.groundset()) - Q = [] #Quadratic Generators + Q = [] # Quadratic generators flats_containing = {x: [] for x in E} for F in self._flats: for x in F: flats_containing[x].append(F) for F in self._flats: for G in self._flats: - if not (G >= F or F > G): #generators for every pair of non-nested flats - Q.append(self._flats_generator[F]*self._flats_generator[G]) - for x in E: #generators for every set of flats containing element + if not (G >= F or F > G): # generators for every pair of non-nested flats + Q.append(self._flats_generator[F] * self._flats_generator[G]) + for x in E: # generators for every set of flats containing element term = poly_ring.zero() for H in flats_containing[x]: term += self._flats_generator[H] @@ -605,7 +605,7 @@ def _latex_(self): I_{af} of matroid \text{\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}} """ from sage.misc.latex import latex - return 'I_{af} of matroid ' + latex(self._matroid) + return 'I_{af} of matroid '.format(latex(self._matroid)) def groebner_basis(self, algorithm='', *args, **kwargs): """ From 99d843f9d0e5b3079ea6337ec6fca90193cffec9 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 28 Oct 2024 22:40:01 +0530 Subject: [PATCH 136/167] Corrected linting errors in ideal file --- src/sage/matroids/chow_ring_ideal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 55812198d00..f3075099f87 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -192,7 +192,7 @@ def _latex_(self): I_{M} + J_{M} of matroid \text{\texttt{Matroid{ }of{ }rank{ }2{ }on{ }4{ }elements{ }with{ }3{ }bases}} """ from sage.misc.latex import latex - return 'I_{M} + J_{M} of matroid '.format(latex(self._matroid)) + return 'I_{M} + J_{M} of matroid ' + latex(self._matroid) def groebner_basis(self, algorithm='', *args, **kwargs): r""" @@ -605,7 +605,7 @@ def _latex_(self): I_{af} of matroid \text{\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}} """ from sage.misc.latex import latex - return 'I_{af} of matroid '.format(latex(self._matroid)) + return 'I_{{af}}({}) of matroid '.format(latex(self._matroid)) def groebner_basis(self, algorithm='', *args, **kwargs): """ From 6ef419f35b2f712cc09617071e8f20e1f6556269 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 09:59:03 +0530 Subject: [PATCH 137/167] Corrected doctests --- src/sage/matroids/chow_ring.py | 17 ++++++++--------- src/sage/matroids/chow_ring_ideal.py | 6 +++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 7c5615848f5..35089995aa9 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -133,7 +133,7 @@ def _latex_(self): base = "A({})_{{{}}}" if self._augmented: base += "^*" - return base.format(latex(self.matroid()), latex(self.base_ring())) + return base.format(latex(self._matroid), latex(self.base_ring())) def _coerce_map_from_base_ring(self): r""" @@ -157,10 +157,9 @@ def basis(self): sage: ch.basis() Family (1, B1, B1*B012345, B0, B0*B012345, B01, B01^2, B2, B2*B012345, B02, B02^2, B12, B12^2, B3, B3*B012345, B03, B03^2, - B13, B13^2, B23, B23^2, B4, B4*B012345, B24, B24^2, B34, B34^2, - B04, B04^2, B14, B14^2, B5, B5*B012345, B25, B25^2, B35, B35^2, - B45, B45^2, B05, B05^2, B15, B15^2, B012345, B012345^2, - B012345^3) + B13, B13^2, B23, B23^2, B4, B4*B012345, B04, B04^2, B14, B14^2, + B24, B24^2, B34, B34^2, B5, B5*B012345, B05, B05^2, B15, B15^2, + B25, B25^2, B35, B35^2, B45, B45^2, B012345, B012345^2, B012345^3) sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis()) True sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) @@ -310,15 +309,15 @@ def degree(self): A03 1 A13 1 A23 1 - A24 1 - A34 1 A04 1 A14 1 + A24 1 + A34 1 + A05 1 + A15 1 A25 1 A35 1 A45 1 - A05 1 - A15 1 A012345 1 A012345^2 2 sage: v = sum(ch.basis()) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index f3075099f87..edf90f682ab 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -429,7 +429,7 @@ def _latex_(self): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'fy') sage: ch.defining_ideal()._latex_() - I_{FY} of matroid \text{\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}} + 'I_{FY}(\\text{\\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}})' """ from sage.misc.latex import latex return 'I_{{FY}}({})'.format((latex(self._matroid))) @@ -602,10 +602,10 @@ def _latex_(self): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._latex_() - I_{af} of matroid \text{\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}} + 'I_{af}(\\text{\\texttt{Graphic{ }matroid{ }of{ }rank{ }2{ }on{ }3{ }elements}})' """ from sage.misc.latex import latex - return 'I_{{af}}({}) of matroid '.format(latex(self._matroid)) + return 'I_{{af}}({})'.format(latex(self._matroid)) def groebner_basis(self, algorithm='', *args, **kwargs): """ From f4237380c6372ff5e0090938ed7ab6f3f7ba15af Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 10:21:41 +0530 Subject: [PATCH 138/167] Added normal_basis() method for all 3 classes --- src/sage/matroids/chow_ring.py | 73 +------------------ src/sage/matroids/chow_ring_ideal.py | 103 ++++++++++++++++++++++++++- 2 files changed, 103 insertions(+), 73 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 35089995aa9..ec556e5d707 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -177,79 +177,8 @@ def basis(self): sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis()) True """ - F = self._matroid.lattice_of_flats() - H = F.hasse_diagram() - H.delete_vertex(self._ideal.matroid().flats(0)[0]) # remove the empty flat - lattice_flats = Poset(H) - flats = list(lattice_flats) - flats_gen = self._ideal.flats_generator() - R = self._ideal.ring() - flats.sort(key=lambda X: (len(X), sorted(X))) - ranks = {F: self._matroid.rank(F) for F in flats} - monomial_basis = [] - chains = lattice_flats.chains() #Only chains - if self._augmented: - if self._presentation == 'fy': - for subset in chains: - k = len(subset) - if k == 0: - monomial_basis.append(R.one()) - else: - max_powers = [] - max_powers.append(ranks[subset[0]]) - for i in range(1, k): - max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - ranges = [range(1, p) for p in max_powers] - ranges[0] = range(1, max_powers[0] + 1) - for combination in product(*(r for r in ranges)): - #Generating combinations for all powers up to max_powers - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - - elif self._presentation == 'atom-free': - for subset in chains: - max_powers = [] - k = len(subset) - if subset == []: - monomial_basis.append(R.one()) - else: - for i in range(k): - if i == 0: - max_powers.append(ranks[subset[i]]) - else: - max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - ranges = [range(1, p) for p in max_powers] - ranges[0] = range(1, max_powers[0] + 1) - first_rank = ranks[subset[k-1]] + 1 - for combination in product(*(r for r in ranges)): - #Generating combinations for all powers from 1 to max_powers - if sum(combination) <= first_rank: - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - - else: - for subset in chains: - max_powers = [] - k = len(subset) - if (k == 0): - monomial_basis.append(R.one()) - elif not ((k == 1) & (ranks[subset[0]] == 1)): - for i in range(k): - if i == 0: - max_powers.append(ranks[subset[i]]) - else: - max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) - for combination in product(*(range(1, p) for p in max_powers)): - expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] - monomial_basis.append(expression) - from sage.sets.family import Family + monomial_basis = list(self._ideal.normal_basis()) return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) class Element(QuotientRing_generic.Element): diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index edf90f682ab..15a84552743 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -49,6 +49,17 @@ def flats_generator(self): """ return dict(self._flats_generator) + def lattice_flats(self): + F = self._matroid.lattice_of_flats() + H = F.hasse_diagram() + H.delete_vertex(self._ideal.matroid().flats(0)[0]) # remove the empty flat + lattice_flats = Poset(H) + flats = list(lattice_flats) + flats.sort(key=lambda X: (len(X), sorted(X))) + ranks = {F: self._matroid.rank(F) for F in flats} + chains = lattice_flats.chains() #Only chains + return (ranks, chains) + class ChowRingIdeal_nonaug(ChowRingIdeal): r""" @@ -240,6 +251,34 @@ def groebner_basis(self, algorithm='', *args, **kwargs): gb.append(flats_gen[G]*(term)**(ranks[F] - ranks[G])) g_basis = PolynomialSequence(R, [gb]) return g_basis + + def normal_basis(self, algorithm='', *args, **kwargs): + if algorithm == '': + algorithm = 'constructed' + if algorithm != 'constructed': + return super().normal_basis(algorithm=algorithm, *args, **kwargs) + R = self.ring() + flats_gen = self._flats_generator + monomial_basis = [] + ranks, chains = self.lattice_flats() + for subset in chains: + max_powers = [] + k = len(subset) + if (k == 0): + monomial_basis.append(R.one()) + elif not ((k == 1) & (ranks[subset[0]] == 1)): + for i in range(k): + if i == 0: + max_powers.append(ranks[subset[i]]) + else: + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + for combination in product(*(range(1, p) for p in max_powers)): + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + n_basis = PolynomialSequence(R, [monomial_basis]) + return n_basis class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" @@ -478,6 +517,35 @@ def groebner_basis(self, algorithm='', *args, **kwargs): g_basis = PolynomialSequence(poly_ring, [gb]) return g_basis + def normal_basis(self, algorithm='', *args, **kwargs): + if algorithm == '': + algorithm = 'constructed' + if algorithm != 'constructed': + return super().normal_basis(algorithm=algorithm, *args, **kwargs) + R = self.ring() + flats_gen = self._flats_generator + monomial_basis = [] + ranks, chains = self.lattice_flats() + for subset in chains: + k = len(subset) + if k == 0: + monomial_basis.append(R.one()) + else: + max_powers = [] + max_powers.append(ranks[subset[0]]) + for i in range(1, k): + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + ranges = [range(1, p) for p in max_powers] + ranges[0] = range(1, max_powers[0] + 1) + for combination in product(*(r for r in ranges)): + #Generating combinations for all powers up to max_powers + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + n_basis = PolynomialSequence(R, [monomial_basis]) + return n_basis + class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): r""" The augmented Chow ring ideal for a matroid `M` over ring `R` in the @@ -640,4 +708,37 @@ def groebner_basis(self, algorithm='', *args, **kwargs): gb.append((term**self._matroid.rank(F)) + 1) g_basis = PolynomialSequence(poly_ring, [gb]) - return g_basis \ No newline at end of file + return g_basis + + def normal_basis(self, algorithm='', *args, **kwargs): + if algorithm == '': + algorithm = 'constructed' + if algorithm != 'constructed': + return super().normal_basis(algorithm=algorithm, *args, **kwargs) + R = self.ring() + flats_gen = self._flats_generator + monomial_basis = [] + ranks, chains = self.lattice_flats() + for subset in chains: + max_powers = [] + k = len(subset) + if subset == []: + monomial_basis.append(R.one()) + else: + for i in range(k): + if i == 0: + max_powers.append(ranks[subset[i]]) + else: + max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) + ranges = [range(1, p) for p in max_powers] + ranges[0] = range(1, max_powers[0] + 1) + first_rank = ranks[subset[k-1]] + 1 + for combination in product(*(r for r in ranges)): + #Generating combinations for all powers from 1 to max_powers + if sum(combination) <= first_rank: + expression = R.one() + for i in range(k): + expression *= flats_gen[subset[i]]**combination[i] + monomial_basis.append(expression) + n_basis = PolynomialSequence(R, [monomial_basis]) + return n_basis \ No newline at end of file From e4031ada3eb40f8e4cbcdc8317b8a1f48c48d749 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 10:46:41 +0530 Subject: [PATCH 139/167] Added normal_basis() method doctests for all 3 classes --- src/sage/matroids/chow_ring.py | 2 - src/sage/matroids/chow_ring_ideal.py | 57 +++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index ec556e5d707..32559e623e3 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -10,8 +10,6 @@ from sage.rings.quotient_ring import QuotientRing_generic from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis from sage.categories.commutative_rings import CommutativeRings -from itertools import product -from sage.combinat.posets.posets import Poset class ChowRing(QuotientRing_generic): r""" diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 15a84552743..0a20747d923 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -11,6 +11,7 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence from sage.combinat.posets.posets import Poset +from itertools import product class ChowRingIdeal(MPolynomialIdeal): def matroid(self): @@ -50,9 +51,26 @@ def flats_generator(self): return dict(self._flats_generator) def lattice_flats(self): + r""" + Return the ranks and chains of lattice of flats of the matroid. + + EXAMPLES:: + + sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'atom-free') + sage: ch.defining_ideal().lattice_flats() + ({frozenset({'b'}): 1, frozenset({'c'}): 1, frozenset({'d'}): 1, + frozenset({'e'}): 1, frozenset({'f'}): 1, frozenset({'g'}): 1, + frozenset({'d', 'e'}): 2, frozenset({'d', 'f'}): 2, + frozenset({'e', 'f'}): 2, frozenset({'a', 'b', 'f'}): 2, + frozenset({'a', 'c', 'e'}): 2, frozenset({'a', 'd', 'g'}): 2, + frozenset({'b', 'c', 'd'}): 2, frozenset({'b', 'e', 'g'}): 2, + frozenset({'c', 'f', 'g'}): 2, + frozenset({'a', 'b', 'c', 'd', 'e', 'f', 'g'}): 3}, + Set of chains of Finite poset containing 17 elements) + """ F = self._matroid.lattice_of_flats() H = F.hasse_diagram() - H.delete_vertex(self._ideal.matroid().flats(0)[0]) # remove the empty flat + H.delete_vertex(self._matroid.flats(0)[0]) # remove the empty flat lattice_flats = Poset(H) flats = list(lattice_flats) flats.sort(key=lambda X: (len(X), sorted(X))) @@ -253,6 +271,19 @@ def groebner_basis(self, algorithm='', *args, **kwargs): return g_basis def normal_basis(self, algorithm='', *args, **kwargs): + r""" + Return the monomial basis of the quotient ring of this ideal. + + EXAMPLES:: + + sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) + sage: ch.defining_ideal().normal_basis() + [1, Abcd, Aace, Aabf, Adef, Aadg, Abeg, Acfg, Aabcdefg, Aabcdefg^2] + sage: ch = matroids.AG(2,3).chow_ring(QQ, False) + sage: ch.defining_ideal().normal_basis() + [1, A012, A236, A046, A156, A345, A247, A057, A137, A258, A678, + A038, A148, A012345678, A012345678^2] + """ if algorithm == '': algorithm = 'constructed' if algorithm != 'constructed': @@ -518,6 +549,18 @@ def groebner_basis(self, algorithm='', *args, **kwargs): return g_basis def normal_basis(self, algorithm='', *args, **kwargs): + r""" + Return the monomial basis of the quotient ring of this ideal. + + EXAMPLES:: + + sage: ch = matroids.catalog.K33().chow_ring(QQ, True, 'fy') + sage: ch.defining_ideal().normal_basis() + Polynomial Sequence with 1758 Polynomials in 127 Variables + sage: ch = matroids.catalog.Wheel4().chow_ring(QQ, True, 'fy') + sage: ch.defining_ideal().normal_basis() + Polynomial Sequence with 200 Polynomials in 42 Variables + """ if algorithm == '': algorithm = 'constructed' if algorithm != 'constructed': @@ -711,6 +754,18 @@ def groebner_basis(self, algorithm='', *args, **kwargs): return g_basis def normal_basis(self, algorithm='', *args, **kwargs): + r""" + Return the monomial basis of the quotient ring of this ideal. + + EXAMPLES:: + + sage: ch = matroids.Whirl(5).chow_ring(QQ, True, 'atom-free') + sage: ch.defining_ideal().normal_basis() + Polynomial Sequence with 1726 Polynomials in 121 Variables + sage: ch = matroids.Z(4).chow_ring(QQ, True, 'atom-free') + sage: ch.defining_ideal().normal_basis() + Polynomial Sequence with 248 Polynomials in 52 Variables + """ if algorithm == '': algorithm = 'constructed' if algorithm != 'constructed': From 744fc9305240a4c4bfa20c66293f81bc47e75c51 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 10:49:21 +0530 Subject: [PATCH 140/167] Added input parameters for chow_ring() method --- src/sage/matroids/matroid.pyx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 2bf1fd8abc3..56135b71821 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8037,6 +8037,18 @@ cdef class Matroid(SageObject): - :mod:`sage.matroids.chow_ring_ideal` - :mod:`sage.matroids.chow_ring` + INPUT: + + - ``M`` -- matroid + - ``R`` -- commutative ring + - ``augmented`` -- boolean; when ``True``, this is the augmented + Chow ring and if ``False``, this is the non-augmented Chow ring + - ``presentation`` -- string (default: ``None``); one of the following + (ignored if ``augmented=False``) + + * ``"fy"`` - the Feitchner-Yuzvinsky presentation + * ``"atom-free"`` - the atom-free presentation + EXAMPLES:: sage: M = matroids.Wheel(2) From 8468ff121974b2625036dcfd086a5e421e53bdbc Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 10:56:08 +0530 Subject: [PATCH 141/167] Edited augmented chow ring ideal definition for atom-free presentation --- src/sage/matroids/chow_ring_ideal.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 0a20747d923..eda866b26e6 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -601,23 +601,23 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): R[x_{F_1}, \ldots, x_{F_k}], - where - - - `F_1, \ldots, F_k` are the non-empty flats of `M`, - - `I_{af}(M)` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}` - where `F_i` and `F_j` are incomparable elements in the lattice of flats, + where `F_1, \ldots, F_k` are the non-empty flats of `M` and `I_{af}(M)` is + the ideal generated by + + - all quadratic monomials `x_{F} x_{F'}` for all incomparable elements + `F` and `F'` in the lattice of flats, + + - for all flats `F` and `i \in E \setminus F` .. MATH:: x_F \sum_{i \in F'} x_{F'} - for all `i \in E` and `i \notin F`, and + - and for all `i \in E` .. MATH:: - \sum_{i \in F'} (x_{F'})^2 - - for all `i \in E`. + \sum_{i \in F'} (x_{F'})^2. REFERENCES: From 5070e36805fb1c0e3f49b8b8c20cdf84ef2de839 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 10:57:51 +0530 Subject: [PATCH 142/167] Corrected linting errors --- src/sage/matroids/chow_ring_ideal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index eda866b26e6..afa4c6ecfc9 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -269,7 +269,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): gb.append(flats_gen[G]*(term)**(ranks[F] - ranks[G])) g_basis = PolynomialSequence(R, [gb]) return g_basis - + def normal_basis(self, algorithm='', *args, **kwargs): r""" Return the monomial basis of the quotient ring of this ideal. From a022f89a3689e0e4e4eb1effee7d2091861cf8ec Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 14:17:23 +0530 Subject: [PATCH 143/167] Changed augmented chow ring ideal definition --- src/sage/matroids/chow_ring_ideal.py | 55 ++++++++++++++-------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index afa4c6ecfc9..d24c5f422e4 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -327,9 +327,9 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): - `F_1, \ldots, F_k` are the proper flats of `M`, - `e_1, \ldots, e_n` are `n` elements of groundset of `M`, - - `J_M` is the ideal generated by all quadratic forms `x_{F_i} x_{F_j}`, - where `F_i` and `F_j` are incomparable elements in the lattice of - flats and `y_{i} x_F` for every `i \in E` and `i \notin F`, and + - `J_M` is the ideal generated by all quadratic monomials `x_{F} x_{F'}`, + where `F` and `F'` are incomparable elements in the lattice of + flats and `y_{i} x_F` for all flats `F` and `i \in E \setminus F` and - `I_M` is the ideal generated by all linear forms .. MATH:: @@ -346,20 +346,21 @@ class AugmentedChowRingIdeal_fy(ChowRingIdeal): R[y_{e_1}, \ldots, y_{e_n}, y_{F_1 \cup e}, \ldots, y_{F_k \cup e}], - where + where `F_1, \ldots, F_k` are the flats of `M`, `e_1, \ldots, e_n` are + `n` elements of groundset of `M`, and `I_{FY}(M)` is the ideal generated by - - `F_1, \ldots, F_k` are the flats of `M`, - - `e_1, \ldots, e_n` are `n` elements of groundset of `M`, - - `I_{FY}(M)` is the ideal generated by all quadratic forms - `y_{F_i \cup e} y_{F_j \cup e}`, where `F_i` and `F_j` - are incomparable elements in the lattice of flats, `y_{i} y_{F \cup e}` - for every `i \in E` and `i \notin F`, linear forms + - all quadratic monomials `y_{F \cup e} y_{F' \cup e}`, for incomparable + elements `F` and `F'` in the lattice of flats, + + - `y_{i} y_{F \cup e}` for all flats `F` and all `i \in E \setminus F` + + - for all `i \in E` .. MATH:: y_i + \sum_{i \in F} y_{F \cup e} - for all `i \in E` and + - and .. MATH:: @@ -520,13 +521,13 @@ def groebner_basis(self, algorithm='', *args, **kwargs): algorithm = 'constructed' if algorithm != 'constructed': return super().groebner_basis(algorithm=algorithm, *args, **kwargs) - gb = [] #Reduced groebner basis with two eliminated cases + gb = [] # reduced groebner basis with two eliminated cases E = list(self._matroid.groundset()) poly_ring = self.ring() for F in self._flats: for G in self._flats: - if not (F <= G or G <= F): #Non-nested flats - gb.append(self._flats_generator[F]*self._flats_generator[G]) + if not (F <= G or G <= F): # non-nested flats + gb.append(self._flats_generator[F]*self._flats_generator[G]) for i in E: term = poly_ring.zero() @@ -537,11 +538,11 @@ def groebner_basis(self, algorithm='', *args, **kwargs): if H >= G: term1 += self._flats_generator[H] if term != poly_ring.zero(): - gb.append(self._flats_generator[i] + term) #5.7 + gb.append(self._flats_generator[i] + term) #5.7 (MM2022) if term1 != poly_ring.zero(): - gb.append(term1**(self._matroid.rank(G) + 1)) #5.6 + gb.append(term1**(self._matroid.rank(G) + 1)) #5.6 (MM2022) - if G > F: #nested flats + if G > F: # nested flats if term1 != poly_ring.zero(): gb.append(self._flats_generator[F]*term1**(self._matroid.rank(G)-self._matroid.rank(F))) @@ -570,10 +571,10 @@ def normal_basis(self, algorithm='', *args, **kwargs): monomial_basis = [] ranks, chains = self.lattice_flats() for subset in chains: - k = len(subset) - if k == 0: + if not subset: monomial_basis.append(R.one()) else: + k = len(subset) max_powers = [] max_powers.append(ranks[subset[0]]) for i in range(1, k): @@ -581,10 +582,10 @@ def normal_basis(self, algorithm='', *args, **kwargs): ranges = [range(1, p) for p in max_powers] ranges[0] = range(1, max_powers[0] + 1) for combination in product(*(r for r in ranges)): - #Generating combinations for all powers up to max_powers + # generating combinations for all powers up to max_powers expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] + for val, c in zip(subset, combination): + expression *= flats_gen[val] ** c monomial_basis.append(expression) n_basis = PolynomialSequence(R, [monomial_basis]) return n_basis @@ -603,10 +604,10 @@ class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): where `F_1, \ldots, F_k` are the non-empty flats of `M` and `I_{af}(M)` is the ideal generated by - + - all quadratic monomials `x_{F} x_{F'}` for all incomparable elements `F` and `F'` in the lattice of flats, - + - for all flats `F` and `i \in E \setminus F` .. MATH:: @@ -648,7 +649,7 @@ def __init__(self, M, R): """ self._matroid = M self._flats = [X for i in range(1, self._matroid.rank() + 1) - for X in self._matroid.flats(i)] + for X in self._matroid.flats(i)] names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] try: poly_ring = PolynomialRing(R, names) #self.ring @@ -681,7 +682,7 @@ def _gens_constructor(self, poly_ring): for F in self._flats: for G in self._flats: if not (G >= F or F > G): # generators for every pair of non-nested flats - Q.append(self._flats_generator[F] * self._flats_generator[G]) + Q.append(self._flats_generator[F] * self._flats_generator[G]) for x in E: # generators for every set of flats containing element term = poly_ring.zero() for H in flats_containing[x]: @@ -777,7 +778,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): for subset in chains: max_powers = [] k = len(subset) - if subset == []: + if not subset: monomial_basis.append(R.one()) else: for i in range(k): From 3abd40098b6982100861ae75d8f9be09367c0276 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 14:24:05 +0530 Subject: [PATCH 144/167] Corrected doctests --- src/sage/matroids/chow_ring.py | 2 +- src/sage/matroids/chow_ring_ideal.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 32559e623e3..f69a8ea1462 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -125,7 +125,7 @@ def _latex_(self): sage: M1 = matroids.Uniform(2,5) sage: ch = M1.chow_ring(QQ, False) sage: ch._latex_() - '\\Bold{Q}[A_{0}, A_{1}, A_{2}, A_{3}, A_{4}, A_{01234}] / I_{M} + J_{M} of matroid \\begin{array}{l}\n\\text{\\texttt{U(2,{ }5):{ }Matroid{ }of{ }rank{ }2{ }on{ }5{ }elements{ }with{ }circuit{-}closures}}\\\\\n\\text{\\texttt{{\\char`\\{}2:{ }{\\char`\\{}{\\char`\\{}0,{ }1,{ }2,{ }3,{ }4{\\char`\\}}{\\char`\\}}{\\char`\\}}}}\n\\end{array}' + 'A(\\begin{array}{l}\n\\text{\\texttt{U(2,{ }5):{ }Matroid{ }of{ }rank{ }2{ }on{ }5{ }elements{ }with{ }circuit{-}closures}}\\\\\n\\text{\\texttt{{\\char`\\{}2:{ }{\\char`\\{}{\\char`\\{}0,{ }1,{ }2,{ }3,{ }4{\\char`\\}}{\\char`\\}}{\\char`\\}}}}\n\\end{array})_{\\Bold{Q}}' """ from sage.misc.latex import latex base = "A({})_{{{}}}" diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index d24c5f422e4..0c0e8140e32 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -58,13 +58,13 @@ def lattice_flats(self): sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal().lattice_flats() - ({frozenset({'b'}): 1, frozenset({'c'}): 1, frozenset({'d'}): 1, - frozenset({'e'}): 1, frozenset({'f'}): 1, frozenset({'g'}): 1, - frozenset({'d', 'e'}): 2, frozenset({'d', 'f'}): 2, - frozenset({'e', 'f'}): 2, frozenset({'a', 'b', 'f'}): 2, - frozenset({'a', 'c', 'e'}): 2, frozenset({'a', 'd', 'g'}): 2, - frozenset({'b', 'c', 'd'}): 2, frozenset({'b', 'e', 'g'}): 2, - frozenset({'c', 'f', 'g'}): 2, + ({frozenset({'a'}): 1, frozenset({'b'}): 1, frozenset({'c'}): 1, + frozenset({'d'}): 1, frozenset({'e'}): 1, frozenset({'f'}): 1, + frozenset({'g'}): 1, frozenset({'d', 'e'}): 2, + frozenset({'d', 'f'}): 2, frozenset({'e', 'f'}): 2, + frozenset({'a', 'b', 'f'}): 2, frozenset({'a', 'c', 'e'}): 2, + frozenset({'a', 'd', 'g'}): 2, frozenset({'b', 'c', 'd'}): 2, + frozenset({'b', 'e', 'g'}): 2, frozenset({'c', 'f', 'g'}): 2, frozenset({'a', 'b', 'c', 'd', 'e', 'f', 'g'}): 3}, Set of chains of Finite poset containing 17 elements) """ From a6ecb2d618221adfe6db566eb6fb5a6791dc396b Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 14:25:42 +0530 Subject: [PATCH 145/167] Removed flats_generator() method --- src/sage/matroids/chow_ring_ideal.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 0c0e8140e32..6926961f2dc 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -28,28 +28,6 @@ def matroid(self): M = self._matroid return M - def flats_generator(self): - r""" - Return the variables of every corresponding flat/groundset element - of the matroid. - - EXAMPLES:: - - sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) - sage: ch.defining_ideal().flats_generator() - {frozenset({'a'}): Aa, frozenset({'b'}): Ab, frozenset({'c'}): Ac, - frozenset({'d'}): Ad, frozenset({'e'}): Ae, frozenset({'f'}): Af, - frozenset({'g'}): Ag, frozenset({'a', 'b', 'f'}): Aabf, - frozenset({'a', 'c', 'e'}): Aace, - frozenset({'a', 'd', 'g'}): Aadg, - frozenset({'b', 'c', 'd'}): Abcd, - frozenset({'b', 'e', 'g'}): Abeg, - frozenset({'c', 'f', 'g'}): Acfg, - frozenset({'d', 'e', 'f'}): Adef, - frozenset({'a', 'b', 'c', 'd', 'e', 'f', 'g'}): Aabcdefg} - """ - return dict(self._flats_generator) - def lattice_flats(self): r""" Return the ranks and chains of lattice of flats of the matroid. From ad966f0d8fbbff501f041c1b6421a2774d91a936 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 14:30:42 +0530 Subject: [PATCH 146/167] Renamed lattice_flats() method --- src/sage/matroids/chow_ring_ideal.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 6926961f2dc..f5cc622e339 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -28,14 +28,14 @@ def matroid(self): M = self._matroid return M - def lattice_flats(self): + def _lattice_flats(self): r""" Return the ranks and chains of lattice of flats of the matroid. EXAMPLES:: sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'atom-free') - sage: ch.defining_ideal().lattice_flats() + sage: ch.defining_ideal()._lattice_flats() ({frozenset({'a'}): 1, frozenset({'b'}): 1, frozenset({'c'}): 1, frozenset({'d'}): 1, frozenset({'e'}): 1, frozenset({'f'}): 1, frozenset({'g'}): 1, frozenset({'d', 'e'}): 2, @@ -269,7 +269,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): R = self.ring() flats_gen = self._flats_generator monomial_basis = [] - ranks, chains = self.lattice_flats() + ranks, chains = self._lattice_flats() for subset in chains: max_powers = [] k = len(subset) @@ -547,7 +547,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): R = self.ring() flats_gen = self._flats_generator monomial_basis = [] - ranks, chains = self.lattice_flats() + ranks, chains = self._lattice_flats() for subset in chains: if not subset: monomial_basis.append(R.one()) @@ -752,7 +752,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): R = self.ring() flats_gen = self._flats_generator monomial_basis = [] - ranks, chains = self.lattice_flats() + ranks, chains = self._lattice_flats() for subset in chains: max_powers = [] k = len(subset) From 564ac20d0c895b0e4a0dbb5347d7f341af26427b Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 14:46:12 +0530 Subject: [PATCH 147/167] Optimized PolynomialSequence returns --- src/sage/matroids/chow_ring_ideal.py | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index f5cc622e339..300e46770d6 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -56,7 +56,6 @@ def _lattice_flats(self): chains = lattice_flats.chains() #Only chains return (ranks, chains) - class ChowRingIdeal_nonaug(ChowRingIdeal): r""" The Chow ring ideal of a matroid `M`. @@ -212,6 +211,8 @@ def groebner_basis(self, algorithm='', *args, **kwargs): [Aa*Abc, Aa, Abc, Aa*Aabc, Abc*Aabc, Aabc] sage: ch.defining_ideal().groebner_basis().is_groebner() True + sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') + True Another example would be the Groebner basis of the Chow ring ideal of the matroid of the length 3 cycle graph:: @@ -221,6 +222,8 @@ def groebner_basis(self, algorithm='', *args, **kwargs): [A0*A1, A0*A2, A1*A2, A0, A1, A2, A0*A3, A1*A3, A2*A3, A3] sage: ch.defining_ideal().groebner_basis().is_groebner() True + sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') + True """ if algorithm == '': algorithm = 'constructed' @@ -245,8 +248,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): term += flats_gen[G] for G in lattice_flats.order_ideal([F]): gb.append(flats_gen[G]*(term)**(ranks[F] - ranks[G])) - g_basis = PolynomialSequence(R, [gb]) - return g_basis + return PolynomialSequence(R, [gb]) def normal_basis(self, algorithm='', *args, **kwargs): r""" @@ -283,11 +285,10 @@ def normal_basis(self, algorithm='', *args, **kwargs): max_powers.append(ranks[subset[i]] - ranks[subset[i-1]]) for combination in product(*(range(1, p) for p in max_powers)): expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] + for val, c in zip(subset, combination): + expression *= flats_gen[val] ** c monomial_basis.append(expression) - n_basis = PolynomialSequence(R, [monomial_basis]) - return n_basis + return PolynomialSequence(R, [monomial_basis]) class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" @@ -494,6 +495,8 @@ def groebner_basis(self, algorithm='', *args, **kwargs): Polynomial Sequence with 565 Polynomials in 12 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True + sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') + True """ if algorithm == '': algorithm = 'constructed' @@ -524,8 +527,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): if term1 != poly_ring.zero(): gb.append(self._flats_generator[F]*term1**(self._matroid.rank(G)-self._matroid.rank(F))) - g_basis = PolynomialSequence(poly_ring, [gb]) - return g_basis + return PolynomialSequence(poly_ring, [gb]) def normal_basis(self, algorithm='', *args, **kwargs): r""" @@ -565,8 +567,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): for val, c in zip(subset, combination): expression *= flats_gen[val] ** c monomial_basis.append(expression) - n_basis = PolynomialSequence(R, [monomial_basis]) - return n_basis + return PolynomialSequence(R, [monomial_basis]) class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): r""" @@ -709,6 +710,8 @@ def groebner_basis(self, algorithm='', *args, **kwargs): Polynomial Sequence with 22 Polynomials in 3 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True + sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') + True """ if algorithm == '': algorithm = 'constructed' @@ -729,8 +732,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): gb.append(self._flats_generator[F]*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) gb.append((term**self._matroid.rank(F)) + 1) - g_basis = PolynomialSequence(poly_ring, [gb]) - return g_basis + return PolynomialSequence(poly_ring, [gb]) def normal_basis(self, algorithm='', *args, **kwargs): r""" @@ -771,8 +773,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): #Generating combinations for all powers from 1 to max_powers if sum(combination) <= first_rank: expression = R.one() - for i in range(k): - expression *= flats_gen[subset[i]]**combination[i] + for val, c in zip(subset, combination): + expression *= flats_gen[val] ** c monomial_basis.append(expression) - n_basis = PolynomialSequence(R, [monomial_basis]) - return n_basis \ No newline at end of file + return PolynomialSequence(R, [monomial_basis]) \ No newline at end of file From e91e6008eb95a6072ca37c891b4edf49d9ec32c8 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 16:36:54 +0530 Subject: [PATCH 148/167] Optimized groebner_basis() and _gens_constructor() for augmented chow ring ideals --- src/sage/matroids/chow_ring.py | 4 +- src/sage/matroids/chow_ring_ideal.py | 158 ++++++++++++++------------- 2 files changed, 82 insertions(+), 80 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index f69a8ea1462..291a8f7db8d 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -208,9 +208,9 @@ def monomial_coefficients(self, copy=None): sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'atom-free') sage: v = ch.an_element(); v - 0 + Aa sage: v.monomial_coefficients() - {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, + {0: 0, 1: 1, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0, 20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0, 26: 0, 27: 0, 28: 0, 29: 0, 30: 0, 31: 0, 32: 0, 33: 0, diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 300e46770d6..afdafd671ab 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -391,6 +391,10 @@ def __init__(self, M, R): self._flats_generator[x] = poly_ring.gens()[i] for i, F in enumerate(self._flats): self._flats_generator[F] = poly_ring.gens()[len(E) + i] + self._flats_containing = {x: [] for x in E} + for F in self._flats: + for x in F: + self._flats_containing[x].append(F) MPolynomialIdeal.__init__(self, poly_ring, self._gens_constructor(poly_ring)) def _gens_constructor(self, poly_ring): @@ -401,62 +405,54 @@ def _gens_constructor(self, poly_ring): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) - [B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B124, B0*B15, B0*B23, - B0*B345, B0*B1, B1*B2, B1*B3, B1*B4, B1*B5, B1*B025, B1*B04, - B1*B23, B1*B345, B0*B2, B1*B2, B2*B3, B2*B4, B2*B5, B2*B013, - B2*B04, B2*B15, B2*B345, B0*B3, B1*B3, B2*B3, B3*B4, B3*B5, - B3*B025, B3*B04, B3*B124, B3*B15, B0*B4, B1*B4, B2*B4, B3*B4, - B4*B5, B4*B013, B4*B025, B4*B15, B4*B23, B0*B5, B1*B5, B2*B5, - B3*B5, B4*B5, B5*B013, B5*B04, B5*B124, B5*B23, B2*B013, B4*B013, - B5*B013, B013*B025, B013*B04, B013*B124, B013*B15, B013*B23, - B013*B345, B1*B025, B3*B025, B4*B025, B013*B025, B025*B04, - B025*B124, B025*B15, B025*B23, B025*B345, B1*B04, B2*B04, B3*B04, - B5*B04, B013*B04, B025*B04, B04*B124, B04*B15, B04*B23, B04*B345, - B0*B124, B3*B124, B5*B124, B013*B124, B025*B124, B04*B124, - B124*B15, B124*B23, B124*B345, B0*B15, B2*B15, B3*B15, B4*B15, - B013*B15, B025*B15, B04*B15, B124*B15, B15*B23, B15*B345, B0*B23, - B1*B23, B4*B23, B5*B23, B013*B23, B025*B23, B04*B23, B124*B23, - B15*B23, B23*B345, B0*B345, B1*B345, B2*B345, B013*B345, - B025*B345, B04*B345, B124*B345, B15*B345, B23*B345, A0*B, A0*B1, - A0*B2, A0*B3, A0*B4, A0*B5, A0*B124, A0*B15, A0*B23, A0*B345, - A1*B, A1*B0, A1*B2, A1*B3, A1*B4, A1*B5, A1*B025, A1*B04, A1*B23, - A1*B345, A2*B, A2*B0, A2*B1, A2*B3, A2*B4, A2*B5, A2*B013, A2*B04, - A2*B15, A2*B345, A3*B, A3*B0, A3*B1, A3*B2, A3*B4, A3*B5, A3*B025, - A3*B04, A3*B124, A3*B15, A4*B, A4*B0, A4*B1, A4*B2, A4*B3, A4*B5, - A4*B013, A4*B025, A4*B15, A4*B23, A5*B, A5*B0, A5*B1, A5*B2, - A5*B3, A5*B4, A5*B013, A5*B04, A5*B124, A5*B23, + [B0*B1, B0*B2, B0*B3, B0*B23, B0*B4, B0*B124, B0*B5, B0*B15, + B0*B345, B1*B2, B1*B3, B1*B23, B1*B4, B1*B04, B1*B5, B1*B025, + B1*B345, B2*B3, B2*B013, B2*B4, B2*B04, B2*B5, B2*B15, B2*B345, + B3*B4, B3*B04, B3*B124, B3*B5, B3*B025, B3*B15, B013*B23, B4*B013, + B013*B04, B013*B124, B5*B013, B013*B025, B013*B15, B013*B345, + B4*B23, B04*B23, B124*B23, B5*B23, B025*B23, B15*B23, B23*B345, + B4*B5, B4*B025, B4*B15, B04*B124, B5*B04, B025*B04, B04*B15, + B04*B345, B5*B124, B025*B124, B124*B15, B124*B345, B025*B15, + B025*B345, B15*B345, A0*B, A0*B1, A0*B2, A0*B3, A0*B4, A0*B5, + A0*B124, A0*B15, A0*B23, A0*B345, A1*B, A1*B0, A1*B2, A1*B3, + A1*B4, A1*B5, A1*B025, A1*B04, A1*B23, A1*B345, A2*B, A2*B0, + A2*B1, A2*B3, A2*B4, A2*B5, A2*B013, A2*B04, A2*B15, A2*B345, + A3*B, A3*B0, A3*B1, A3*B2, A3*B4, A3*B5, A3*B025, A3*B04, A3*B124, + A3*B15, A4*B, A4*B0, A4*B1, A4*B2, A4*B3, A4*B5, A4*B013, A4*B025, + A4*B15, A4*B23, A5*B, A5*B0, A5*B1, A5*B2, A5*B3, A5*B4, A5*B013, + A5*B04, A5*B124, A5*B23, A0 + B0 + B013 + B025 + B04 + B012345, B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, - A0 + B0 + B013 + B025 + B04 + B012345, A1 + B1 + B013 + B124 + B15 + B012345, + B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, A2 + B2 + B025 + B124 + B23 + B012345, + B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, A3 + B3 + B013 + B23 + B345 + B012345, + B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, A4 + B4 + B04 + B124 + B345 + B012345, - A5 + B5 + B025 + B15 + B345 + B012345] + B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, + A5 + B5 + B025 + B15 + B345 + B012345, + B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345] """ E = list(self._matroid.groundset()) - flats_containing = {x: [] for x in E} - for F in self._flats: - for x in F: - flats_containing[x].append(F) - Q = list() L = list() - term = poly_ring.zero() - for F in self._flats: - term += self._flats_generator[F] - for G in self._flats: - if not (F <= G or G < F): - Q.append(self._flats_generator[F] * self._flats_generator[G]) # Quadratic generators - L.append(term) + reln = lambda x,y: x <= y + lattice_flats = Poset((self._flats, reln)) + antichains = lattice_flats.antichains().elements_of_depth_iterator(2) + for F, G in antichains: + Q.append(self._flats_generator[F] * self._flats_generator[G]) # Quadratic generators for x in E: term = poly_ring.zero() + term1 = poly_ring.zero() for F in self._flats: - if F not in flats_containing[x]: + term1 += self._flats_generator[F] + if F not in self._flats_containing[x]: Q.append(self._flats_generator[x] * self._flats_generator[F]) else: term += self._flats_generator[F] L.append(self._flats_generator[x] + term) #Linear Generators + L.append(term1) return Q + L def _repr_(self): @@ -492,7 +488,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): sage: ch = matroids.Uniform(2,5).chow_ring(QQ, True, 'fy') sage: ch.defining_ideal().groebner_basis(algorithm='') - Polynomial Sequence with 565 Polynomials in 12 Variables + Polynomial Sequence with 33 Polynomials in 12 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') @@ -505,27 +501,28 @@ def groebner_basis(self, algorithm='', *args, **kwargs): gb = [] # reduced groebner basis with two eliminated cases E = list(self._matroid.groundset()) poly_ring = self.ring() + reln = lambda x,y: x <= y + lattice_flats = Poset((self._flats, reln)) + antichains = lattice_flats.antichains().elements_of_depth_iterator(2) + for F, G in antichains: + gb.append(self._flats_generator[F] * self._flats_generator[G]) # non-nested flats + for i in E: + term = poly_ring.zero() + for H in self._flats_containing[i]: + term += self._flats_generator[H] + if term != poly_ring.zero(): + gb.append(self._flats_generator[i] + term) # 5.7 (MM2022) + for F in self._flats: - for G in self._flats: - if not (F <= G or G <= F): # non-nested flats - gb.append(self._flats_generator[F]*self._flats_generator[G]) - - for i in E: - term = poly_ring.zero() - term1 = poly_ring.zero() - for H in self._flats: - if i in H: - term += self._flats_generator[H] - if H >= G: - term1 += self._flats_generator[H] - if term != poly_ring.zero(): - gb.append(self._flats_generator[i] + term) #5.7 (MM2022) - if term1 != poly_ring.zero(): - gb.append(term1**(self._matroid.rank(G) + 1)) #5.6 (MM2022) - - if G > F: # nested flats - if term1 != poly_ring.zero(): - gb.append(self._flats_generator[F]*term1**(self._matroid.rank(G)-self._matroid.rank(F))) + term1 = poly_ring.zero() + for H in lattice_flats.order_filter([F]): + term1 += self._flats_generator[H] + if term1 != poly_ring.zero(): + gb.append(term1**(self._matroid.rank(G) + 1)) #5.6 (MM2022) + order_ideal_modified = lattice_flats.order_ideal([F]) + order_ideal_modified.remove(F) + for G in order_ideal_modified: # nested flats + gb.append(self._flats_generator[F]*term1**(self._matroid.rank(F) - self._matroid.rank(G))) return PolynomialSequence(poly_ring, [gb]) @@ -647,10 +644,9 @@ def _gens_constructor(self, poly_ring): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) - [A0*A1, A0*A2, A0^2 + 2*A0*A3 + A3^2, A1^2 + 2*A1*A3 + A3^2, + [A0*A1, A0*A2, A1*A2, A0^2 + 2*A0*A3 + A3^2, A1^2 + 2*A1*A3 + A3^2, A0*A1 + A0*A3, A2^2 + 2*A2*A3 + A3^2, A0*A2 + A0*A3, - A0*A1, A1*A2, A0*A1 + A1*A3, A1*A2 + A1*A3, A0*A2, A1*A2, - A0*A2 + A2*A3, A1*A2 + A2*A3] + A0*A1 + A1*A3, A1*A2 + A1*A3, A0*A2 + A2*A3, A1*A2 + A2*A3] """ E = list(self._matroid.groundset()) Q = [] # Quadratic generators @@ -658,10 +654,12 @@ def _gens_constructor(self, poly_ring): for F in self._flats: for x in F: flats_containing[x].append(F) + reln = lambda x,y: x <= y + lattice_flats = Poset((self._flats, reln)) + antichains = lattice_flats.antichains().elements_of_depth_iterator(2) + for F, G in antichains: + Q.append(self._flats_generator[F] * self._flats_generator[G]) for F in self._flats: - for G in self._flats: - if not (G >= F or F > G): # generators for every pair of non-nested flats - Q.append(self._flats_generator[F] * self._flats_generator[G]) for x in E: # generators for every set of flats containing element term = poly_ring.zero() for H in flats_containing[x]: @@ -707,7 +705,8 @@ def groebner_basis(self, algorithm='', *args, **kwargs): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal().groebner_basis(algorithm='') - Polynomial Sequence with 22 Polynomials in 3 Variables + [A0*A1, A0*A2, A1*A2, A0^2 + 2*A0*A3 + A3^2, A1^2 + 2*A1*A3 + A3^2, + A2^2 + 2*A2*A3 + A3^2, A0*A3, A1*A3, A2*A3, A3^3] sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') @@ -719,18 +718,21 @@ def groebner_basis(self, algorithm='', *args, **kwargs): return super().groebner_basis(algorithm=algorithm, *args, **kwargs) gb = [] poly_ring = self.ring() + reln = lambda x,y: x <= y + lattice_flats = Poset((self._flats, reln)) + antichains = lattice_flats.antichains().elements_of_depth_iterator(2) + for F, G in antichains: + gb.append(self._flats_generator[F]*self._flats_generator[G]) for F in self._flats: - for G in self._flats: - term = poly_ring.zero() - for H in self._flats: - if H < F: - term += self._flats_generator[H] - if not (F >= G or G > F): #Non nested flats - gb.append(self._flats_generator[F]*self._flats_generator[G]) - elif F < G: #Nested flats - if term != poly_ring.zero(): - gb.append(self._flats_generator[F]*(term**(self._matroid.rank(G) - self._matroid.rank(F)))) - gb.append((term**self._matroid.rank(F)) + 1) + term = poly_ring.zero() + for H in lattice_flats.order_filter([F]): + term += self._flats_generator[H] + if term != poly_ring.zero(): + order_ideal_modified = lattice_flats.order_ideal([F]) + order_ideal_modified.remove(F) + for G in order_ideal_modified: + gb.append(self._flats_generator[G] * (term ** (self._matroid.rank(F) - self._matroid.rank(G)))) + gb.append(term ** (self._matroid.rank(F) + 1)) return PolynomialSequence(poly_ring, [gb]) From 0611846f59ae3c13637076ffe8aaa4fb27bdaf78 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 29 Oct 2024 17:07:45 +0530 Subject: [PATCH 149/167] Edited basis() method --- src/sage/matroids/chow_ring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 291a8f7db8d..57c20813edd 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -176,7 +176,7 @@ def basis(self): True """ from sage.sets.family import Family - monomial_basis = list(self._ideal.normal_basis()) + monomial_basis = self._ideal.normal_basis() return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis]) class Element(QuotientRing_generic.Element): From 77938e8e051f308c9bc4c0ddde1aaa518eb91121 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 30 Oct 2024 11:18:11 +0530 Subject: [PATCH 150/167] Corrected groebner_basis() for FY presentation --- src/sage/matroids/chow_ring_ideal.py | 63 ++++++++++++++++++---------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index afdafd671ab..760d35341d4 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -256,13 +256,19 @@ def normal_basis(self, algorithm='', *args, **kwargs): EXAMPLES:: - sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) - sage: ch.defining_ideal().normal_basis() - [1, Abcd, Aace, Aabf, Adef, Aadg, Abeg, Acfg, Aabcdefg, Aabcdefg^2] + sage: ch = matroids.Z(3).chow_ring(QQ, False) + sage: I = ch.defining_ideal() + sage: I.normal_basis() + [1, Ax2x3y1, Ax1x3y2, Ax1x2y3, Ay1y2y3, Atx1y1, Atx2y2, Atx3y3, Atx1x2x3y1y2y3, Atx1x2x3y1y2y3^2] + sage: set(I.gens().ideal().normal_basis()) == set(I.normal_basis()) + True sage: ch = matroids.AG(2,3).chow_ring(QQ, False) - sage: ch.defining_ideal().normal_basis() + sage: I = ch.defining_ideal() + sage: I.normal_basis() [1, A012, A236, A046, A156, A345, A247, A057, A137, A258, A678, A038, A148, A012345678, A012345678^2] + sage: set(I.gens().ideal().normal_basis()) == set(I.normal_basis()) + True """ if algorithm == '': algorithm = 'constructed' @@ -486,9 +492,9 @@ def groebner_basis(self, algorithm='', *args, **kwargs): EXAMPLES:: - sage: ch = matroids.Uniform(2,5).chow_ring(QQ, True, 'fy') + sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'fy') sage: ch.defining_ideal().groebner_basis(algorithm='') - Polynomial Sequence with 33 Polynomials in 12 Variables + Polynomial Sequence with 178 Polynomials in 25 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') @@ -518,11 +524,11 @@ def groebner_basis(self, algorithm='', *args, **kwargs): for H in lattice_flats.order_filter([F]): term1 += self._flats_generator[H] if term1 != poly_ring.zero(): - gb.append(term1**(self._matroid.rank(G) + 1)) #5.6 (MM2022) + gb.append(term1**(self._matroid.rank(F) + 1)) #5.6 (MM2022) order_ideal_modified = lattice_flats.order_ideal([F]) order_ideal_modified.remove(F) for G in order_ideal_modified: # nested flats - gb.append(self._flats_generator[F]*term1**(self._matroid.rank(F) - self._matroid.rank(G))) + gb.append(self._flats_generator[G]*term1**(self._matroid.rank(F) - self._matroid.rank(G))) return PolynomialSequence(poly_ring, [gb]) @@ -532,12 +538,18 @@ def normal_basis(self, algorithm='', *args, **kwargs): EXAMPLES:: - sage: ch = matroids.catalog.K33().chow_ring(QQ, True, 'fy') - sage: ch.defining_ideal().normal_basis() - Polynomial Sequence with 1758 Polynomials in 127 Variables - sage: ch = matroids.catalog.Wheel4().chow_ring(QQ, True, 'fy') - sage: ch.defining_ideal().normal_basis() - Polynomial Sequence with 200 Polynomials in 42 Variables + sage: ch = matroids.Uniform(2,5).chow_ring(QQ, True, 'fy') + sage: I = ch.defining_ideal() + sage: I.normal_basis() + [1, B0, B1, B2, B3, B4, B01234, B01234^2] + sage: set(I.gens().ideal().normal_basis()) == set(I.normal_basis()) + True + sage: ch = matroids.catalog.Fano().chow_ring(QQ, True, 'fy') + sage: I = ch.defining_ideal() + sage: I.normal_basis() + Polynomial Sequence with 32 Polynomials in 15 Variables + sage: set(I.gens().ideal().normal_basis()) == set(I.normal_basis()) + True """ if algorithm == '': algorithm = 'constructed' @@ -702,11 +714,10 @@ def groebner_basis(self, algorithm='', *args, **kwargs): EXAMPLES:: - sage: M1 = Matroid(graphs.CycleGraph(3)) + sage: M1 = matroids.Uniform(3,6) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: ch.defining_ideal().groebner_basis(algorithm='') - [A0*A1, A0*A2, A1*A2, A0^2 + 2*A0*A3 + A3^2, A1^2 + 2*A1*A3 + A3^2, - A2^2 + 2*A2*A3 + A3^2, A0*A3, A1*A3, A2*A3, A3^3] + Polynomial Sequence with 253 Polynomials in 22 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') @@ -742,12 +753,18 @@ def normal_basis(self, algorithm='', *args, **kwargs): EXAMPLES:: - sage: ch = matroids.Whirl(5).chow_ring(QQ, True, 'atom-free') - sage: ch.defining_ideal().normal_basis() - Polynomial Sequence with 1726 Polynomials in 121 Variables - sage: ch = matroids.Z(4).chow_ring(QQ, True, 'atom-free') - sage: ch.defining_ideal().normal_basis() - Polynomial Sequence with 248 Polynomials in 52 Variables + sage: ch = Matroid(graphs.CycleGraph(3)).chow_ring(QQ, True, 'atom-free') + sage: I = ch.defining_ideal() + sage: I.normal_basis() + [1, A0, A1, A2, A3, A3^2] + sage: set(I.gens().ideal().normal_basis()) == set(I.normal_basis()) + True + sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free') + sage: I = ch.defining_ideal() + sage: I.normal_basis() + Polynomial Sequence with 30 Polynomials in 14 Variables + sage: set(I.gens().ideal().normal_basis()) == set(I.normal_basis()) + True """ if algorithm == '': algorithm = 'constructed' From 00535fe30057fe7e4c33ddeb76dab224307089e3 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 4 Nov 2024 10:49:39 +0530 Subject: [PATCH 151/167] Resolved PEP8 changes --- src/sage/matroids/chow_ring.py | 8 +++++--- src/sage/matroids/chow_ring_ideal.py | 12 ++++++------ src/sage/matroids/matroid.pyx | 9 +++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 57c20813edd..1b7c651fc08 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -109,12 +109,14 @@ def _repr_(self): sage: ch Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) """ + output = "Chow ring of {}".format(self._matroid) if self._augmented is True: + output = "Augmented " + output if self._presentation == 'fy': - return "Augmented Chow ring of {} in Feitchner-Yuzvinsky presentation".format(self._matroid) + output += "Feitchner-Yuzvinsky presentation" elif self._presentation == 'atom-free': - return "Augmented Chow ring of {} in atom-free presentation".format(self._matroid) - return "Chow ring of {}".format(self._matroid) + output += "atom-free presentation" + return output + " over " + repr(self.base_ring()) def _latex_(self): r""" diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 760d35341d4..7199b0478f5 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -165,12 +165,12 @@ def _gens_constructor(self, poly_ring): term *= self._flats_generator[el] I.append(term) #Stanley-Reisner Ideal atoms = self._matroid.lattice_of_flats().atoms() - atoms_gen = {a:poly_ring.zero() for a in atoms} + atoms_gen = {a: poly_ring.zero() for a in atoms} for F in flats: for a in atoms: if a.issubset(F): atoms_gen[a] += self._flats_generator[F] - J = list(atoms_gen.values()) #Linear Generators + J = list(atoms_gen.values()) # Linear generators return I + J def _repr_(self): @@ -457,7 +457,7 @@ def _gens_constructor(self, poly_ring): Q.append(self._flats_generator[x] * self._flats_generator[F]) else: term += self._flats_generator[F] - L.append(self._flats_generator[x] + term) #Linear Generators + L.append(self._flats_generator[x] + term) # Linear generators L.append(term1) return Q + L @@ -672,14 +672,14 @@ def _gens_constructor(self, poly_ring): for F, G in antichains: Q.append(self._flats_generator[F] * self._flats_generator[G]) for F in self._flats: - for x in E: # generators for every set of flats containing element + for x in E: # generators for every set of flats containing element term = poly_ring.zero() for H in flats_containing[x]: term += self._flats_generator[H] if term**2 not in Q: Q.append(term**2) - if F not in flats_containing[x]: #generators for every set of flats not containing element + if F not in flats_containing[x]: # generators for every set of flats not containing element Q.append(self._flats_generator[F]*term) return Q @@ -789,7 +789,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): ranges[0] = range(1, max_powers[0] + 1) first_rank = ranks[subset[k-1]] + 1 for combination in product(*(r for r in ranges)): - #Generating combinations for all powers from 1 to max_powers + # Generating combinations for all powers from 1 to max_powers if sum(combination) <= first_rank: expression = R.one() for val, c in zip(subset, combination): diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 56135b71821..8f680bdd0c0 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8041,10 +8041,11 @@ cdef class Matroid(SageObject): - ``M`` -- matroid - ``R`` -- commutative ring - - ``augmented`` -- boolean; when ``True``, this is the augmented - Chow ring and if ``False``, this is the non-augmented Chow ring - - ``presentation`` -- string (default: ``None``); one of the following - (ignored if ``augmented=False``) + - ``augmented`` -- boolean (default: ``False``); when ``True``, this + is the augmented Chow ring and if ``False``, this is the + non-augmented Chow ring + - ``presentation`` -- string; if ``augmented=True``, then this + must be one of the following (ignored if ``augmented=False``): * ``"fy"`` - the Feitchner-Yuzvinsky presentation * ``"atom-free"`` - the atom-free presentation From de683a8118384b3e30f85fb09018d70cb414afda Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 4 Nov 2024 11:00:15 +0530 Subject: [PATCH 152/167] added multiplication table --- src/sage/matroids/matroid.pyx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 8f680bdd0c0..e81d035848b 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8064,8 +8064,18 @@ cdef class Matroid(SageObject): We construct a more interesting example using the Fano matroid:: sage: M = matroids.catalog.Fano() - sage: A = M.chow_ring(QQ, augmented=False); A + sage: A = M.chow_ring(QQ); A Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + sage: G = A.gens()[6:] + sage: matrix([[x * y for x in G] for y in G]) + [2*Adef^2 0 0 -Adef^2 0 -Adef^2 -Adef^2 0] + [ 0 Adef^2 0 0 0 0 0 0] + [ 0 0 Adef^2 0 0 0 0 0] + [ -Adef^2 0 0 Adef^2 0 0 0 0] + [ 0 0 0 0 Adef^2 0 0 0] + [ -Adef^2 0 0 0 0 Adef^2 0 0] + [ -Adef^2 0 0 0 0 0 Adef^2 0] + [ 0 0 0 0 0 0 0 Adef^2] The augmented Chow ring can also be constructed with the Feitchner-Yuzvinsky and atom-free presentation:: From 0f85f745c6639b53d15fa3fae126c070ced749f8 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 4 Nov 2024 11:04:09 +0530 Subject: [PATCH 153/167] Added computations --- src/sage/matroids/matroid.pyx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index e81d035848b..c6b763ba44c 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8066,7 +8066,13 @@ cdef class Matroid(SageObject): sage: M = matroids.catalog.Fano() sage: A = M.chow_ring(QQ); A Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) - sage: G = A.gens()[6:] + sage: G = A.gens()[6:]; G + (Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef) + sage: Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef = G + sage: Ag*Ag + 2*Adef^2 + sage: Ag*Abeg + -Adef^2 sage: matrix([[x * y for x in G] for y in G]) [2*Adef^2 0 0 -Adef^2 0 -Adef^2 -Adef^2 0] [ 0 Adef^2 0 0 0 0 0 0] From 6ca02bb3082f1b38484f856fa825c2149c977952 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 4 Nov 2024 11:40:16 +0530 Subject: [PATCH 154/167] Edited repr() doctests --- src/sage/matroids/chow_ring.py | 8 +++++--- src/sage/matroids/matroid.pyx | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 1b7c651fc08..86fcc36dd8c 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -70,10 +70,11 @@ class ChowRing(QuotientRing_generic): EXAMPLES:: - sage: M1 = matroids.catalog.P8pp() #more examples + sage: M1 = matroids.catalog.P8pp() sage: ch = M1.chow_ring(QQ, False) sage: ch Chow ring of P8'': Matroid of rank 4 on 8 elements with 8 nonspanning circuits + over Rational Field """ def __init__(self, R, M, augmented, presentation=None): r""" @@ -108,14 +109,15 @@ def _repr_(self): sage: ch = M1.chow_ring(QQ, False) sage: ch Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + over Rational Field """ output = "Chow ring of {}".format(self._matroid) if self._augmented is True: output = "Augmented " + output if self._presentation == 'fy': - output += "Feitchner-Yuzvinsky presentation" + output += " in Feitchner-Yuzvinsky presentation" elif self._presentation == 'atom-free': - output += "atom-free presentation" + output += " in atom-free presentation" return output + " over " + repr(self.base_ring()) def _latex_(self): diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 7e4402b9111..c0c98a26150 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8060,7 +8060,8 @@ cdef class Matroid(SageObject): sage: M = matroids.Wheel(2) sage: A = M.chow_ring(R=ZZ, augmented=False); A - Chow ring of Wheel(2): Regular matroid of rank 2 on 4 elements with 5 bases + Chow ring of Wheel(2): Regular matroid of rank 2 on 4 elements with + 5 bases over Integer Ring sage: A.defining_ideal()._gens_constructor(A.defining_ideal().ring()) [A0*A1, A0*A23, A1*A23, A0 + A0123, A1 + A0123, A23 + A0123] sage: A23 = A.gen(0) @@ -8072,6 +8073,7 @@ cdef class Matroid(SageObject): sage: M = matroids.catalog.Fano() sage: A = M.chow_ring(QQ); A Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) + over Rational Field sage: G = A.gens()[6:]; G (Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef) sage: Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef = G @@ -8095,11 +8097,12 @@ cdef class Matroid(SageObject): sage: M = matroids.Wheel(3) sage: ch = M.chow_ring(QQ, augmented=True, presentation='fy'); ch Augmented Chow ring of Wheel(3): Regular matroid of rank 3 on - 6 elements with 16 bases in Feitchner-Yuzvinsky presentation + 6 elements with 16 bases in Feitchner-Yuzvinsky presentation over + Rational Field sage: M = matroids.Uniform(3, 6) sage: ch = M.chow_ring(QQ, augmented=True, presentation='atom-free'); ch Augmented Chow ring of U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures - {3: {{0, 1, 2, 3, 4, 5}}} in atom-free presentation + {3: {{0, 1, 2, 3, 4, 5}}} in atom-free presentation over Rational Field """ from sage.matroids.chow_ring import ChowRing return ChowRing(M=self, R=R, augmented=augmented, presentation=presentation) From a239339851d5b670857609cded79487fd5956fad Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 4 Nov 2024 11:52:45 +0530 Subject: [PATCH 155/167] Fixed linting error --- src/sage/matroids/chow_ring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 86fcc36dd8c..dbcdcdf4fde 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -117,7 +117,7 @@ def _repr_(self): if self._presentation == 'fy': output += " in Feitchner-Yuzvinsky presentation" elif self._presentation == 'atom-free': - output += " in atom-free presentation" + output += " in atom-free presentation" return output + " over " + repr(self.base_ring()) def _latex_(self): From 71e09d0e7e72cbaf1800308058be22d1edfb0cd4 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 4 Nov 2024 14:09:03 +0530 Subject: [PATCH 156/167] Edited doctest --- src/sage/matroids/matroid.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index c0c98a26150..493d9176045 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8074,6 +8074,10 @@ cdef class Matroid(SageObject): sage: A = M.chow_ring(QQ); A Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) over Rational Field + + Next, we get the non-trivial generators and do some computations:: + + sage: # needs sage.libs.singular sage.rings.finite_rings sage: G = A.gens()[6:]; G (Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef) sage: Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef = G From 79f410bc9a3ff2f9b609740c7a3b32b0f6a698ea Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 4 Nov 2024 14:09:31 +0530 Subject: [PATCH 157/167] Edited doctests --- src/sage/matroids/matroid.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 493d9176045..12c4c6a527a 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8075,7 +8075,7 @@ cdef class Matroid(SageObject): Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) over Rational Field - Next, we get the non-trivial generators and do some computations:: + Next we get the non-trivial generators and do some computations:: sage: # needs sage.libs.singular sage.rings.finite_rings sage: G = A.gens()[6:]; G From 9c9f804c7d0829d0a78c5eb23945b88c5c74103d Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 4 Nov 2024 21:32:10 +0530 Subject: [PATCH 158/167] Incorporated changes --- src/sage/matroids/chow_ring_ideal.py | 24 +++++++++++++----------- src/sage/matroids/matroid.pyx | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 7199b0478f5..0f0eea77f17 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -97,11 +97,11 @@ class ChowRingIdeal_nonaug(ChowRingIdeal): sage: ch = matroids.Uniform(3,6).chow_ring(QQ, False) sage: ch.defining_ideal() Chow ring ideal of U(3, 6): Matroid of rank 3 on 6 elements with - circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} - non augmented + circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} - non augmented sage: ch = matroids.catalog.Fano().chow_ring(QQ, False) sage: ch.defining_ideal() Chow ring ideal of Fano: Binary matroid of rank 3 on 7 elements, - type (3, 0) - non augmented + type (3, 0) - non augmented """ def __init__(self, M, R): r""" @@ -198,7 +198,7 @@ def _latex_(self): I_{M} + J_{M} of matroid \text{\texttt{Matroid{ }of{ }rank{ }2{ }on{ }4{ }elements{ }with{ }3{ }bases}} """ from sage.misc.latex import latex - return 'I_{M} + J_{M} of matroid ' + latex(self._matroid) + return '(I_{{{M}}} + J_{{{M}}}'.format(M=latex(self._matroid)) def groebner_basis(self, algorithm='', *args, **kwargs): r""" @@ -222,7 +222,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): [A0*A1, A0*A2, A1*A2, A0, A1, A2, A0*A3, A1*A3, A2*A3, A3] sage: ch.defining_ideal().groebner_basis().is_groebner() True - sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') + sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().gens().ideal().hilbert_series() True """ if algorithm == '': @@ -237,12 +237,12 @@ def groebner_basis(self, algorithm='', *args, **kwargs): flats_gen = self._flats_generator lattice_flats = Poset((flats, reln)) antichains = lattice_flats.antichains().elements_of_depth_iterator(2) - for subset in antichains: #Taking antichains of size 2 + for subset in antichains: # Taking antichains of size 2 term = R.one() for x in subset: term *= flats_gen[x] gb.append(term) - for F in flats: #Reduced groebner basis by computing the sum first and then the product + for F in flats: # Reduced groebner basis by computing the sum first and then the product term = R.zero() for G in lattice_flats.order_filter([F]): term += flats_gen[G] @@ -296,6 +296,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): monomial_basis.append(expression) return PolynomialSequence(R, [monomial_basis]) + class AugmentedChowRingIdeal_fy(ChowRingIdeal): r""" The augmented Chow ring ideal of matroid `M` over ring `R` in @@ -440,9 +441,9 @@ def _gens_constructor(self, poly_ring): B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345] """ E = list(self._matroid.groundset()) - Q = list() - L = list() - reln = lambda x,y: x <= y + Q = [] + L = [] + reln = lambda x, y: x <= y lattice_flats = Poset((self._flats, reln)) antichains = lattice_flats.antichains().elements_of_depth_iterator(2) for F, G in antichains: @@ -497,7 +498,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): Polynomial Sequence with 178 Polynomials in 25 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True - sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') + sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().gens().ideal().hilbert_series() True """ if algorithm == '': @@ -578,6 +579,7 @@ def normal_basis(self, algorithm='', *args, **kwargs): monomial_basis.append(expression) return PolynomialSequence(R, [monomial_basis]) + class AugmentedChowRingIdeal_atom_free(ChowRingIdeal): r""" The augmented Chow ring ideal for a matroid `M` over ring `R` in the @@ -720,7 +722,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): Polynomial Sequence with 253 Polynomials in 22 Variables sage: ch.defining_ideal().groebner_basis(algorithm='').is_groebner() True - sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') + sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().gens().ideal().hilbert_series() True """ if algorithm == '': diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 12c4c6a527a..0427af753de 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8053,8 +8053,8 @@ cdef class Matroid(SageObject): - ``presentation`` -- string; if ``augmented=True``, then this must be one of the following (ignored if ``augmented=False``): - * ``"fy"`` - the Feitchner-Yuzvinsky presentation - * ``"atom-free"`` - the atom-free presentation + * ``"fy"`` - the Feitchner-Yuzvinsky presentation + * ``"atom-free"`` - the atom-free presentation EXAMPLES:: From 9abd55f6902e7666c00f2fd6060762c7facf8f72 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 5 Nov 2024 10:09:06 +0530 Subject: [PATCH 159/167] Corrected _latex_() doctest --- src/sage/matroids/chow_ring_ideal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 0f0eea77f17..d694fac1dfb 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -195,7 +195,7 @@ def _latex_(self): sage: M1 = Matroid(groundset='abcd', bases=['ab','ad', 'bc']) sage: ch = M1.chow_ring(QQ, False) sage: ch.defining_ideal()._latex_() - I_{M} + J_{M} of matroid \text{\texttt{Matroid{ }of{ }rank{ }2{ }on{ }4{ }elements{ }with{ }3{ }bases}} + '(I_{\\text{\\texttt{Matroid{ }of{ }rank{ }2{ }on{ }4{ }elements{ }with{ }3{ }bases}}} + J_{\\text{\\texttt{Matroid{ }of{ }rank{ }2{ }on{ }4{ }elements{ }with{ }3{ }bases}}}' """ from sage.misc.latex import latex return '(I_{{{M}}} + J_{{{M}}}'.format(M=latex(self._matroid)) From ace86c164d89299d838dc89d419468f1917cc9b6 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 5 Nov 2024 11:15:19 +0530 Subject: [PATCH 160/167] Edited groebner_basis() for nonaug case --- src/sage/matroids/chow_ring_ideal.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index d694fac1dfb..c9e9856de7a 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -247,7 +247,11 @@ def groebner_basis(self, algorithm='', *args, **kwargs): for G in lattice_flats.order_filter([F]): term += flats_gen[G] for G in lattice_flats.order_ideal([F]): - gb.append(flats_gen[G]*(term)**(ranks[F] - ranks[G])) + if G != F: + gb.append(flats_gen[G]*(term) ** (ranks[F] - ranks[G])) + + gb.append(term ** ranks[F]) + return PolynomialSequence(R, [gb]) def normal_basis(self, algorithm='', *args, **kwargs): From 73d6e59f199352d70def7768da1a542617979911 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 5 Nov 2024 11:17:01 +0530 Subject: [PATCH 161/167] Edited doctests --- src/sage/matroids/chow_ring_ideal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index c9e9856de7a..ea8e05d4829 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -211,7 +211,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): [Aa*Abc, Aa, Abc, Aa*Aabc, Abc*Aabc, Aabc] sage: ch.defining_ideal().groebner_basis().is_groebner() True - sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().hilbert_series(algorithm='singular') + sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().gens().ideal().hilbert_series() True Another example would be the Groebner basis of the Chow ring ideal of From c8936d1775ff1216b719d7c5b079b774b7b0a095 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 5 Nov 2024 12:46:50 +0530 Subject: [PATCH 162/167] Edited doctests --- src/sage/matroids/chow_ring.py | 6 +++--- src/sage/matroids/chow_ring_ideal.py | 6 +++--- src/sage/matroids/matroid.pyx | 31 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index dbcdcdf4fde..427a7a8493b 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -192,9 +192,9 @@ def to_vector(self, order=None): sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, False) sage: v = ch.an_element(); v - 0 + -A01 - A02 - A03 - A04 - A05 - A012345 sage: v.to_vector() - (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + (0, -1, -1, 0, -1, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0) """ P = self.parent() B = P.basis() @@ -253,7 +253,7 @@ def degree(self): A012345^2 2 sage: v = sum(ch.basis()) sage: v.degree() - 0 + 2 """ return self.lift().degree() diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index ea8e05d4829..0c5fd58d0e4 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -163,7 +163,7 @@ def _gens_constructor(self, poly_ring): term = poly_ring.one() for el in subset: term *= self._flats_generator[el] - I.append(term) #Stanley-Reisner Ideal + I.append(term) # Stanley-Reisner Ideal atoms = self._matroid.lattice_of_flats().atoms() atoms_gen = {a: poly_ring.zero() for a in atoms} for F in flats: @@ -208,7 +208,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): sage: ch = Matroid(groundset='abc', bases=['ab', 'ac']).chow_ring(QQ, False) sage: ch.defining_ideal().groebner_basis() - [Aa*Abc, Aa, Abc, Aa*Aabc, Abc*Aabc, Aabc] + [Aa*Abc, Aa + Aabc, Abc + Aabc, Aa*Aabc, Abc*Aabc, Aabc^2] sage: ch.defining_ideal().groebner_basis().is_groebner() True sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().gens().ideal().hilbert_series() @@ -219,7 +219,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): sage: ch = Matroid(graphs.CycleGraph(3)).chow_ring(QQ, False) sage: ch.defining_ideal().groebner_basis() - [A0*A1, A0*A2, A1*A2, A0, A1, A2, A0*A3, A1*A3, A2*A3, A3] + [A0*A1, A0*A2, A1*A2, A0 + A3, A1 + A3, A2 + A3, A0*A3, A1*A3, A2*A3, A3^2] sage: ch.defining_ideal().groebner_basis().is_groebner() True sage: ch.defining_ideal().hilbert_series() == ch.defining_ideal().gens().ideal().hilbert_series() diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 0427af753de..a2d6ff57eb3 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8078,22 +8078,23 @@ cdef class Matroid(SageObject): Next we get the non-trivial generators and do some computations:: sage: # needs sage.libs.singular sage.rings.finite_rings - sage: G = A.gens()[6:]; G - (Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef) - sage: Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef = G - sage: Ag*Ag - 2*Adef^2 - sage: Ag*Abeg - -Adef^2 + sage: G = A.gens()[7:]; G + (Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef, Aabcdefg) + sage: Aabf, Aace, Aadg, Abcd, Abeg, Acfg Adef, Aabcdefg = G + sage: Aabf*Aabf + 2*Aabcdefgf^2 + sage: Aabf*Acfg + -Aabcdefg^2 sage: matrix([[x * y for x in G] for y in G]) - [2*Adef^2 0 0 -Adef^2 0 -Adef^2 -Adef^2 0] - [ 0 Adef^2 0 0 0 0 0 0] - [ 0 0 Adef^2 0 0 0 0 0] - [ -Adef^2 0 0 Adef^2 0 0 0 0] - [ 0 0 0 0 Adef^2 0 0 0] - [ -Adef^2 0 0 0 0 Adef^2 0 0] - [ -Adef^2 0 0 0 0 0 Adef^2 0] - [ 0 0 0 0 0 0 0 Adef^2] + [-2*Aabcdefg^2 0 0 Aabcdefg^2 0 Aabcdefg^2 Aabcdefg^2 0 -Aabcdefg^2] + [ 0 -Aabcdefg^2 0 0 0 0 0 0 0] + [ 0 0 -Aabcdefg^2 0 0 0 0 0 0] + [ Aabcdefg^2 0 0 -Aabcdefg^2 0 0 0 0 0] + [ 0 0 0 0 -Aabcdefg^2 0 0 0 0] + [ Aabcdefg^2 0 0 0 0 -Aabcdefg^2 0 0 0] + [ Aabcdefg^2 0 0 0 0 0 -Aabcdefg^2 0 0] + [ 0 0 0 0 0 0 0 -Aabcdefg^2 0] + [ -Aabcdefg^2 0 0 0 0 0 0 0 Aabcdefg^2] The augmented Chow ring can also be constructed with the Feitchner-Yuzvinsky and atom-free presentation:: From d841b58c354dc5416cc21b0cea0616f2f25ef9e5 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 5 Nov 2024 13:07:14 +0530 Subject: [PATCH 163/167] Resolved PEP8 changes and added matroid() method --- src/sage/matroids/chow_ring.py | 14 ++++++++++++++ src/sage/matroids/chow_ring_ideal.py | 14 +++++--------- src/sage/matroids/matroid.pyx | 19 +++++++++---------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index 427a7a8493b..a404e32cf90 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -137,6 +137,20 @@ def _latex_(self): base += "^*" return base.format(latex(self._matroid), latex(self.base_ring())) + def matroid(self): + r""" + Return the matroid of ``self``. + + EXAMPLES:: + + sage: ch = matroids.Uniform(3,6).chow_ring(QQ, True, 'fy') + sage: ch.matroid() + U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures + {3: {{0, 1, 2, 3, 4, 5}}} + """ + M = self._matroid + return M + def _coerce_map_from_base_ring(self): r""" Disable the coercion from the base ring from the category. diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 0c5fd58d0e4..4d62ed233ab 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -155,8 +155,7 @@ def _gens_constructor(self, poly_ring): Ag + Aadg + Abeg + Acfg + Aabcdefg] """ flats = list(self._flats_generator) - reln = lambda x,y: x <= y - lattice_flats = Poset((flats, reln)) + lattice_flats = Poset((flats, lambda x, y: x <= y)) I = [] subsets = lattice_flats.antichains().elements_of_depth_iterator(2) for subset in subsets: @@ -231,11 +230,10 @@ def groebner_basis(self, algorithm='', *args, **kwargs): return super().groebner_basis(algorithm=algorithm, *args, **kwargs) flats = sorted(list(self._flats_generator), key=len) ranks = {F: self._matroid.rank(F) for F in flats} - gb = list() + gb = [] R = self.ring() - reln = lambda x,y: x <= y flats_gen = self._flats_generator - lattice_flats = Poset((flats, reln)) + lattice_flats = Poset((flats, lambda x, y: x <= y)) antichains = lattice_flats.antichains().elements_of_depth_iterator(2) for subset in antichains: # Taking antichains of size 2 term = R.one() @@ -447,8 +445,7 @@ def _gens_constructor(self, poly_ring): E = list(self._matroid.groundset()) Q = [] L = [] - reln = lambda x, y: x <= y - lattice_flats = Poset((self._flats, reln)) + lattice_flats = Poset((self._flats, lambda x, y: x <= y)) antichains = lattice_flats.antichains().elements_of_depth_iterator(2) for F, G in antichains: Q.append(self._flats_generator[F] * self._flats_generator[G]) # Quadratic generators @@ -735,8 +732,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): return super().groebner_basis(algorithm=algorithm, *args, **kwargs) gb = [] poly_ring = self.ring() - reln = lambda x,y: x <= y - lattice_flats = Poset((self._flats, reln)) + lattice_flats = Poset((self._flats, lambda x, y: x <= y)) antichains = lattice_flats.antichains().elements_of_depth_iterator(2) for F, G in antichains: gb.append(self._flats_generator[F]*self._flats_generator[G]) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index a2d6ff57eb3..ad91bc392ab 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8080,21 +8080,20 @@ cdef class Matroid(SageObject): sage: # needs sage.libs.singular sage.rings.finite_rings sage: G = A.gens()[7:]; G (Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef, Aabcdefg) - sage: Aabf, Aace, Aadg, Abcd, Abeg, Acfg Adef, Aabcdefg = G + sage: Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef, Aabcdefg = G sage: Aabf*Aabf 2*Aabcdefgf^2 sage: Aabf*Acfg -Aabcdefg^2 sage: matrix([[x * y for x in G] for y in G]) - [-2*Aabcdefg^2 0 0 Aabcdefg^2 0 Aabcdefg^2 Aabcdefg^2 0 -Aabcdefg^2] - [ 0 -Aabcdefg^2 0 0 0 0 0 0 0] - [ 0 0 -Aabcdefg^2 0 0 0 0 0 0] - [ Aabcdefg^2 0 0 -Aabcdefg^2 0 0 0 0 0] - [ 0 0 0 0 -Aabcdefg^2 0 0 0 0] - [ Aabcdefg^2 0 0 0 0 -Aabcdefg^2 0 0 0] - [ Aabcdefg^2 0 0 0 0 0 -Aabcdefg^2 0 0] - [ 0 0 0 0 0 0 0 -Aabcdefg^2 0] - [ -Aabcdefg^2 0 0 0 0 0 0 0 Aabcdefg^2] + [-Aabcdefg^2 0 0 0 0 0 0 0] + [ 0 -Aabcdefg^2 0 0 0 0 0 0] + [ 0 0 -Aabcdefg^2 0 0 0 0 0] + [ 0 0 0 -Aabcdefg^2 0 0 0 0] + [ 0 0 0 0 -Aabcdefg^2 0 0 0] + [ 0 0 0 0 0 -Aabcdefg^2 0 0] + [ 0 0 0 0 0 0 -Aabcdefg^2 0] + [ 0 0 0 0 0 0 0 Aabcdefg^2] The augmented Chow ring can also be constructed with the Feitchner-Yuzvinsky and atom-free presentation:: From 79d3371790e38cb44e91d0b808749279312da554 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 5 Nov 2024 13:26:30 +0530 Subject: [PATCH 164/167] Corrected doctests --- src/sage/matroids/matroid.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index ad91bc392ab..e06f9b423cf 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -8082,9 +8082,9 @@ cdef class Matroid(SageObject): (Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef, Aabcdefg) sage: Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef, Aabcdefg = G sage: Aabf*Aabf - 2*Aabcdefgf^2 - sage: Aabf*Acfg -Aabcdefg^2 + sage: Aabf*Acfg + 0 sage: matrix([[x * y for x in G] for y in G]) [-Aabcdefg^2 0 0 0 0 0 0 0] [ 0 -Aabcdefg^2 0 0 0 0 0 0] From eb201659dde486749366dfd10fdc077c89e195d7 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 5 Nov 2024 22:07:02 +0530 Subject: [PATCH 165/167] Edited matroid() method --- src/sage/matroids/chow_ring.py | 3 +-- src/sage/matroids/chow_ring_ideal.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/sage/matroids/chow_ring.py b/src/sage/matroids/chow_ring.py index a404e32cf90..173c8db7f84 100644 --- a/src/sage/matroids/chow_ring.py +++ b/src/sage/matroids/chow_ring.py @@ -148,8 +148,7 @@ def matroid(self): U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} """ - M = self._matroid - return M + return self._matroid def _coerce_map_from_base_ring(self): r""" diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 4d62ed233ab..53bdfedd246 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -25,8 +25,7 @@ def matroid(self): U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures {3: {{0, 1, 2, 3, 4, 5}}} """ - M = self._matroid - return M + return self._matroid def _lattice_flats(self): r""" From 51f66ddf8ab0e25e2bf76ec599d259b75b15122b Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 11 Nov 2024 10:54:58 +0530 Subject: [PATCH 166/167] Corrected _gens_constructor() doctest --- src/sage/matroids/chow_ring_ideal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 53bdfedd246..46d4d39031e 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -130,7 +130,7 @@ def _gens_constructor(self, poly_ring): EXAMPLES:: sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) - sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) + sage: sorted(ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring())) [Aa*Ab, Aa*Ac, Aa*Ae, Aa*Ad, Aa*Ade, Aa*Abcd, Aa*Af, Aa*Adf, Aa*Aef, Aa*Ag, Aa*Abeg, Aa*Acfg, Ab*Ac, Ab*Ae, Ab*Aace, Ab*Ad, Ab*Ade, Ab*Af, Ab*Adf, Ab*Aef, Ab*Ag, Ab*Aadg, Ab*Acfg, Ac*Ae, @@ -412,7 +412,7 @@ def _gens_constructor(self, poly_ring): EXAMPLES:: sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') - sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) + sage: sorted(ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring())) [B0*B1, B0*B2, B0*B3, B0*B23, B0*B4, B0*B124, B0*B5, B0*B15, B0*B345, B1*B2, B1*B3, B1*B23, B1*B4, B1*B04, B1*B5, B1*B025, B1*B345, B2*B3, B2*B013, B2*B4, B2*B04, B2*B5, B2*B15, B2*B345, @@ -657,7 +657,7 @@ def _gens_constructor(self, poly_ring): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') - sage: ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring()) + sage: sorted(ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring())) [A0*A1, A0*A2, A1*A2, A0^2 + 2*A0*A3 + A3^2, A1^2 + 2*A1*A3 + A3^2, A0*A1 + A0*A3, A2^2 + 2*A2*A3 + A3^2, A0*A2 + A0*A3, A0*A1 + A1*A3, A1*A2 + A1*A3, A0*A2 + A2*A3, A1*A2 + A2*A3] From a7eec7ba8bcf557e40565651af3d2dbc8a24ee94 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 11 Nov 2024 12:01:44 +0530 Subject: [PATCH 167/167] Formatted doctests --- src/sage/matroids/chow_ring_ideal.py | 89 ++++++++++++++-------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index 46d4d39031e..d0ac04a23ee 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -131,27 +131,27 @@ def _gens_constructor(self, poly_ring): sage: ch = matroids.catalog.NonFano().chow_ring(QQ, False) sage: sorted(ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring())) - [Aa*Ab, Aa*Ac, Aa*Ae, Aa*Ad, Aa*Ade, Aa*Abcd, Aa*Af, Aa*Adf, - Aa*Aef, Aa*Ag, Aa*Abeg, Aa*Acfg, Ab*Ac, Ab*Ae, Ab*Aace, Ab*Ad, - Ab*Ade, Ab*Af, Ab*Adf, Ab*Aef, Ab*Ag, Ab*Aadg, Ab*Acfg, Ac*Ae, - Ac*Ad, Ac*Ade, Ac*Af, Ac*Aabf, Ac*Adf, Ac*Aef, Ac*Ag, Ac*Aadg, - Ac*Abeg, Ad*Ae, Ae*Abcd, Ae*Af, Ae*Aabf, Ae*Adf, Ae*Ag, Ae*Aadg, - Ae*Acfg, Ad*Aace, Aace*Ade, Aace*Abcd, Af*Aace, Aabf*Aace, - Aace*Adf, Aace*Aef, Ag*Aace, Aace*Aadg, Aace*Abeg, Aace*Acfg, - Ad*Af, Ad*Aabf, Ad*Aef, Ad*Ag, Ad*Abeg, Ad*Acfg, Abcd*Ade, Af*Ade, - Aabf*Ade, Ade*Adf, Ade*Aef, Ag*Ade, Aadg*Ade, Abeg*Ade, Acfg*Ade, - Af*Abcd, Aabf*Abcd, Abcd*Adf, Abcd*Aef, Ag*Abcd, Aadg*Abcd, - Abcd*Abeg, Abcd*Acfg, Af*Ag, Af*Aadg, Af*Abeg, Aabf*Adf, Aabf*Aef, - Ag*Aabf, Aabf*Aadg, Aabf*Abeg, Aabf*Acfg, Adf*Aef, Ag*Adf, - Aadg*Adf, Abeg*Adf, Acfg*Adf, Ag*Aef, Aadg*Aef, Abeg*Aef, - Acfg*Aef, Aadg*Abeg, Aadg*Acfg, Abeg*Acfg, - Aa + Aabf + Aace + Aadg + Aabcdefg, - Ab + Aabf + Abcd + Abeg + Aabcdefg, - Ac + Aace + Abcd + Acfg + Aabcdefg, - Ad + Aadg + Abcd + Ade + Adf + Aabcdefg, - Ae + Aace + Abeg + Ade + Aef + Aabcdefg, + [Ag + Aadg + Abeg + Acfg + Aabcdefg, Af + Aabf + Acfg + Adf + Aef + Aabcdefg, - Ag + Aadg + Abeg + Acfg + Aabcdefg] + Ae + Aace + Abeg + Ade + Aef + Aabcdefg, + Ad + Aadg + Abcd + Ade + Adf + Aabcdefg, + Ac + Aace + Abcd + Acfg + Aabcdefg, + Ab + Aabf + Abcd + Abeg + Aabcdefg, + Aa + Aabf + Aace + Aadg + Aabcdefg, + Adf*Aef, Ade*Aef, Acfg*Aef, Abeg*Aef, Abcd*Aef, Aadg*Aef, + Aace*Aef, Aabf*Aef, Ag*Aef, Ad*Aef, Ac*Aef, Ab*Aef, Aa*Aef, + Ade*Adf, Acfg*Adf, Abeg*Adf, Abcd*Adf, Aadg*Adf, Aace*Adf, + Aabf*Adf, Ag*Adf, Ae*Adf, Ac*Adf, Ab*Adf, Aa*Adf, Acfg*Ade, + Abeg*Ade, Abcd*Ade, Aadg*Ade, Aace*Ade, Aabf*Ade, Ag*Ade, Af*Ade, + Ac*Ade, Ab*Ade, Aa*Ade, Abeg*Acfg, Abcd*Acfg, Aadg*Acfg, + Aace*Acfg, Aabf*Acfg, Ae*Acfg, Ad*Acfg, Ab*Acfg, Aa*Acfg, + Abcd*Abeg, Aadg*Abeg, Aace*Abeg, Aabf*Abeg, Af*Abeg, Ad*Abeg, + Ac*Abeg, Aa*Abeg, Aadg*Abcd, Aace*Abcd, Aabf*Abcd, Ag*Abcd, + Af*Abcd, Ae*Abcd, Aa*Abcd, Aace*Aadg, Aabf*Aadg, Af*Aadg, Ae*Aadg, + Ac*Aadg, Ab*Aadg, Aabf*Aace, Ag*Aace, Af*Aace, Ad*Aace, Ab*Aace, + Ag*Aabf, Ae*Aabf, Ad*Aabf, Ac*Aabf, Af*Ag, Ae*Ag, Ad*Ag, Ac*Ag, + Ab*Ag, Aa*Ag, Ae*Af, Ad*Af, Ac*Af, Ab*Af, Aa*Af, Ad*Ae, Ac*Ae, + Ab*Ae, Aa*Ae, Ac*Ad, Ab*Ad, Aa*Ad, Ab*Ac, Aa*Ac, Aa*Ab] """ flats = list(self._flats_generator) lattice_flats = Poset((flats, lambda x, y: x <= y)) @@ -413,33 +413,34 @@ def _gens_constructor(self, poly_ring): sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'fy') sage: sorted(ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring())) - [B0*B1, B0*B2, B0*B3, B0*B23, B0*B4, B0*B124, B0*B5, B0*B15, - B0*B345, B1*B2, B1*B3, B1*B23, B1*B4, B1*B04, B1*B5, B1*B025, - B1*B345, B2*B3, B2*B013, B2*B4, B2*B04, B2*B5, B2*B15, B2*B345, - B3*B4, B3*B04, B3*B124, B3*B5, B3*B025, B3*B15, B013*B23, B4*B013, - B013*B04, B013*B124, B5*B013, B013*B025, B013*B15, B013*B345, - B4*B23, B04*B23, B124*B23, B5*B23, B025*B23, B15*B23, B23*B345, - B4*B5, B4*B025, B4*B15, B04*B124, B5*B04, B025*B04, B04*B15, - B04*B345, B5*B124, B025*B124, B124*B15, B124*B345, B025*B15, - B025*B345, B15*B345, A0*B, A0*B1, A0*B2, A0*B3, A0*B4, A0*B5, - A0*B124, A0*B15, A0*B23, A0*B345, A1*B, A1*B0, A1*B2, A1*B3, - A1*B4, A1*B5, A1*B025, A1*B04, A1*B23, A1*B345, A2*B, A2*B0, - A2*B1, A2*B3, A2*B4, A2*B5, A2*B013, A2*B04, A2*B15, A2*B345, - A3*B, A3*B0, A3*B1, A3*B2, A3*B4, A3*B5, A3*B025, A3*B04, A3*B124, - A3*B15, A4*B, A4*B0, A4*B1, A4*B2, A4*B3, A4*B5, A4*B013, A4*B025, - A4*B15, A4*B23, A5*B, A5*B0, A5*B1, A5*B2, A5*B3, A5*B4, A5*B013, - A5*B04, A5*B124, A5*B23, A0 + B0 + B013 + B025 + B04 + B012345, + [B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, - A1 + B1 + B013 + B124 + B15 + B012345, B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, - A2 + B2 + B025 + B124 + B23 + B012345, B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, - A3 + B3 + B013 + B23 + B345 + B012345, B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, - A4 + B4 + B04 + B124 + B345 + B012345, B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345, A5 + B5 + B025 + B15 + B345 + B012345, - B + B0 + B1 + B2 + B3 + B4 + B5 + B013 + B025 + B04 + B124 + B15 + B23 + B345 + B012345] + A4 + B4 + B04 + B124 + B345 + B012345, + A3 + B3 + B013 + B23 + B345 + B012345, + A2 + B2 + B025 + B124 + B23 + B012345, + A1 + B1 + B013 + B124 + B15 + B012345, + A0 + B0 + B013 + B025 + B04 + B012345, + B23*B345, B15*B345, B124*B345, B04*B345, B025*B345, B013*B345, + B2*B345, B1*B345, B0*B345, A2*B345, A1*B345, A0*B345, B15*B23, + B124*B23, B04*B23, B025*B23, B013*B23, B5*B23, B4*B23, B1*B23, + B0*B23, A5*B23, A4*B23, A1*B23, A0*B23, B124*B15, B04*B15, + B025*B15, B013*B15, B4*B15, B3*B15, B2*B15, B0*B15, A4*B15, + A3*B15, A2*B15, A0*B15, B04*B124, B025*B124, B013*B124, B5*B124, + B3*B124, B0*B124, A5*B124, A3*B124, A0*B124, B025*B04, B013*B04, + B5*B04, B3*B04, B2*B04, B1*B04, A5*B04, A3*B04, A2*B04, A1*B04, + B013*B025, B4*B025, B3*B025, B1*B025, A4*B025, A3*B025, A1*B025, + B5*B013, B4*B013, B2*B013, A5*B013, A4*B013, A2*B013, B4*B5, + B3*B5, B2*B5, B1*B5, B0*B5, A4*B5, A3*B5, A2*B5, A1*B5, A0*B5, + B3*B4, B2*B4, B1*B4, B0*B4, A5*B4, A3*B4, A2*B4, A1*B4, A0*B4, + B2*B3, B1*B3, B0*B3, A5*B3, A4*B3, A2*B3, A1*B3, A0*B3, B1*B2, + B0*B2, A5*B2, A4*B2, A3*B2, A1*B2, A0*B2, B0*B1, A5*B1, A4*B1, + A3*B1, A2*B1, A0*B1, A5*B0, A4*B0, A3*B0, A2*B0, A1*B0, A5*B, + A4*B, A3*B, A2*B, A1*B, A0*B] """ E = list(self._matroid.groundset()) Q = [] @@ -658,9 +659,9 @@ def _gens_constructor(self, poly_ring): sage: M1 = Matroid(graphs.CycleGraph(3)) sage: ch = M1.chow_ring(QQ, True, 'atom-free') sage: sorted(ch.defining_ideal()._gens_constructor(ch.defining_ideal().ring())) - [A0*A1, A0*A2, A1*A2, A0^2 + 2*A0*A3 + A3^2, A1^2 + 2*A1*A3 + A3^2, - A0*A1 + A0*A3, A2^2 + 2*A2*A3 + A3^2, A0*A2 + A0*A3, - A0*A1 + A1*A3, A1*A2 + A1*A3, A0*A2 + A2*A3, A1*A2 + A2*A3] + [A2^2 + 2*A2*A3 + A3^2, A1*A2, A1*A2 + A2*A3, A1*A2 + A1*A3, A0*A2, + A0*A2 + A2*A3, A0*A2 + A0*A3, A1^2 + 2*A1*A3 + A3^2, A0*A1, + A0*A1 + A1*A3, A0*A1 + A0*A3, A0^2 + 2*A0*A3 + A3^2] """ E = list(self._matroid.groundset()) Q = [] # Quadratic generators