Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage.combinat: Update # needs #36916

Merged
merged 8 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sage.combinat: Update # needs
  • Loading branch information
Matthias Koeppe committed Dec 19, 2023
commit e6ac10361c4ef494be88ffa49fa8cee9f70ab536
76 changes: 45 additions & 31 deletions src/sage/combinat/posets/lattices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2298,8 +2298,8 @@ def is_orthocomplemented(self, unique=False):
sage: D6.is_orthocomplemented(unique=True) # needs sage.groups
False

sage: hexagon = LatticePoset({0:[1, 2], 1:[3], 2:[4], 3:[5], 4:[5]})
sage: hexagon.is_orthocomplemented(unique=True)
sage: hexagon = LatticePoset({0: [1, 2], 1: [3], 2: [4], 3:[5], 4: [5]})
sage: hexagon.is_orthocomplemented(unique=True) # needs sage.groups
True

.. SEEALSO::
Expand Down Expand Up @@ -4046,7 +4046,7 @@ def is_subdirectly_reducible(self, certificate=False):

TESTS::

sage: [posets.ChainPoset(i).is_subdirectly_reducible() for i in range(5)]
sage: [posets.ChainPoset(i).is_subdirectly_reducible() for i in range(5)] # needs sage.combinat
[False, False, False, True, True]
"""
H = self._hasse_diagram
Expand Down Expand Up @@ -4256,7 +4256,7 @@ def is_constructible_by_doublings(self, type) -> bool:
sage: L = L.day_doubling([(3,0), (1,1), (2,1)]) # An upper pseudo-interval
sage: L.is_constructible_by_doublings('upper')
False
sage: L.is_constructible_by_doublings('convex')
sage: L.is_constructible_by_doublings('convex') # needs sage.combinat
True

An example of a lattice that can be constructed by doublings
Expand Down Expand Up @@ -4378,18 +4378,20 @@ def is_isoform(self, certificate=False):

EXAMPLES::

sage: L = LatticePoset({1:[2, 3, 4], 2: [5, 6], 3: [6, 7], 4: [7], 5: [8], 6: [8], 7: [8]})
sage: L.is_isoform()
sage: L = LatticePoset({1: [2, 3, 4], 2: [5, 6], 3: [6, 7],
....: 4: [7], 5: [8], 6: [8], 7: [8]})
sage: L.is_isoform() # needs sage.combinat
True

Every isoform lattice is (trivially) uniform, but the converse is
not true::

sage: L = LatticePoset({1: [2, 3, 6], 2: [4, 5], 3: [5], 4: [9, 8], 5: [7, 8], 6: [9], 7: [10], 8: [10], 9: [10]})
sage: L.is_isoform(), L.is_uniform()
sage: L = LatticePoset({1: [2, 3, 6], 2: [4, 5], 3: [5], 4: [9, 8],
....: 5: [7, 8], 6: [9], 7: [10], 8: [10], 9: [10]})
sage: L.is_isoform(), L.is_uniform() # needs sage.combinat
(False, True)

sage: L.is_isoform(certificate=True)
sage: L.is_isoform(certificate=True) # needs sage.combinat
(False, {{1, 2, 4, 6, 9}, {3, 5, 7, 8, 10}})

.. SEEALSO::
Expand All @@ -4404,7 +4406,7 @@ def is_isoform(self, certificate=False):
sage: [posets.ChainPoset(i).is_isoform() for i in range(5)]
[True, True, True, False, False]

sage: posets.DiamondPoset(5).is_isoform() # Simple, so trivially isoform
sage: posets.DiamondPoset(5).is_isoform() # Simple, so trivially isoform # needs sage.combinat
True
"""
ok = (True, None) if certificate else True
Expand Down Expand Up @@ -4451,8 +4453,9 @@ def is_uniform(self, certificate=False):

EXAMPLES::

sage: L = LatticePoset({1: [2, 3, 4], 2: [6, 7], 3: [5], 4: [5], 5: [9, 8], 6: [9], 7: [10], 8: [10], 9: [10]})
sage: L.is_uniform()
sage: L = LatticePoset({1: [2, 3, 4], 2: [6, 7], 3: [5], 4: [5],
....: 5: [9, 8], 6: [9], 7: [10], 8: [10], 9: [10]})
sage: L.is_uniform() # needs sage.combinat
True

Every uniform lattice is regular, but the converse is not true::
Expand All @@ -4461,7 +4464,7 @@ def is_uniform(self, certificate=False):
sage: N6.is_uniform(), N6.is_regular()
(False, True)

sage: N6.is_uniform(certificate=True)
sage: N6.is_uniform(certificate=True) # needs sage.combinat
(False, {{1, 2, 3, 4}, {5, 6}})

.. SEEALSO::
Expand All @@ -4475,7 +4478,7 @@ def is_uniform(self, certificate=False):
sage: [posets.ChainPoset(i).is_uniform() for i in range(5)]
[True, True, True, False, False]

sage: posets.DiamondPoset(5).is_uniform() # Simple, so trivially uniform
sage: posets.DiamondPoset(5).is_uniform() # Simple, so trivially uniform # needs sage.combinat
True
"""
ok = (True, None) if certificate else True
Expand Down Expand Up @@ -4532,14 +4535,15 @@ def is_regular(self, certificate=False):

EXAMPLES::

sage: L = LatticePoset({1: [2, 3, 4], 2: [5, 6], 3: [8, 7], 4: [6, 7], 5: [8], 6: [9], 7: [9], 8: [9]})
sage: L.is_regular()
sage: L = LatticePoset({1: [2, 3, 4], 2: [5, 6], 3: [8, 7], 4: [6, 7],
....: 5: [8], 6: [9], 7: [9], 8: [9]})
sage: L.is_regular() # needs sage.combinat
True

sage: N5 = posets.PentagonPoset()
sage: N5.is_regular()
sage: N5.is_regular() # needs sage.combinat
False
sage: N5.is_regular(certificate=True)
sage: N5.is_regular(certificate=True) # needs sage.combinat
(False, ({{0}, {1}, {2, 3}, {4}}, [0]))

.. SEEALSO::
Expand All @@ -4552,7 +4556,7 @@ def is_regular(self, certificate=False):

TESTS::

sage: [posets.ChainPoset(i).is_regular() for i in range(5)]
sage: [posets.ChainPoset(i).is_regular() for i in range(5)] # needs sage.combinat
[True, True, True, False, False]
"""
ok = (True, None) if certificate else True
Expand Down Expand Up @@ -4598,6 +4602,7 @@ def is_simple(self, certificate=False):

EXAMPLES::

sage: # needs sage.combinat
sage: posets.DiamondPoset(5).is_simple() # Smallest nontrivial example
True
sage: L = LatticePoset({1: [2, 3], 2: [4, 5], 3: [6], 4: [6], 5: [6]})
Expand All @@ -4611,11 +4616,11 @@ def is_simple(self, certificate=False):

sage: L = LatticePoset({1: [2, 3, 4], 2: [5], 3: [5], 4: [6, 7],
....: 5: [8], 6: [8], 7: [8]})
sage: L.is_simple()
sage: L.is_simple() # needs sage.combinat
False
sage: L = LatticePoset({1: [2, 3], 2: [4, 5], 3: [6, 7], 4: [8],
....: 5: [8], 6: [8], 7: [8]})
sage: L.is_simple()
sage: L.is_simple() # needs sage.combinat
True

.. SEEALSO::
Expand Down Expand Up @@ -4652,9 +4657,10 @@ def subdirect_decomposition(self):

EXAMPLES::

sage: posets.ChainPoset(3).subdirect_decomposition()
sage: posets.ChainPoset(3).subdirect_decomposition() # needs sage.combinat
[Finite lattice containing 2 elements, Finite lattice containing 2 elements]

sage: # needs sage.combinat
sage: L = LatticePoset({1: [2, 4], 2: [3], 3: [6, 7], 4: [5, 7],
....: 5: [9, 8], 6: [9], 7: [9], 8: [10], 9: [10]})
sage: Ldecomp = L.subdirect_decomposition()
Expand All @@ -4665,6 +4671,7 @@ def subdirect_decomposition(self):

TESTS::

sage: # needs sage.combinat
sage: posets.ChainPoset(0).subdirect_decomposition()
[Finite lattice containing 0 elements]
sage: posets.ChainPoset(1).subdirect_decomposition()
Expand All @@ -4676,7 +4683,7 @@ def subdirect_decomposition(self):
has only one element::

sage: N5 = posets.PentagonPoset()
sage: N5.subdirect_decomposition()
sage: N5.subdirect_decomposition() # needs sage.combinat
[Finite lattice containing 5 elements]
"""
H = self._hasse_diagram
Expand Down Expand Up @@ -4737,6 +4744,7 @@ def congruence(self, S):

EXAMPLES::

sage: # needs sage.combinat
sage: L = posets.DivisorLattice(12)
sage: cong = L.congruence([[1, 3]])
sage: sorted(sorted(c) for c in cong)
Expand All @@ -4745,19 +4753,20 @@ def congruence(self, S):
{{1, 2, 4}, {3, 6, 12}}

sage: L = LatticePoset({1: [2, 3], 2: [4], 3: [4], 4: [5]})
sage: L.congruence([[1, 2]])
sage: L.congruence([[1, 2]]) # needs sage.combinat
{{1, 2}, {3, 4}, {5}}

sage: L = LatticePoset({1: [2, 3], 2: [4, 5, 6], 4: [5], 5: [7, 8],
....: 6: [8], 3: [9], 7: [10], 8: [10], 9:[10]})
sage: cong = L.congruence([[1, 2]])
sage: cong[0]
sage: cong = L.congruence([[1, 2]]) # needs sage.combinat
sage: cong[0] # needs sage.combinat
frozenset({1, 2, 3, 4, 5, 6, 7, 8, 9, 10})

.. SEEALSO:: :meth:`quotient`

TESTS::

sage: # needs sage.combinat
sage: P = posets.PentagonPoset()
sage: P.congruence([])
{{0}, {1}, {2}, {3}, {4}}
Expand All @@ -4774,13 +4783,13 @@ def congruence(self, S):
works::

sage: L = LatticePoset(DiGraph('P^??@_?@??B_?@??B??@_?@??B_?@??B??@??A??C??G??O???'))
sage: sorted(sorted(p) for p in L.congruence([[1,6]]))
sage: sorted(sorted(p) for p in L.congruence([[1,6]])) # needs sage.combinat
[[0], [1, 6], [2], [3, 8], [4], [5, 10], [7, 12], [9, 14], [11], [13], [15], [16]]

Simple lattice, i.e. a lattice without any nontrivial congruence::

sage: L = LatticePoset(DiGraph('GPb_@?OC@?O?'))
sage: L.congruence([[1,2]])
sage: L.congruence([[1,2]]) # needs sage.combinat
{{0, 1, 2, 3, 4, 5, 6, 7}}
"""
from sage.combinat.set_partition import SetPartition
Expand Down Expand Up @@ -4821,6 +4830,7 @@ def quotient(self, congruence, labels='tuple'):

EXAMPLES::

sage: # needs sage.combinat
sage: L = posets.PentagonPoset()
sage: c = L.congruence([[0, 1]])
sage: I = L.quotient(c); I
Expand All @@ -4831,6 +4841,7 @@ def quotient(self, congruence, labels='tuple'):
sage: I.top()
Finite lattice containing 3 elements

sage: # needs sage.combinat
sage: B3 = posets.BooleanLattice(3)
sage: c = B3.congruence([[0,1]])
sage: B2 = B3.quotient(c, labels='integer')
Expand All @@ -4846,7 +4857,7 @@ def quotient(self, congruence, labels='tuple'):
Finite lattice containing 0 elements

sage: L = posets.PentagonPoset()
sage: L.quotient(L.congruence([[1]])).is_isomorphic(L)
sage: L.quotient(L.congruence([[1]])).is_isomorphic(L) # needs sage.combinat
True
"""
if labels not in ['lattice', 'tuple', 'integer']:
Expand Down Expand Up @@ -4894,6 +4905,7 @@ def congruences_lattice(self, labels='congruence'):

EXAMPLES::

sage: # needs sage.combinat
sage: N5 = posets.PentagonPoset()
sage: CL = N5.congruences_lattice(); CL
Finite lattice containing 5 elements
Expand All @@ -4903,12 +4915,13 @@ def congruences_lattice(self, labels='congruence'):
[{{0, 1}, {2, 3, 4}}, {{0, 2, 3}, {1, 4}}]

sage: C4 = posets.ChainPoset(4)
sage: CL = C4.congruences_lattice(labels='integer')
sage: CL.is_isomorphic(posets.BooleanLattice(3))
sage: CL = C4.congruences_lattice(labels='integer') # needs sage.combinat
sage: CL.is_isomorphic(posets.BooleanLattice(3)) # needs sage.combinat
True

TESTS::

sage: # needs sage.combinat
sage: posets.ChainPoset(0).congruences_lattice()
Finite lattice containing 1 elements
sage: posets.ChainPoset(1).congruences_lattice()
Expand Down Expand Up @@ -5002,6 +5015,7 @@ def feichtner_yuzvinsky_ring(self, G, use_defining=False, base_ring=None):

We reproduce the example from Section 5 of [Coron2023]_::

sage: # needs sage.geometry.polyhedron
sage: H.<a,b,c,d> = HyperplaneArrangements(QQ)
sage: Arr = H(a-b, b-c, c-d, d-a)
sage: P = LatticePoset(Arr.intersection_poset())
Expand Down
30 changes: 15 additions & 15 deletions src/sage/combinat/posets/posets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3745,9 +3745,9 @@ def magnitude(self) -> Integer:
sage: P.magnitude() == m1*m2
True

sage: Poset({}).magnitude()
sage: Poset({}).magnitude() # needs sage.libs.flint
0
sage: Poset({1:[]}).magnitude()
sage: Poset({1: []}).magnitude() # needs sage.libs.flint
1
"""
H = self._hasse_diagram
Expand Down Expand Up @@ -4314,7 +4314,7 @@ def coxeter_transformation(self):

EXAMPLES::

sage: posets.PentagonPoset().coxeter_transformation()
sage: posets.PentagonPoset().coxeter_transformation() # needs sage.libs.flint
[ 0 0 0 0 -1]
[ 0 0 0 1 -1]
[ 0 1 0 0 -1]
Expand All @@ -4327,8 +4327,8 @@ def coxeter_transformation(self):

TESTS::

sage: M = posets.PentagonPoset().coxeter_transformation()
sage: M ** 8 == 1
sage: M = posets.PentagonPoset().coxeter_transformation() # needs sage.libs.flint
sage: M ** 8 == 1 # needs sage.libs.flint
True
"""
return self._hasse_diagram.coxeter_transformation()
Expand All @@ -4348,11 +4348,11 @@ def coxeter_polynomial(self):
EXAMPLES::

sage: P = posets.PentagonPoset()
sage: P.coxeter_polynomial()
sage: P.coxeter_polynomial() # needs sage.libs.flint
x^5 + x^4 + x + 1

sage: p = posets.SymmetricGroupWeakOrderPoset(3) # needs sage.groups
sage: p.coxeter_polynomial() # needs sage.groups
sage: p.coxeter_polynomial() # needs sage.groups sage.libs.flint
x^6 + x^5 - x^3 + x + 1

.. SEEALSO::
Expand Down Expand Up @@ -4398,7 +4398,7 @@ def coxeter_smith_form(self, algorithm='singular'):
TESTS::

sage: P = posets.PentagonPoset()
sage: P.coxeter_smith_form(algorithm='sage')
sage: P.coxeter_smith_form(algorithm='sage') # needs sage.libs.flint
[1, 1, 1, 1, x^5 + x^4 + x + 1]
sage: P.coxeter_smith_form(algorithm='gap') # needs sage.libs.gap
[1, 1, 1, 1, x^5 + x^4 + x + 1]
Expand Down Expand Up @@ -8099,33 +8099,33 @@ def is_eulerian(self, k=None, certificate=False):

sage: P = Poset({0: [1, 2, 3], 1: [4, 5], 2: [4, 6], 3: [5, 6],
....: 4: [7, 8], 5: [7, 8], 6: [7, 8], 7: [9], 8: [9]})
sage: P.is_eulerian()
sage: P.is_eulerian() # needs sage.libs.flint
True
sage: P = Poset({0: [1, 2, 3], 1: [4, 5, 6], 2: [4, 6], 3: [5,6],
....: 4: [7], 5:[7], 6:[7]})
sage: P.is_eulerian()
sage: P.is_eulerian() # needs sage.libs.flint
False

Canonical examples of Eulerian posets are the face lattices of
convex polytopes::

sage: P = polytopes.cube().face_lattice() # needs sage.geometry.polyhedron
sage: P.is_eulerian() # needs sage.geometry.polyhedron
sage: P.is_eulerian() # needs sage.geometry.polyhedron sage.libs.flint
True

A poset that is 3- but not 4-eulerian::

sage: P = Poset(DiGraph('MWW@_?W?@_?W??@??O@_?W?@_?W?@??O??')); P
Finite poset containing 14 elements
sage: P.is_eulerian(k=3)
sage: P.is_eulerian(k=3) # needs sage.libs.flint
True
sage: P.is_eulerian(k=4)
sage: P.is_eulerian(k=4) # needs sage.libs.flint
False

Getting an interval that is not Eulerian::

sage: P = posets.DivisorLattice(12)
sage: P.is_eulerian(certificate=True)
sage: P.is_eulerian(certificate=True) # needs sage.libs.flint
(False, (1, 4))

TESTS::
Expand All @@ -8143,7 +8143,7 @@ def is_eulerian(self, k=None, certificate=False):
...
ValueError: the poset is not graded

sage: posets.BooleanLattice(3).is_eulerian(k=123, certificate=True)
sage: posets.BooleanLattice(3).is_eulerian(k=123, certificate=True) # needs sage.libs.flint
(True, None)
"""
if k is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/root_system/coxeter_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def CoxeterGroup(data, implementation="reflection", base_ring=None, index_set=No

TESTS::

sage: W = groups.misc.CoxeterGroup(["H",3]) # needs sage.groups
sage: W = groups.misc.CoxeterGroup(["H",3]) # needs sage.graphs sage.groups
"""
if implementation not in ["permutation", "matrix", "coxeter3", "reflection", "chevie", None]:
raise ValueError("invalid type implementation")
Expand Down
Loading