Hasse diagrams of posets¶
| Return all antichains of  | |
| Return an iterator over the antichains of the poset. | |
| Return whether  | |
| Return whether  | |
| Return atoms of the congruence lattice. | |
| Return the value of the Möbius function of the poset on the elements  | |
| Return the number of elements in the poset. | |
| Return the chain polynomial of the poset. | |
| Return all chains of  | |
| Return a list of the elements \(z\) of  | |
| Return the list of all common lower covers of  | |
| Return the list of all common upper covers of  | |
| Return the congruence  | |
| Return an iterator over all congruences of the lattice. | |
| Return the list of cover relations. | |
| Iterate over cover relations. | |
| Return  | |
| Return the list of diamonds of  | |
| Return a poset that is dual to the given poset. | |
| Check if the lattice is semidistributive or not. | |
| Return pair of elements showing the lattice is not modular. | |
| Return a pair that generates non-trivial congruence or  | |
| Return the list of elements of the Frattini sublattice of the lattice. | |
| Return an iterator over greedy linear extensions of the Hasse diagram. | |
| Return  | |
| Return  | |
| Return an iterator of the elements \(z\) of  | |
| Return  | |
| Return  | |
| Return  | |
| Return an element of the lattice that has no complement. | |
| Return  | |
| Return  | |
| Return  | |
| Return  | |
| Return  | |
| Return  | |
| Return  | |
| Test if an ordering is a linear extension. | |
| Return whether the interval  | |
| Return  | |
| Return  | |
| Return the matrix of joins of  | |
| Return the maximum element greater than the element covered by  | |
| Return the minimum element smaller than the element covering  | |
| Return a matrix whose  | |
| Return a linear extension. | |
| Return an iterator over all linear extensions. | |
| Return the list of elements that are covered by  | |
| Return a list of the maximal elements of the poset. | |
| Return maximal sublattices of the lattice. | |
| Return the matrix of meets of  | |
| Return a list of the minimal elements of the poset. | |
| Return the value of the Möbius function of the poset on the elements  | |
| Return the matrix of the Möbius function of this poset. | |
| Return the list of neutral elements of the lattice. | |
| Return a list of the elements \(z\) of  | |
| Return the order filter generated by a list of elements. | |
| Return the order ideal generated by a list of elements. | |
| Return the cardinality of the order ideal generated by  | |
| Return an iterator over orthocomplementations of the lattice. | |
| Return the join-prime and meet-prime elements of the bounded poset. | |
| Return the poset of join-irreducibles of the congruence lattice. | |
| Return the order filter generated by  | |
| Return the order ideal generated by \(i\). | |
| Return the pseudocomplement of  | |
| Return the rank of  | |
| Return the (normalized) rank function of the poset, if it exists. | |
| Return the skeleton of the lattice. | |
| Return an iterator over sublattices of the Hasse diagram. | |
| Return an iterator over supergreedy linear extensions of the Hasse diagram. | |
| Return the top element of the poset, if it exists. | |
| Return the list of elements that cover  | |
| Return vertical decomposition of the lattice. | 
- class sage.combinat.posets.hasse_diagram.HasseDiagram(data=None, pos=None, loops=None, format=None, weighted=None, data_structure='sparse', vertex_labels=True, name=None, multiedges=None, convert_empty_dict_labels_to_None=None, sparse=True, immutable=False, hash_labels=None)[source]¶
- Bases: - DiGraph- The Hasse diagram of a poset. This is just a transitively-reduced, directed, acyclic graph without loops or multiple edges. - Note - We assume that - range(n)is a linear extension of the poset. That is,- range(n)is the vertex set and a topological sort of the digraph.- This should not be called directly, use Poset instead; all type checking happens there. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,2],1:[3],2:[3],3:[]}); H Hasse diagram of a poset containing 4 elements sage: TestSuite(H).run() - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(2)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[]}); H Hasse diagram of a poset containing 4 elements >>> TestSuite(H).run() - antichains(element_class=<class 'list'>)[source]¶
- Return all antichains of - self, organized as a prefix tree.- INPUT: - element_class– (default:- list) an iterable type
 - EXAMPLES: - sage: # needs sage.modules sage: P = posets.PentagonPoset() sage: H = P._hasse_diagram sage: A = H.antichains() sage: list(A) [[], [0], [1], [1, 2], [1, 3], [2], [3], [4]] sage: A.cardinality() 8 sage: [1,3] in A True sage: [1,4] in A False - >>> from sage.all import * >>> # needs sage.modules >>> P = posets.PentagonPoset() >>> H = P._hasse_diagram >>> A = H.antichains() >>> list(A) [[], [0], [1], [1, 2], [1, 3], [2], [3], [4]] >>> A.cardinality() 8 >>> [Integer(1),Integer(3)] in A True >>> [Integer(1),Integer(4)] in A False 
 - antichains_iterator()[source]¶
- Return an iterator over the antichains of the poset. - Note - The algorithm is based on Freese-Jezek-Nation p. 226. It does a depth first search through the set of all antichains organized in a prefix tree. - EXAMPLES: - sage: # needs sage.modules sage: P = posets.PentagonPoset() sage: H = P._hasse_diagram sage: H.antichains_iterator() <generator object ...antichains_iterator at ...> sage: list(H.antichains_iterator()) [[], [4], [3], [2], [1], [1, 3], [1, 2], [0]] sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,2],1:[4],2:[3],3:[4]}) sage: list(H.antichains_iterator()) [[], [4], [3], [2], [1], [1, 3], [1, 2], [0]] sage: H = HasseDiagram({0:[],1:[],2:[]}) sage: list(H.antichains_iterator()) [[], [2], [1], [1, 2], [0], [0, 2], [0, 1], [0, 1, 2]] sage: H = HasseDiagram({0:[1],1:[2],2:[3],3:[4]}) sage: list(H.antichains_iterator()) [[], [4], [3], [2], [1], [0]] - >>> from sage.all import * >>> # needs sage.modules >>> P = posets.PentagonPoset() >>> H = P._hasse_diagram >>> H.antichains_iterator() <generator object ...antichains_iterator at ...> >>> list(H.antichains_iterator()) [[], [4], [3], [2], [1], [1, 3], [1, 2], [0]] >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(3)],Integer(3):[Integer(4)]}) >>> list(H.antichains_iterator()) [[], [4], [3], [2], [1], [1, 3], [1, 2], [0]] >>> H = HasseDiagram({Integer(0):[],Integer(1):[],Integer(2):[]}) >>> list(H.antichains_iterator()) [[], [2], [1], [1, 2], [0], [0, 2], [0, 1], [0, 1, 2]] >>> H = HasseDiagram({Integer(0):[Integer(1)],Integer(1):[Integer(2)],Integer(2):[Integer(3)],Integer(3):[Integer(4)]}) >>> list(H.antichains_iterator()) [[], [4], [3], [2], [1], [0]] 
 - are_comparable(i, j)[source]¶
- Return whether - iand- jare comparable in the poset.- INPUT: - i,- j– vertices of this Hasse diagram
 - EXAMPLES: - sage: # needs sage.modules sage: P = posets.PentagonPoset() sage: H = P._hasse_diagram sage: H.are_comparable(1,2) False sage: V = H.vertices(sort=True) sage: [ (i,j) for i in V for j in V if H.are_comparable(i,j)] [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 4), (2, 0), (2, 2), (2, 3), (2, 4), (3, 0), (3, 2), (3, 3), (3, 4), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] - >>> from sage.all import * >>> # needs sage.modules >>> P = posets.PentagonPoset() >>> H = P._hasse_diagram >>> H.are_comparable(Integer(1),Integer(2)) False >>> V = H.vertices(sort=True) >>> [ (i,j) for i in V for j in V if H.are_comparable(i,j)] [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 4), (2, 0), (2, 2), (2, 3), (2, 4), (3, 0), (3, 2), (3, 3), (3, 4), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] 
 - are_incomparable(i, j)[source]¶
- Return whether - iand- jare incomparable in the poset.- INPUT: - i,- j– vertices of this Hasse diagram
 - EXAMPLES: - sage: # needs sage.modules sage: P = posets.PentagonPoset() sage: H = P._hasse_diagram sage: H.are_incomparable(1,2) True sage: V = H.vertices(sort=True) sage: [ (i,j) for i in V for j in V if H.are_incomparable(i,j)] [(1, 2), (1, 3), (2, 1), (3, 1)] - >>> from sage.all import * >>> # needs sage.modules >>> P = posets.PentagonPoset() >>> H = P._hasse_diagram >>> H.are_incomparable(Integer(1),Integer(2)) True >>> V = H.vertices(sort=True) >>> [ (i,j) for i in V for j in V if H.are_incomparable(i,j)] [(1, 2), (1, 3), (2, 1), (3, 1)] 
 - atoms_of_congruence_lattice()[source]¶
- Return atoms of the congruence lattice. - In other words, return “minimal non-trivial” congruences: A congruence is minimal if the only finer (as a partition of set of elements) congruence is the trivial congruence where every block contains only one element. - See also - OUTPUT: - List of congruences, every congruence as - sage.combinat.set_partition.SetPartition- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: N5 = HasseDiagram({0: [1, 2], 1: [4], 2: [3], 3:[4]}) sage: N5.atoms_of_congruence_lattice() # needs sage.combinat sage.modules [{{0}, {1}, {2, 3}, {4}}] sage: Hex = HasseDiagram({0: [1, 2], 1: [3], 2: [4], 3: [5], 4: [5]}) sage: Hex.atoms_of_congruence_lattice() # needs sage.combinat sage.modules [{{0}, {1}, {2, 4}, {3}, {5}}, {{0}, {1, 3}, {2}, {4}, {5}}] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> N5 = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(4)], Integer(2): [Integer(3)], Integer(3):[Integer(4)]}) >>> N5.atoms_of_congruence_lattice() # needs sage.combinat sage.modules [{{0}, {1}, {2, 3}, {4}}] >>> Hex = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(3)], Integer(2): [Integer(4)], Integer(3): [Integer(5)], Integer(4): [Integer(5)]}) >>> Hex.atoms_of_congruence_lattice() # needs sage.combinat sage.modules [{{0}, {1}, {2, 4}, {3}, {5}}, {{0}, {1, 3}, {2}, {4}, {5}}] - ALGORITHM: - Every atom is a join-irreducible. Every join-irreducible of \(\mathrm{Con}(L)\) is a principal congruence generated by a meet-irreducible element and the only element covering it (and also by a join-irreducible element and the only element covered by it). Hence we check those principal congruences to find the minimal ones. 
 - bottom()[source]¶
- Return the bottom element of the poset, if it exists. - EXAMPLES: - sage: P = Poset({0:[3],1:[3],2:[3],3:[4],4:[]}) sage: P.bottom() is None True sage: Q = Poset({0:[1],1:[]}) sage: Q.bottom() 0 - >>> from sage.all import * >>> P = Poset({Integer(0):[Integer(3)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[Integer(4)],Integer(4):[]}) >>> P.bottom() is None True >>> Q = Poset({Integer(0):[Integer(1)],Integer(1):[]}) >>> Q.bottom() 0 
 - bottom_moebius_function(j)[source]¶
- Return the value of the Möbius function of the poset on the elements - zeroand- j, where- zerois- self.bottom(), the unique minimal element of the poset.- EXAMPLES: - sage: P = Poset({0: [1,2]}) sage: hasse = P._hasse_diagram sage: hasse.bottom_moebius_function(1) -1 sage: hasse.bottom_moebius_function(2) -1 sage: P = Poset({0: [1,3], 1:[2], 2:[4], 3:[4]}) sage: hasse = P._hasse_diagram sage: for i in range(5): ....: print(hasse.bottom_moebius_function(i)) 1 -1 0 -1 1 - >>> from sage.all import * >>> P = Poset({Integer(0): [Integer(1),Integer(2)]}) >>> hasse = P._hasse_diagram >>> hasse.bottom_moebius_function(Integer(1)) -1 >>> hasse.bottom_moebius_function(Integer(2)) -1 >>> P = Poset({Integer(0): [Integer(1),Integer(3)], Integer(1):[Integer(2)], Integer(2):[Integer(4)], Integer(3):[Integer(4)]}) >>> hasse = P._hasse_diagram >>> for i in range(Integer(5)): ... print(hasse.bottom_moebius_function(i)) 1 -1 0 -1 1 
 - cardinality()[source]¶
- Return the number of elements in the poset. - EXAMPLES: - sage: Poset([[1,2,3],[4],[4],[4],[]]).cardinality() 5 - >>> from sage.all import * >>> Poset([[Integer(1),Integer(2),Integer(3)],[Integer(4)],[Integer(4)],[Integer(4)],[]]).cardinality() 5 
 - chain_polynomial()[source]¶
- Return the chain polynomial of the poset. - The coefficient of \(q^k\) is the number of chains of \(k\) elements in the poset. List of coefficients of this polynomial is also called a f-vector of the poset. - EXAMPLES: - sage: P = posets.ChainPoset(3) sage: H = P._hasse_diagram sage: t = H.chain_polynomial(); t q^3 + 3*q^2 + 3*q + 1 - >>> from sage.all import * >>> P = posets.ChainPoset(Integer(3)) >>> H = P._hasse_diagram >>> t = H.chain_polynomial(); t q^3 + 3*q^2 + 3*q + 1 
 - chains(element_class=<class 'list'>, exclude=None, conversion=None)[source]¶
- Return all chains of - self, organized as a prefix tree.- INPUT: - element_class– (default:- list) an iterable type
- exclude– elements of the poset to be excluded (default:- None)
- conversion– (default:- None) used to pass the list of elements of the poset in their fixed order
 - OUTPUT: - The enumerated set (with a forest structure given by prefix ordering) consisting of all chains of - self, each of which is given as an- element_class.- If - conversionis given, then the chains are converted to chain of elements of this list.- EXAMPLES: - sage: # needs sage.modules sage: P = posets.PentagonPoset() sage: H = P._hasse_diagram sage: A = H.chains() sage: list(A) [[], [0], [0, 1], [0, 1, 4], [0, 2], [0, 2, 3], [0, 2, 3, 4], [0, 2, 4], [0, 3], [0, 3, 4], [0, 4], [1], [1, 4], [2], [2, 3], [2, 3, 4], [2, 4], [3], [3, 4], [4]] sage: A.cardinality() 20 sage: [1,3] in A False sage: [1,4] in A True - >>> from sage.all import * >>> # needs sage.modules >>> P = posets.PentagonPoset() >>> H = P._hasse_diagram >>> A = H.chains() >>> list(A) [[], [0], [0, 1], [0, 1, 4], [0, 2], [0, 2, 3], [0, 2, 3, 4], [0, 2, 4], [0, 3], [0, 3, 4], [0, 4], [1], [1, 4], [2], [2, 3], [2, 3, 4], [2, 4], [3], [3, 4], [4]] >>> A.cardinality() 20 >>> [Integer(1),Integer(3)] in A False >>> [Integer(1),Integer(4)] in A True - One can exclude some vertices: - sage: # needs sage.modules sage: list(H.chains(exclude=[4, 3])) [[], [0], [0, 1], [0, 2], [1], [2]] - >>> from sage.all import * >>> # needs sage.modules >>> list(H.chains(exclude=[Integer(4), Integer(3)])) [[], [0], [0, 1], [0, 2], [1], [2]] - The - element_classkeyword determines how the chains are being returned:- sage: P = Poset({1: [2, 3], 2: [4]}) sage: list(P._hasse_diagram.chains(element_class=tuple)) [(), (0,), (0, 1), (0, 1, 2), (0, 2), (0, 3), (1,), (1, 2), (2,), (3,)] sage: list(P._hasse_diagram.chains()) [[], [0], [0, 1], [0, 1, 2], [0, 2], [0, 3], [1], [1, 2], [2], [3]] - >>> from sage.all import * >>> P = Poset({Integer(1): [Integer(2), Integer(3)], Integer(2): [Integer(4)]}) >>> list(P._hasse_diagram.chains(element_class=tuple)) [(), (0,), (0, 1), (0, 1, 2), (0, 2), (0, 3), (1,), (1, 2), (2,), (3,)] >>> list(P._hasse_diagram.chains()) [[], [0], [0, 1], [0, 1, 2], [0, 2], [0, 3], [1], [1, 2], [2], [3]] - (Note that taking the Hasse diagram has renamed the vertices.) - sage: list(P._hasse_diagram.chains(element_class=tuple, exclude=[0])) [(), (1,), (1, 2), (2,), (3,)] - >>> from sage.all import * >>> list(P._hasse_diagram.chains(element_class=tuple, exclude=[Integer(0)])) [(), (1,), (1, 2), (2,), (3,)] - See also 
 - closed_interval(x, y)[source]¶
- Return a list of the elements \(z\) of - selfsuch that \(x \leq z \leq y\).- The order is that induced by the ordering in - self.linear_extension.- INPUT: - x– any element of the poset
- y– any element of the poset
 - Note - The method - _precompute_intervals()creates a cache which is used if available, making the function very fast.- See also - EXAMPLES: - sage: uc = [[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] sage: dag = DiGraph(dict(zip(range(len(uc)),uc))) sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram(dag) sage: I = set([2,5,6,4,7]) sage: I == set(H.interval(2,7)) True - >>> from sage.all import * >>> uc = [[Integer(1),Integer(3),Integer(2)],[Integer(4)],[Integer(4),Integer(5),Integer(6)],[Integer(6)],[Integer(7)],[Integer(7)],[Integer(7)],[]] >>> dag = DiGraph(dict(zip(range(len(uc)),uc))) >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram(dag) >>> I = set([Integer(2),Integer(5),Integer(6),Integer(4),Integer(7)]) >>> I == set(H.interval(Integer(2),Integer(7))) True 
 - common_lower_covers(vertices)[source]¶
- Return the list of all common lower covers of - vertices.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1,2], 1: [3], 2: [3], 3: []}) sage: H.common_lower_covers([1, 2]) [0] sage: from sage.combinat.posets.poset_examples import Posets sage: H = Posets.YoungDiagramPoset(Partition([3, 2, 2]))._hasse_diagram # needs sage.combinat sage.modules sage: H.common_lower_covers([4, 5]) # needs sage.combinat sage.modules [3] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1),Integer(2)], Integer(1): [Integer(3)], Integer(2): [Integer(3)], Integer(3): []}) >>> H.common_lower_covers([Integer(1), Integer(2)]) [0] >>> from sage.combinat.posets.poset_examples import Posets >>> H = Posets.YoungDiagramPoset(Partition([Integer(3), Integer(2), Integer(2)]))._hasse_diagram # needs sage.combinat sage.modules >>> H.common_lower_covers([Integer(4), Integer(5)]) # needs sage.combinat sage.modules [3] 
 - common_upper_covers(vertices)[source]¶
- Return the list of all common upper covers of - vertices.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1,2], 1: [3], 2: [3], 3: []}) sage: H.common_upper_covers([1, 2]) [3] sage: from sage.combinat.posets.poset_examples import Posets sage: H = Posets.YoungDiagramPoset(Partition([3, 2, 2]))._hasse_diagram # needs sage.combinat sage.modules sage: H.common_upper_covers([4, 5]) # needs sage.combinat sage.modules [6] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1),Integer(2)], Integer(1): [Integer(3)], Integer(2): [Integer(3)], Integer(3): []}) >>> H.common_upper_covers([Integer(1), Integer(2)]) [3] >>> from sage.combinat.posets.poset_examples import Posets >>> H = Posets.YoungDiagramPoset(Partition([Integer(3), Integer(2), Integer(2)]))._hasse_diagram # needs sage.combinat sage.modules >>> H.common_upper_covers([Integer(4), Integer(5)]) # needs sage.combinat sage.modules [6] 
 - congruence(parts, start=None, stop_pairs=None)[source]¶
- Return the congruence - start“extended” by- parts.- startis assumed to be a valid congruence of the lattice, and this is not checked.- INPUT: - parts– list of lists; congruences to add
- start– a disjoint set; already computed congruence (or- None)
- stop_pairs– list of pairs; list of pairs for stopping computation
 - OUTPUT: - None, if the congruence generated by- startand- partstogether contains a block that has elements \(a, b\) so that- (a, b)is in the list- stop_pairs. Otherwise the least congruence that contains a block whose subset is \(p\) for every \(p\) in- partsor- start, given as- sage.sets.disjoint_set.DisjointSet_class.- ALGORITHM: - Use the quadrilateral argument from page 120 of [Dav1997]. - Basically we take one block from todo-list, search quadrilateral blocks up and down against the block, and then complete them to closed intervals and add to todo-list. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 1: [3], 2: [4], 3: [4]}) sage: cong = H.congruence([[0, 1]]); cong # needs sage.modules {{0, 1, 3}, {2, 4}} sage: H.congruence([[0, 2]], start=cong) # needs sage.modules {{0, 1, 2, 3, 4}} sage: H.congruence([[0, 1]], stop_pairs=[(1, 3)]) is None # needs sage.modules True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(3)], Integer(2): [Integer(4)], Integer(3): [Integer(4)]}) >>> cong = H.congruence([[Integer(0), Integer(1)]]); cong # needs sage.modules {{0, 1, 3}, {2, 4}} >>> H.congruence([[Integer(0), Integer(2)]], start=cong) # needs sage.modules {{0, 1, 2, 3, 4}} >>> H.congruence([[Integer(0), Integer(1)]], stop_pairs=[(Integer(1), Integer(3))]) is None # needs sage.modules True 
 - congruences_iterator()[source]¶
- Return an iterator over all congruences of the lattice. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram('GY@OQ?OW@?O?') sage: it = H.congruences_iterator(); it <generator object ...> sage: sorted([cong.number_of_subsets() for cong in it]) # needs sage.combinat sage.modules [1, 2, 2, 2, 4, 4, 4, 8] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram('GY@OQ?OW@?O?') >>> it = H.congruences_iterator(); it <generator object ...> >>> sorted([cong.number_of_subsets() for cong in it]) # needs sage.combinat sage.modules [1, 2, 2, 2, 4, 4, 4, 8] 
 - cover_relations()[source]¶
- Return the list of cover relations. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}) sage: H.cover_relations() [(0, 2), (0, 3), (1, 3), (1, 4), (2, 5), (3, 5), (4, 5)] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(2),Integer(3)], Integer(1):[Integer(3),Integer(4)], Integer(2):[Integer(5)], Integer(3):[Integer(5)], Integer(4):[Integer(5)]}) >>> H.cover_relations() [(0, 2), (0, 3), (1, 3), (1, 4), (2, 5), (3, 5), (4, 5)] 
 - cover_relations_iterator()[source]¶
- Iterate over cover relations. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}) sage: list(H.cover_relations_iterator()) [(0, 2), (0, 3), (1, 3), (1, 4), (2, 5), (3, 5), (4, 5)] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(2),Integer(3)], Integer(1):[Integer(3),Integer(4)], Integer(2):[Integer(5)], Integer(3):[Integer(5)], Integer(4):[Integer(5)]}) >>> list(H.cover_relations_iterator()) [(0, 2), (0, 3), (1, 3), (1, 4), (2, 5), (3, 5), (4, 5)] 
 - covers(x, y)[source]¶
- Return - Trueif y covers x and- Falseotherwise.- EXAMPLES: - sage: Q = Poset([[1,5],[2,6],[3],[4],[],[6,3],[4]]) sage: Q.covers(Q(1),Q(6)) True sage: Q.covers(Q(1),Q(4)) False - >>> from sage.all import * >>> Q = Poset([[Integer(1),Integer(5)],[Integer(2),Integer(6)],[Integer(3)],[Integer(4)],[],[Integer(6),Integer(3)],[Integer(4)]]) >>> Q.covers(Q(Integer(1)),Q(Integer(6))) True >>> Q.covers(Q(Integer(1)),Q(Integer(4))) False 
 - coxeter_transformation(algorithm='cython')[source]¶
- Return the matrix of the Auslander-Reiten translation acting on the Grothendieck group of the derived category of modules on the poset, in the basis of simple modules. - INPUT: - algorithm–- 'cython'(default) or- 'matrix'
 - This uses either a specific matrix code in Cython, or generic matrices. - See also - EXAMPLES: - sage: # needs sage.libs.flint sage.modules sage: P = posets.PentagonPoset()._hasse_diagram sage: M = P.coxeter_transformation(); M [ 0 0 0 0 -1] [ 0 0 0 1 -1] [ 0 1 0 0 -1] [-1 1 1 0 -1] [-1 1 0 1 -1] sage: P.__dict__['coxeter_transformation'].clear_cache() sage: P.coxeter_transformation(algorithm='matrix') == M True - >>> from sage.all import * >>> # needs sage.libs.flint sage.modules >>> P = posets.PentagonPoset()._hasse_diagram >>> M = P.coxeter_transformation(); M [ 0 0 0 0 -1] [ 0 0 0 1 -1] [ 0 1 0 0 -1] [-1 1 1 0 -1] [-1 1 0 1 -1] >>> P.__dict__['coxeter_transformation'].clear_cache() >>> P.coxeter_transformation(algorithm='matrix') == M True 
 - diamonds()[source]¶
- Return the list of diamonds of - self.- A diamond is the following subgraph of the Hasse diagram: - z / \ x y \ / w - Thus each edge represents a cover relation in the Hasse diagram. We represent his as the tuple \((w, x, y, z)\). - OUTPUT: a tuple with - a list of all diamonds in the Hasse Diagram, 
- a boolean checking that every \(w,x,y\) that form a - V, there is a unique element \(z\), which completes the diamond.
 - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1,2], 1: [3], 2: [3], 3: []}) sage: H.diamonds() ([(0, 1, 2, 3)], True) sage: P = posets.YoungDiagramPoset(Partition([3, 2, 2])) # needs sage.combinat sage.modules sage: H = P._hasse_diagram # needs sage.combinat sage.modules sage: H.diamonds() # needs sage.combinat sage.modules ([(0, 1, 3, 4), (3, 4, 5, 6)], False) - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1),Integer(2)], Integer(1): [Integer(3)], Integer(2): [Integer(3)], Integer(3): []}) >>> H.diamonds() ([(0, 1, 2, 3)], True) >>> P = posets.YoungDiagramPoset(Partition([Integer(3), Integer(2), Integer(2)])) # needs sage.combinat sage.modules >>> H = P._hasse_diagram # needs sage.combinat sage.modules >>> H.diamonds() # needs sage.combinat sage.modules ([(0, 1, 3, 4), (3, 4, 5, 6)], False) 
 - dual()[source]¶
- Return a poset that is dual to the given poset. - This means that it has the same elements but opposite order. The elements are renumbered to ensure that - range(n)is a linear extension.- EXAMPLES: - sage: P = posets.IntegerPartitions(4) # needs sage.combinat sage: H = P._hasse_diagram; H # needs sage.combinat Hasse diagram of a poset containing 5 elements sage: H.dual() # needs sage.combinat Hasse diagram of a poset containing 5 elements - >>> from sage.all import * >>> P = posets.IntegerPartitions(Integer(4)) # needs sage.combinat >>> H = P._hasse_diagram; H # needs sage.combinat Hasse diagram of a poset containing 5 elements >>> H.dual() # needs sage.combinat Hasse diagram of a poset containing 5 elements 
 - find_nonsemidistributive_elements(meet_or_join)[source]¶
- Check if the lattice is semidistributive or not. - INPUT: - meet_or_join– string- 'meet'or- 'join'to decide if to check for join-semidistributivity or meet-semidistributivity
 - OUTPUT: - Noneif the lattice is semidistributive OR
- tuple - (u, e, x, y)such that \(u = e \vee x = e \vee y\) but \(u \neq e \vee (x \wedge y)\) if- meet_or_join=='join'and \(u = e \wedge x = e \wedge y\) but \(u \neq e \wedge (x \vee y)\) if- meet_or_join=='meet'
 - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1, 2], 1:[3, 4], 2:[4, 5], 3:[6], ....: 4:[6], 5:[6]}) sage: H.find_nonsemidistributive_elements('join') is None # needs sage.modules False sage: H.find_nonsemidistributive_elements('meet') is None # needs sage.modules True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1), Integer(2)], Integer(1):[Integer(3), Integer(4)], Integer(2):[Integer(4), Integer(5)], Integer(3):[Integer(6)], ... Integer(4):[Integer(6)], Integer(5):[Integer(6)]}) >>> H.find_nonsemidistributive_elements('join') is None # needs sage.modules False >>> H.find_nonsemidistributive_elements('meet') is None # needs sage.modules True 
 - find_nonsemimodular_pair(upper)[source]¶
- Return pair of elements showing the lattice is not modular. - INPUT: - upper– boolean; if- True, test whether the lattice is upper semimodular. Otherwise test whether the lattice is lower semimodular.
 - OUTPUT: - None, if the lattice is semimodular. Pair \((a, b)\) violating semimodularity otherwise.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1, 2], 1:[3, 4], 2:[4, 5], 3:[6], 4:[6], 5:[6]}) sage: H.find_nonsemimodular_pair(upper=True) is None True sage: H.find_nonsemimodular_pair(upper=False) (5, 3) sage: H_ = HasseDiagram(H.reverse().relabel(lambda x: 6-x, inplace=False)) sage: H_.find_nonsemimodular_pair(upper=True) (3, 1) sage: H_.find_nonsemimodular_pair(upper=False) is None True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1), Integer(2)], Integer(1):[Integer(3), Integer(4)], Integer(2):[Integer(4), Integer(5)], Integer(3):[Integer(6)], Integer(4):[Integer(6)], Integer(5):[Integer(6)]}) >>> H.find_nonsemimodular_pair(upper=True) is None True >>> H.find_nonsemimodular_pair(upper=False) (5, 3) >>> H_ = HasseDiagram(H.reverse().relabel(lambda x: Integer(6)-x, inplace=False)) >>> H_.find_nonsemimodular_pair(upper=True) (3, 1) >>> H_.find_nonsemimodular_pair(upper=False) is None True 
 - find_nontrivial_congruence()[source]¶
- Return a pair that generates non-trivial congruence or - Noneif there is not any.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 1: [5], 2: [3, 4], 3: [5], 4: [5]}) sage: H.find_nontrivial_congruence() # needs sage.modules {{0, 1}, {2, 3, 4, 5}} sage: H = HasseDiagram({0: [1, 2, 3], 1: [4], 2: [4], 3: [4]}) sage: H.find_nontrivial_congruence() is None # needs sage.modules True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(5)], Integer(2): [Integer(3), Integer(4)], Integer(3): [Integer(5)], Integer(4): [Integer(5)]}) >>> H.find_nontrivial_congruence() # needs sage.modules {{0, 1}, {2, 3, 4, 5}} >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2), Integer(3)], Integer(1): [Integer(4)], Integer(2): [Integer(4)], Integer(3): [Integer(4)]}) >>> H.find_nontrivial_congruence() is None # needs sage.modules True - ALGORITHM: - See https://www.math.hawaii.edu/~ralph/Preprints/conlat.pdf: - If \(\Theta\) is a join irreducible element of a \(\mathrm{Con}(L)\), then there is at least one join-irreducible \(j\) and one meet-irreducible \(m\) such that \(\Theta\) is both the principal congruence generated by \((j^*, j)\), where \(j^*\) is the unique lower cover of \(j\), and the principal congruence generated by \((m, m^*)\), where \(m^*\) is the unique upper cover of \(m\). - So, we only check join irreducibles or meet irreducibles, whichever is a smaller set. To optimize more we stop computation whenever it finds a pair that we know to generate one-element congruence. 
 - frattini_sublattice()[source]¶
- Return the list of elements of the Frattini sublattice of the lattice. - EXAMPLES: - sage: H = posets.PentagonPoset()._hasse_diagram # needs sage.modules sage: H.frattini_sublattice() # needs sage.modules [0, 4] - >>> from sage.all import * >>> H = posets.PentagonPoset()._hasse_diagram # needs sage.modules >>> H.frattini_sublattice() # needs sage.modules [0, 4] 
 - greedy_linear_extensions_iterator()[source]¶
- Return an iterator over greedy linear extensions of the Hasse diagram. - A linear extension \([e_1, e_2, \ldots, e_n]\) is greedy if for every \(i\) either \(e_{i+1}\) covers \(e_i\) or all upper covers of \(e_i\) have at least one lower cover that is not in \([e_1, e_2, \ldots, e_i]\). - Informally said a linear extension is greedy if it “always goes up when possible” and so has no unnecessary jumps. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: N5 = HasseDiagram({0: [1, 2], 2: [3], 1: [4], 3: [4]}) sage: for l in N5.greedy_linear_extensions_iterator(): ....: print(l) [0, 1, 2, 3, 4] [0, 2, 3, 1, 4] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> N5 = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(2): [Integer(3)], Integer(1): [Integer(4)], Integer(3): [Integer(4)]}) >>> for l in N5.greedy_linear_extensions_iterator(): ... print(l) [0, 1, 2, 3, 4] [0, 2, 3, 1, 4] 
 - has_bottom()[source]¶
- Return - Trueif the poset has a unique minimal element.- EXAMPLES: - sage: P = Poset({0:[3],1:[3],2:[3],3:[4],4:[]}) sage: P.has_bottom() False sage: Q = Poset({0:[1],1:[]}) sage: Q.has_bottom() True - >>> from sage.all import * >>> P = Poset({Integer(0):[Integer(3)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[Integer(4)],Integer(4):[]}) >>> P.has_bottom() False >>> Q = Poset({Integer(0):[Integer(1)],Integer(1):[]}) >>> Q.has_bottom() True 
 - has_top()[source]¶
- Return - Trueif the poset contains a unique maximal element, and- Falseotherwise.- EXAMPLES: - sage: P = Poset({0:[3],1:[3],2:[3],3:[4,5],4:[],5:[]}) sage: P.has_top() False sage: Q = Poset({0:[1],1:[]}) sage: Q.has_top() True - >>> from sage.all import * >>> P = Poset({Integer(0):[Integer(3)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[Integer(4),Integer(5)],Integer(4):[],Integer(5):[]}) >>> P.has_top() False >>> Q = Poset({Integer(0):[Integer(1)],Integer(1):[]}) >>> Q.has_top() True 
 - interval(x, y)[source]¶
- Return a list of the elements \(z\) of - selfsuch that \(x \leq z \leq y\).- The order is that induced by the ordering in - self.linear_extension.- INPUT: - x– any element of the poset
- y– any element of the poset
 - Note - The method - _precompute_intervals()creates a cache which is used if available, making the function very fast.- See also - EXAMPLES: - sage: uc = [[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] sage: dag = DiGraph(dict(zip(range(len(uc)),uc))) sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram(dag) sage: I = set([2,5,6,4,7]) sage: I == set(H.interval(2,7)) True - >>> from sage.all import * >>> uc = [[Integer(1),Integer(3),Integer(2)],[Integer(4)],[Integer(4),Integer(5),Integer(6)],[Integer(6)],[Integer(7)],[Integer(7)],[Integer(7)],[]] >>> dag = DiGraph(dict(zip(range(len(uc)),uc))) >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram(dag) >>> I = set([Integer(2),Integer(5),Integer(6),Integer(4),Integer(7)]) >>> I == set(H.interval(Integer(2),Integer(7))) True 
 - interval_iterator(x, y)[source]¶
- Return an iterator of the elements \(z\) of - selfsuch that \(x \leq z \leq y\).- INPUT: - x– any element of the poset
- y– any element of the poset
 - See also - Note - This becomes much faster when first calling - _leq_storage(), which precomputes the principal upper ideals.- EXAMPLES: - sage: uc = [[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] sage: dag = DiGraph(dict(zip(range(len(uc)),uc))) sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram(dag) sage: I = set([2,5,6,4,7]) sage: I == set(H.interval_iterator(2,7)) True - >>> from sage.all import * >>> uc = [[Integer(1),Integer(3),Integer(2)],[Integer(4)],[Integer(4),Integer(5),Integer(6)],[Integer(6)],[Integer(7)],[Integer(7)],[Integer(7)],[]] >>> dag = DiGraph(dict(zip(range(len(uc)),uc))) >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram(dag) >>> I = set([Integer(2),Integer(5),Integer(6),Integer(4),Integer(7)]) >>> I == set(H.interval_iterator(Integer(2),Integer(7))) True 
 - is_antichain_of_poset(elms)[source]¶
- Return - Trueif- elmsis an antichain of the Hasse diagram and- Falseotherwise.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2, 3], 1: [4], 2: [4], 3: [4]}) sage: H.is_antichain_of_poset([1, 2, 3]) True sage: H.is_antichain_of_poset([0, 2, 3]) False - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2), Integer(3)], Integer(1): [Integer(4)], Integer(2): [Integer(4)], Integer(3): [Integer(4)]}) >>> H.is_antichain_of_poset([Integer(1), Integer(2), Integer(3)]) True >>> H.is_antichain_of_poset([Integer(0), Integer(2), Integer(3)]) False 
 - is_bounded()[source]¶
- Return - Trueif the poset contains a unique maximal element and a unique minimal element, and- Falseotherwise.- EXAMPLES: - sage: P = Poset({0:[3],1:[3],2:[3],3:[4,5],4:[],5:[]}) sage: P.is_bounded() False sage: Q = Poset({0:[1],1:[]}) sage: Q.is_bounded() True - >>> from sage.all import * >>> P = Poset({Integer(0):[Integer(3)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[Integer(4),Integer(5)],Integer(4):[],Integer(5):[]}) >>> P.is_bounded() False >>> Q = Poset({Integer(0):[Integer(1)],Integer(1):[]}) >>> Q.is_bounded() True 
 - is_chain()[source]¶
- Return - Trueif the poset is totally ordered, and- Falseotherwise.- EXAMPLES: - sage: L = Poset({0:[1],1:[2],2:[3],3:[4]}) sage: L.is_chain() True sage: V = Poset({0:[1,2]}) sage: V.is_chain() False - >>> from sage.all import * >>> L = Poset({Integer(0):[Integer(1)],Integer(1):[Integer(2)],Integer(2):[Integer(3)],Integer(3):[Integer(4)]}) >>> L.is_chain() True >>> V = Poset({Integer(0):[Integer(1),Integer(2)]}) >>> V.is_chain() False 
 - is_complemented()[source]¶
- Return an element of the lattice that has no complement. - If the lattice is complemented, return - None.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1, 2], 1:[3], 2:[3], 3:[4]}) sage: H.is_complemented() # needs sage.modules 1 sage: H = HasseDiagram({0:[1, 2, 3], 1:[4], 2:[4], 3:[4]}) sage: H.is_complemented() is None # needs sage.modules True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1), Integer(2)], Integer(1):[Integer(3)], Integer(2):[Integer(3)], Integer(3):[Integer(4)]}) >>> H.is_complemented() # needs sage.modules 1 >>> H = HasseDiagram({Integer(0):[Integer(1), Integer(2), Integer(3)], Integer(1):[Integer(4)], Integer(2):[Integer(4)], Integer(3):[Integer(4)]}) >>> H.is_complemented() is None # needs sage.modules True 
 - is_congruence_normal()[source]¶
- Return - Trueif the lattice can be constructed from the one-element lattice with Day doubling constructions of convex subsets.- Subsets to double does not need to be lower nor upper pseudo-intervals. On the other hand they must be convex, i.e. doubling a non-convex but municipal subset will give a lattice that returns - Falsefrom this function.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram('IX?Q@?AG?OG?W?O@??') sage: H.is_congruence_normal() # needs sage.combinat sage.modules True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram('IX?Q@?AG?OG?W?O@??') >>> H.is_congruence_normal() # needs sage.combinat sage.modules True - The 5-element diamond is the smallest non-example: - sage: H = HasseDiagram({0: [1, 2, 3], 1: [4], 2: [4], 3: [4]}) sage: H.is_congruence_normal() # needs sage.combinat sage.modules False - >>> from sage.all import * >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2), Integer(3)], Integer(1): [Integer(4)], Integer(2): [Integer(4)], Integer(3): [Integer(4)]}) >>> H.is_congruence_normal() # needs sage.combinat sage.modules False - This is done by doubling a non-convex subset: - sage: H = HasseDiagram('OQC?a?@CO?G_C@?GA?O??_??@?BO?A_?G??C??_?@???') sage: H.is_congruence_normal() # needs sage.combinat sage.modules False - >>> from sage.all import * >>> H = HasseDiagram('OQC?a?@CO?G_C@?GA?O??_??@?BO?A_?G??C??_?@???') >>> H.is_congruence_normal() # needs sage.combinat sage.modules False - ALGORITHM: 
 - is_convex_subset(S)[source]¶
- Return - Trueif \(S\) is a convex subset of the poset, and- Falseotherwise.- A subset \(S\) is convex in the poset if \(b \in S\) whenever \(a, c \in S\) and \(a \le b \le c\). - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: B3 = HasseDiagram({0: [1, 2, 4], 1: [3, 5], 2: [3, 6], ....: 3: [7], 4: [5, 6], 5: [7], 6: [7]}) sage: B3.is_convex_subset([1, 3, 5, 4]) # Also connected True sage: B3.is_convex_subset([1, 3, 4]) # Not connected True sage: B3.is_convex_subset([0, 1, 2, 3, 6]) # No, 0 < 4 < 6 False sage: B3.is_convex_subset([0, 1, 2, 7]) # No, 1 < 3 < 7. False - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> B3 = HasseDiagram({Integer(0): [Integer(1), Integer(2), Integer(4)], Integer(1): [Integer(3), Integer(5)], Integer(2): [Integer(3), Integer(6)], ... Integer(3): [Integer(7)], Integer(4): [Integer(5), Integer(6)], Integer(5): [Integer(7)], Integer(6): [Integer(7)]}) >>> B3.is_convex_subset([Integer(1), Integer(3), Integer(5), Integer(4)]) # Also connected True >>> B3.is_convex_subset([Integer(1), Integer(3), Integer(4)]) # Not connected True >>> B3.is_convex_subset([Integer(0), Integer(1), Integer(2), Integer(3), Integer(6)]) # No, 0 < 4 < 6 False >>> B3.is_convex_subset([Integer(0), Integer(1), Integer(2), Integer(7)]) # No, 1 < 3 < 7. False 
 - is_gequal(x, y)[source]¶
- Return - Trueif- xis greater than or equal to- y, and- Falseotherwise.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: Q = HasseDiagram({0:[2], 1:[2], 2:[3], 3:[4], 4:[]}) sage: x,y,z = 0,1,4 sage: Q.is_gequal(x,y) False sage: Q.is_gequal(y,x) False sage: Q.is_gequal(x,z) False sage: Q.is_gequal(z,x) True sage: Q.is_gequal(z,y) True sage: Q.is_gequal(z,z) True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> Q = HasseDiagram({Integer(0):[Integer(2)], Integer(1):[Integer(2)], Integer(2):[Integer(3)], Integer(3):[Integer(4)], Integer(4):[]}) >>> x,y,z = Integer(0),Integer(1),Integer(4) >>> Q.is_gequal(x,y) False >>> Q.is_gequal(y,x) False >>> Q.is_gequal(x,z) False >>> Q.is_gequal(z,x) True >>> Q.is_gequal(z,y) True >>> Q.is_gequal(z,z) True 
 - is_greater_than(x, y)[source]¶
- Return - Trueif- xis greater than but not equal to- y, and- Falseotherwise.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: Q = HasseDiagram({0:[2], 1:[2], 2:[3], 3:[4], 4:[]}) sage: x,y,z = 0,1,4 sage: Q.is_greater_than(x,y) False sage: Q.is_greater_than(y,x) False sage: Q.is_greater_than(x,z) False sage: Q.is_greater_than(z,x) True sage: Q.is_greater_than(z,y) True sage: Q.is_greater_than(z,z) False - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> Q = HasseDiagram({Integer(0):[Integer(2)], Integer(1):[Integer(2)], Integer(2):[Integer(3)], Integer(3):[Integer(4)], Integer(4):[]}) >>> x,y,z = Integer(0),Integer(1),Integer(4) >>> Q.is_greater_than(x,y) False >>> Q.is_greater_than(y,x) False >>> Q.is_greater_than(x,z) False >>> Q.is_greater_than(z,x) True >>> Q.is_greater_than(z,y) True >>> Q.is_greater_than(z,z) False 
 - is_join_semilattice()[source]¶
- Return - Trueif- selfhas a join operation, and- Falseotherwise.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,3,2],1:[4],2:[4,5,6],3:[6],4:[7],5:[7],6:[7],7:[]}) sage: H.is_join_semilattice() # needs sage.modules True sage: H = HasseDiagram({0:[2,3],1:[2,3]}) sage: H.is_join_semilattice() # needs sage.modules False sage: H = HasseDiagram({0:[2,3],1:[2,3],2:[4],3:[4]}) sage: H.is_join_semilattice() # needs sage.modules False - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(3),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(4),Integer(5),Integer(6)],Integer(3):[Integer(6)],Integer(4):[Integer(7)],Integer(5):[Integer(7)],Integer(6):[Integer(7)],Integer(7):[]}) >>> H.is_join_semilattice() # needs sage.modules True >>> H = HasseDiagram({Integer(0):[Integer(2),Integer(3)],Integer(1):[Integer(2),Integer(3)]}) >>> H.is_join_semilattice() # needs sage.modules False >>> H = HasseDiagram({Integer(0):[Integer(2),Integer(3)],Integer(1):[Integer(2),Integer(3)],Integer(2):[Integer(4)],Integer(3):[Integer(4)]}) >>> H.is_join_semilattice() # needs sage.modules False 
 - is_lequal(i, j)[source]¶
- Return - Trueif i is less than or equal to j in the poset, and- Falseotherwise.- Note - If the - lequal_matrix()has been computed, then this method is redefined to use the cached data (see- _alternate_is_lequal()).- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[2], 1:[2], 2:[3], 3:[4], 4:[]}) sage: x,y,z = 0, 1, 4 sage: H.is_lequal(x,y) False sage: H.is_lequal(y,x) False sage: H.is_lequal(x,z) True sage: H.is_lequal(y,z) True sage: H.is_lequal(z,z) True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(2)], Integer(1):[Integer(2)], Integer(2):[Integer(3)], Integer(3):[Integer(4)], Integer(4):[]}) >>> x,y,z = Integer(0), Integer(1), Integer(4) >>> H.is_lequal(x,y) False >>> H.is_lequal(y,x) False >>> H.is_lequal(x,z) True >>> H.is_lequal(y,z) True >>> H.is_lequal(z,z) True 
 - is_less_than(x, y)[source]¶
- Return - Trueif- xis less than but not equal to- yin the poset, and- Falseotherwise.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[2], 1:[2], 2:[3], 3:[4], 4:[]}) sage: x,y,z = 0, 1, 4 sage: H.is_less_than(x,y) False sage: H.is_less_than(y,x) False sage: H.is_less_than(x,z) True sage: H.is_less_than(y,z) True sage: H.is_less_than(z,z) False - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(2)], Integer(1):[Integer(2)], Integer(2):[Integer(3)], Integer(3):[Integer(4)], Integer(4):[]}) >>> x,y,z = Integer(0), Integer(1), Integer(4) >>> H.is_less_than(x,y) False >>> H.is_less_than(y,x) False >>> H.is_less_than(x,z) True >>> H.is_less_than(y,z) True >>> H.is_less_than(z,z) False 
 - is_linear_extension(lin_ext=None)[source]¶
- Test if an ordering is a linear extension. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,2],1:[3],2:[3],3:[]}) sage: H.is_linear_extension(list(range(4))) True sage: H.is_linear_extension([3,2,1,0]) False - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(2)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[]}) >>> H.is_linear_extension(list(range(Integer(4)))) True >>> H.is_linear_extension([Integer(3),Integer(2),Integer(1),Integer(0)]) False 
 - is_linear_interval(t_min, t_max)[source]¶
- Return whether the interval - [t_min, t_max]is linear.- This means that this interval is a total order. - EXAMPLES::
- sage: # needs sage.modules sage: P = posets.PentagonPoset() sage: H = P._hasse_diagram sage: H.is_linear_interval(0, 4) False sage: H.is_linear_interval(0, 3) True sage: H.is_linear_interval(1, 3) False sage: H.is_linear_interval(1, 1) True 
 
 - is_meet_semilattice()[source]¶
- Return - Trueif- selfhas a meet operation, and- Falseotherwise.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,3,2],1:[4],2:[4,5,6],3:[6],4:[7],5:[7],6:[7],7:[]}) sage: H.is_meet_semilattice() # needs sage.modules True sage: H = HasseDiagram({0:[1,2],1:[3],2:[3],3:[]}) sage: H.is_meet_semilattice() # needs sage.modules True sage: H = HasseDiagram({0:[2,3],1:[2,3]}) sage: H.is_meet_semilattice() # needs sage.modules False sage: H = HasseDiagram({0:[1,2],1:[3,4],2:[3,4]}) sage: H.is_meet_semilattice() # needs sage.modules False - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(3),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(4),Integer(5),Integer(6)],Integer(3):[Integer(6)],Integer(4):[Integer(7)],Integer(5):[Integer(7)],Integer(6):[Integer(7)],Integer(7):[]}) >>> H.is_meet_semilattice() # needs sage.modules True >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(2)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[]}) >>> H.is_meet_semilattice() # needs sage.modules True >>> H = HasseDiagram({Integer(0):[Integer(2),Integer(3)],Integer(1):[Integer(2),Integer(3)]}) >>> H.is_meet_semilattice() # needs sage.modules False >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(2)],Integer(1):[Integer(3),Integer(4)],Integer(2):[Integer(3),Integer(4)]}) >>> H.is_meet_semilattice() # needs sage.modules False 
 - is_ranked()[source]¶
- Return - Trueif the poset is ranked, and- Falseotherwise.- A poset is ranked if it admits a rank function. For more information about the rank function, see - rank_function()and- is_graded().- EXAMPLES: - sage: P = Poset([[1],[2],[3],[4],[]]) sage: P.is_ranked() True sage: Q = Poset([[1,5],[2,6],[3],[4],[],[6,3],[4]]) sage: Q.is_ranked() False - >>> from sage.all import * >>> P = Poset([[Integer(1)],[Integer(2)],[Integer(3)],[Integer(4)],[]]) >>> P.is_ranked() True >>> Q = Poset([[Integer(1),Integer(5)],[Integer(2),Integer(6)],[Integer(3)],[Integer(4)],[],[Integer(6),Integer(3)],[Integer(4)]]) >>> Q.is_ranked() False 
 - join_matrix()[source]¶
- Return the matrix of joins of - self, when- selfis a join-semilattice; raise an error otherwise.- The - (x,y)-entry of this matrix is the join of- xand- yin- self.- This algorithm is modelled after the algorithm of Freese-Jezek-Nation (p217). It can also be found on page 140 of [Gec81]. - Note - If - selfis a join-semilattice, then the return of this method is the same as- _join(). Once the matrix has been computed, it is stored in- _join(). Delete this attribute if you want to recompute the matrix.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,3,2],1:[4],2:[4,5,6],3:[6],4:[7],5:[7],6:[7],7:[]}) sage: H.join_matrix() # needs sage.modules [0 1 2 3 4 5 6 7] [1 1 4 7 4 7 7 7] [2 4 2 6 4 5 6 7] [3 7 6 3 7 7 6 7] [4 4 4 7 4 7 7 7] [5 7 5 7 7 5 7 7] [6 7 6 6 7 7 6 7] [7 7 7 7 7 7 7 7] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(3),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(4),Integer(5),Integer(6)],Integer(3):[Integer(6)],Integer(4):[Integer(7)],Integer(5):[Integer(7)],Integer(6):[Integer(7)],Integer(7):[]}) >>> H.join_matrix() # needs sage.modules [0 1 2 3 4 5 6 7] [1 1 4 7 4 7 7 7] [2 4 2 6 4 5 6 7] [3 7 6 3 7 7 6 7] [4 4 4 7 4 7 7 7] [5 7 5 7 7 5 7 7] [6 7 6 6 7 7 6 7] [7 7 7 7 7 7 7 7] 
 - kappa(a)[source]¶
- Return the maximum element greater than the element covered by - abut not greater than- a.- Define \(\kappa(a)\) as the maximum element of \((\uparrow a_*) \setminus (\uparrow a)\), where \(a_*\) is the element covered by \(a\). It is always a meet-irreducible element, if it exists. - Note - Element - ais expected to be join-irreducible, and this is not checked.- INPUT: - a– a join-irreducible element of the lattice
 - OUTPUT: - The element \(\kappa(a)\) or - Noneif there is not a unique greatest element with given constraints.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2, 3], 1: [4], 2: [4, 5], 3: [5], 4: [6], 5: [6]}) sage: H.kappa(1) 5 sage: H.kappa(2) is None True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2), Integer(3)], Integer(1): [Integer(4)], Integer(2): [Integer(4), Integer(5)], Integer(3): [Integer(5)], Integer(4): [Integer(6)], Integer(5): [Integer(6)]}) >>> H.kappa(Integer(1)) 5 >>> H.kappa(Integer(2)) is None True 
 - kappa_dual(a)[source]¶
- Return the minimum element smaller than the element covering - abut not smaller than- a.- Define \(\kappa^*(a)\) as the minimum element of \((\downarrow a_*) \setminus (\downarrow a)\), where \(a_*\) is the element covering \(a\). It is always a join-irreducible element, if it exists. - Note - Element - ais expected to be meet-irreducible, and this is not checked.- INPUT: - a– a join-irreducible element of the lattice
 - OUTPUT: - The element \(\kappa^*(a)\) or - Noneif there is not a unique smallest element with given constraints.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 1: [3, 4], 2: [4, 5], 3: [6], 4: [6], 5: [6]}) sage: H.kappa_dual(3) 2 sage: H.kappa_dual(4) is None True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(3), Integer(4)], Integer(2): [Integer(4), Integer(5)], Integer(3): [Integer(6)], Integer(4): [Integer(6)], Integer(5): [Integer(6)]}) >>> H.kappa_dual(Integer(3)) 2 >>> H.kappa_dual(Integer(4)) is None True 
 - lequal_matrix(boolean=False)[source]¶
- Return a matrix whose - (i,j)entry is 1 if- iis less than- jin the poset, and 0 otherwise; and redefines- __lt__to use the boolean version of this matrix.- INPUT: - boolean– flag (default:- False); whether to return a matrix with coefficients in \(\GF(2)\) or in \(\ZZ\)
 - EXAMPLES: - sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]]) sage: H = P._hasse_diagram sage: M = H.lequal_matrix(); M # needs sage.modules [1 1 1 1 1 1 1 1] [0 1 0 1 0 0 0 1] [0 0 1 1 1 0 1 1] [0 0 0 1 0 0 0 1] [0 0 0 0 1 0 0 1] [0 0 0 0 0 1 1 1] [0 0 0 0 0 0 1 1] [0 0 0 0 0 0 0 1] sage: M.base_ring() # needs sage.modules Integer Ring sage: P = posets.DiamondPoset(6) sage: H = P._hasse_diagram sage: M = H.lequal_matrix(boolean=True) # needs sage.modules sage: M.base_ring() # needs sage.modules Finite Field of size 2 - >>> from sage.all import * >>> P = Poset([[Integer(1),Integer(3),Integer(2)],[Integer(4)],[Integer(4),Integer(5),Integer(6)],[Integer(6)],[Integer(7)],[Integer(7)],[Integer(7)],[]]) >>> H = P._hasse_diagram >>> M = H.lequal_matrix(); M # needs sage.modules [1 1 1 1 1 1 1 1] [0 1 0 1 0 0 0 1] [0 0 1 1 1 0 1 1] [0 0 0 1 0 0 0 1] [0 0 0 0 1 0 0 1] [0 0 0 0 0 1 1 1] [0 0 0 0 0 0 1 1] [0 0 0 0 0 0 0 1] >>> M.base_ring() # needs sage.modules Integer Ring >>> P = posets.DiamondPoset(Integer(6)) >>> H = P._hasse_diagram >>> M = H.lequal_matrix(boolean=True) # needs sage.modules >>> M.base_ring() # needs sage.modules Finite Field of size 2 
 - linear_extension()[source]¶
- Return a linear extension. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,2],1:[3],2:[3],3:[]}) sage: H.linear_extension() [0, 1, 2, 3] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(2)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[]}) >>> H.linear_extension() [0, 1, 2, 3] 
 - linear_extensions()[source]¶
- Return an iterator over all linear extensions. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,2],1:[3],2:[3],3:[]}) sage: list(H.linear_extensions()) # needs sage.modules [[0, 1, 2, 3], [0, 2, 1, 3]] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(2)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[]}) >>> list(H.linear_extensions()) # needs sage.modules [[0, 1, 2, 3], [0, 2, 1, 3]] 
 - lower_covers_iterator(element)[source]¶
- Return the list of elements that are covered by - element.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,3,2],1:[4],2:[4,5,6],3:[6],4:[7],5:[7],6:[7],7:[]}) sage: list(H.lower_covers_iterator(0)) [] sage: list(H.lower_covers_iterator(4)) [1, 2] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(3),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(4),Integer(5),Integer(6)],Integer(3):[Integer(6)],Integer(4):[Integer(7)],Integer(5):[Integer(7)],Integer(6):[Integer(7)],Integer(7):[]}) >>> list(H.lower_covers_iterator(Integer(0))) [] >>> list(H.lower_covers_iterator(Integer(4))) [1, 2] 
 - maximal_elements()[source]¶
- Return a list of the maximal elements of the poset. - EXAMPLES: - sage: P = Poset({0:[3],1:[3],2:[3],3:[4],4:[]}) sage: P.maximal_elements() [4] - >>> from sage.all import * >>> P = Poset({Integer(0):[Integer(3)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[Integer(4)],Integer(4):[]}) >>> P.maximal_elements() [4] 
 - maximal_sublattices()[source]¶
- Return maximal sublattices of the lattice. - EXAMPLES: - sage: L = posets.PentagonPoset() # needs sage.modules sage: ms = L._hasse_diagram.maximal_sublattices() # needs sage.modules sage: sorted(ms, key=sorted) # needs sage.modules [{0, 1, 2, 4}, {0, 1, 3, 4}, {0, 2, 3, 4}] - >>> from sage.all import * >>> L = posets.PentagonPoset() # needs sage.modules >>> ms = L._hasse_diagram.maximal_sublattices() # needs sage.modules >>> sorted(ms, key=sorted) # needs sage.modules [{0, 1, 2, 4}, {0, 1, 3, 4}, {0, 2, 3, 4}] 
 - meet_matrix()[source]¶
- Return the matrix of meets of - self, when- selfis a meet-semilattice; raise an error otherwise.- The - (x,y)-entry of this matrix is the meet of- xand- yin- self.- This algorithm is modelled after the algorithm of Freese-Jezek-Nation (p217). It can also be found on page 140 of [Gec81]. - Note - If - selfis a meet-semilattice, then the return of this method is the same as- _meet(). Once the matrix has been computed, it is stored in- _meet(). Delete this attribute if you want to recompute the matrix.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,3,2],1:[4],2:[4,5,6],3:[6],4:[7],5:[7],6:[7],7:[]}) sage: H.meet_matrix() # needs sage.modules [0 0 0 0 0 0 0 0] [0 1 0 0 1 0 0 1] [0 0 2 0 2 2 2 2] [0 0 0 3 0 0 3 3] [0 1 2 0 4 2 2 4] [0 0 2 0 2 5 2 5] [0 0 2 3 2 2 6 6] [0 1 2 3 4 5 6 7] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(3),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(4),Integer(5),Integer(6)],Integer(3):[Integer(6)],Integer(4):[Integer(7)],Integer(5):[Integer(7)],Integer(6):[Integer(7)],Integer(7):[]}) >>> H.meet_matrix() # needs sage.modules [0 0 0 0 0 0 0 0] [0 1 0 0 1 0 0 1] [0 0 2 0 2 2 2 2] [0 0 0 3 0 0 3 3] [0 1 2 0 4 2 2 4] [0 0 2 0 2 5 2 5] [0 0 2 3 2 2 6 6] [0 1 2 3 4 5 6 7] - REFERENCE: 
 - minimal_elements()[source]¶
- Return a list of the minimal elements of the poset. - EXAMPLES: - sage: P = Poset({0:[3],1:[3],2:[3],3:[4],4:[]}) sage: P(0) in P.minimal_elements() True sage: P(1) in P.minimal_elements() True sage: P(2) in P.minimal_elements() True - >>> from sage.all import * >>> P = Poset({Integer(0):[Integer(3)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[Integer(4)],Integer(4):[]}) >>> P(Integer(0)) in P.minimal_elements() True >>> P(Integer(1)) in P.minimal_elements() True >>> P(Integer(2)) in P.minimal_elements() True 
 - moebius_function(i, j)[source]¶
- Return the value of the Möbius function of the poset on the elements - iand- j.- EXAMPLES: - sage: P = Poset([[1,2,3],[4],[4],[4],[]]) sage: H = P._hasse_diagram sage: H.moebius_function(0,4) 2 sage: for u,v in P.cover_relations_iterator(): ....: if P.moebius_function(u,v) != -1: ....: print("Bug in moebius_function!") - >>> from sage.all import * >>> P = Poset([[Integer(1),Integer(2),Integer(3)],[Integer(4)],[Integer(4)],[Integer(4)],[]]) >>> H = P._hasse_diagram >>> H.moebius_function(Integer(0),Integer(4)) 2 >>> for u,v in P.cover_relations_iterator(): ... if P.moebius_function(u,v) != -Integer(1): ... print("Bug in moebius_function!") 
 - moebius_function_matrix(algorithm='cython')[source]¶
- Return the matrix of the Möbius function of this poset. - This returns the matrix over \(\ZZ\) whose - (x, y)entry is the value of the Möbius function of- selfevaluated on- xand- y, and redefines- moebius_function()to use it.- INPUT: - algorithm–- 'recursive',- 'matrix'or- 'cython'(default)
 - This uses either the recursive formula, a generic matrix inversion or a specific matrix inversion coded in Cython. - OUTPUT: a dense matrix for the algorithm - cython, a sparse matrix otherwise- Note - The result is cached in - _moebius_function_matrix().- See also - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,3,2],1:[4],2:[4,5,6],3:[6],4:[7],5:[7],6:[7],7:[]}) sage: H.moebius_function_matrix() # needs sage.libs.flint sage.modules [ 1 -1 -1 -1 1 0 1 0] [ 0 1 0 0 -1 0 0 0] [ 0 0 1 0 -1 -1 -1 2] [ 0 0 0 1 0 0 -1 0] [ 0 0 0 0 1 0 0 -1] [ 0 0 0 0 0 1 0 -1] [ 0 0 0 0 0 0 1 -1] [ 0 0 0 0 0 0 0 1] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(3),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(4),Integer(5),Integer(6)],Integer(3):[Integer(6)],Integer(4):[Integer(7)],Integer(5):[Integer(7)],Integer(6):[Integer(7)],Integer(7):[]}) >>> H.moebius_function_matrix() # needs sage.libs.flint sage.modules [ 1 -1 -1 -1 1 0 1 0] [ 0 1 0 0 -1 0 0 0] [ 0 0 1 0 -1 -1 -1 2] [ 0 0 0 1 0 0 -1 0] [ 0 0 0 0 1 0 0 -1] [ 0 0 0 0 0 1 0 -1] [ 0 0 0 0 0 0 1 -1] [ 0 0 0 0 0 0 0 1] 
 - neutral_elements()[source]¶
- Return the list of neutral elements of the lattice. - An element \(a\) in a lattice is neutral if the sublattice generated by \(a\), \(x\) and \(y\) is distributive for every \(x\), \(y\) in the lattice. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 1: [4], 2: [3], 3: [4, 5], ....: 4: [6], 5: [6]}) sage: sorted(H.neutral_elements()) # needs sage.modules [0, 4, 6] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(4)], Integer(2): [Integer(3)], Integer(3): [Integer(4), Integer(5)], ... Integer(4): [Integer(6)], Integer(5): [Integer(6)]}) >>> sorted(H.neutral_elements()) # needs sage.modules [0, 4, 6] - ALGORITHM: - Basically we just check the distributivity against all element pairs \(x, y\) to see if element \(a\) is neutral or not. - If we found that \(a, x, y\) is not a distributive triple, we add all three to list of non-neutral elements. If we found \(a\) to be neutral, we add it to list of neutral elements. When testing we skip already found neutral elements, as they can’t be our \(x\) or \(y\). - We skip \(a, x, y\) as trivial if it is a chain. We do that by letting \(x\) to be a non-comparable to \(a\); \(y\) can be any element. - We first try to found \(x\) and \(y\) from elements not yet tested, so that we could get three birds with one stone. - And last, the top and bottom elements are always neutral and need not be tested. 
 - open_interval(x, y)[source]¶
- Return a list of the elements \(z\) of - selfsuch that \(x < z < y\).- The order is that induced by the ordering in - self.linear_extension.- EXAMPLES: - sage: uc = [[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] sage: dag = DiGraph(dict(zip(range(len(uc)),uc))) sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram(dag) sage: set([5,6,4]) == set(H.open_interval(2,7)) True sage: H.open_interval(7,2) [] - >>> from sage.all import * >>> uc = [[Integer(1),Integer(3),Integer(2)],[Integer(4)],[Integer(4),Integer(5),Integer(6)],[Integer(6)],[Integer(7)],[Integer(7)],[Integer(7)],[]] >>> dag = DiGraph(dict(zip(range(len(uc)),uc))) >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram(dag) >>> set([Integer(5),Integer(6),Integer(4)]) == set(H.open_interval(Integer(2),Integer(7))) True >>> H.open_interval(Integer(7),Integer(2)) [] 
 - order_filter(elements)[source]¶
- Return the order filter generated by a list of elements. - \(I\) is an order filter if, for any \(x\) in \(I\) and \(y\) such that \(y \ge x\), then \(y\) is in \(I\). - EXAMPLES: - sage: H = posets.BooleanLattice(4)._hasse_diagram sage: H.order_filter([3,8]) [3, 7, 8, 9, 10, 11, 12, 13, 14, 15] - >>> from sage.all import * >>> H = posets.BooleanLattice(Integer(4))._hasse_diagram >>> H.order_filter([Integer(3),Integer(8)]) [3, 7, 8, 9, 10, 11, 12, 13, 14, 15] 
 - order_ideal(elements)[source]¶
- Return the order ideal generated by a list of elements. - \(I\) is an order ideal if, for any \(x\) in \(I\) and \(y\) such that \(y \le x\), then \(y\) is in \(I\). - EXAMPLES: - sage: H = posets.BooleanLattice(4)._hasse_diagram sage: H.order_ideal([7,10]) [0, 1, 2, 3, 4, 5, 6, 7, 8, 10] - >>> from sage.all import * >>> H = posets.BooleanLattice(Integer(4))._hasse_diagram >>> H.order_ideal([Integer(7),Integer(10)]) [0, 1, 2, 3, 4, 5, 6, 7, 8, 10] 
 - order_ideal_cardinality(elements)[source]¶
- Return the cardinality of the order ideal generated by - elements.- \(I\) is an order ideal if, for any \(x\) in \(I\) and \(y\) such that \(y \le x\), then \(y\) is in \(I\). - EXAMPLES: - sage: H = posets.BooleanLattice(4)._hasse_diagram sage: H.order_ideal_cardinality([7,10]) 10 - >>> from sage.all import * >>> H = posets.BooleanLattice(Integer(4))._hasse_diagram >>> H.order_ideal_cardinality([Integer(7),Integer(10)]) 10 
 - orthocomplementations_iterator()[source]¶
- Return an iterator over orthocomplementations of the lattice. - OUTPUT: an iterator that gives plain list of integers - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,2], 1:[3,4], 3:[5], 4:[5], 2:[6,7], ....: 6:[8], 7:[8], 5:[9], 8:[9]}) sage: list(H.orthocomplementations_iterator()) # needs sage.groups [[9, 8, 5, 6, 7, 2, 3, 4, 1, 0], [9, 8, 5, 7, 6, 2, 4, 3, 1, 0]] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(2)], Integer(1):[Integer(3),Integer(4)], Integer(3):[Integer(5)], Integer(4):[Integer(5)], Integer(2):[Integer(6),Integer(7)], ... Integer(6):[Integer(8)], Integer(7):[Integer(8)], Integer(5):[Integer(9)], Integer(8):[Integer(9)]}) >>> list(H.orthocomplementations_iterator()) # needs sage.groups [[9, 8, 5, 6, 7, 2, 3, 4, 1, 0], [9, 8, 5, 7, 6, 2, 4, 3, 1, 0]] - ALGORITHM: - As - DiamondPoset(2*n+2)has \((2n)!/(n!2^n)\) different orthocomplementations, the complexity of listing all of them is necessarily \(O(n!)\).- An orthocomplemented lattice is self-dual, so that for example orthocomplement of an atom is a coatom. This function basically just computes list of possible orthocomplementations for every element (i.e. they must be complements and “duals”), and then tries to fit them all. 
 - prime_elements()[source]¶
- Return the join-prime and meet-prime elements of the bounded poset. - An element \(x\) of a poset \(P\) is join-prime if the subposet induced by \(\{y \in P \mid y \not\ge x\}\) has a top element. Meet-prime is defined dually. - Note - The poset is expected to be bounded, and this is not checked. - OUTPUT: - A pair \((j, m)\) where \(j\) is a list of join-prime elements and \(m\) is a list of meet-prime elements. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 1: [3], 2: [4], 3: [4]}) sage: H.prime_elements() ([1, 2], [2, 3]) - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(3)], Integer(2): [Integer(4)], Integer(3): [Integer(4)]}) >>> H.prime_elements() ([1, 2], [2, 3]) 
 - principal_congruences_poset()[source]¶
- Return the poset of join-irreducibles of the congruence lattice. - OUTPUT: - A pair \((P, D)\) where \(P\) is a poset and \(D\) is a dictionary. - Elements of \(P\) are pairs \((x, y)\) such that \(x\) is an element of the lattice and \(y\) is an element covering it. In the poset \((a, b)\) is less than \((c, d)\) iff the principal congruence generated by \((a, b)\) is refinement of the principal congruence generated by \((c, d)\). - \(D\) is a dictionary from pairs \((x, y)\) to the congruence (given as DisjointSet) generated by the pair. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: N5 = HasseDiagram({0: [1, 2], 1: [4], 2: [3], 3: [4]}) sage: P, D = N5.principal_congruences_poset() # needs sage.combinat sage.modules sage: P # needs sage.combinat sage.modules Finite poset containing 3 elements sage: P.bottom() # needs sage.combinat sage.modules (2, 3) sage: D[(2, 3)] # needs sage.combinat sage.modules {{0}, {1}, {2, 3}, {4}} - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> N5 = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(4)], Integer(2): [Integer(3)], Integer(3): [Integer(4)]}) >>> P, D = N5.principal_congruences_poset() # needs sage.combinat sage.modules >>> P # needs sage.combinat sage.modules Finite poset containing 3 elements >>> P.bottom() # needs sage.combinat sage.modules (2, 3) >>> D[(Integer(2), Integer(3))] # needs sage.combinat sage.modules {{0}, {1}, {2, 3}, {4}} 
 - principal_order_filter(i)[source]¶
- Return the order filter generated by - i.- EXAMPLES: - sage: H = posets.BooleanLattice(4)._hasse_diagram sage: H.principal_order_filter(2) [2, 3, 6, 7, 10, 11, 14, 15] - >>> from sage.all import * >>> H = posets.BooleanLattice(Integer(4))._hasse_diagram >>> H.principal_order_filter(Integer(2)) [2, 3, 6, 7, 10, 11, 14, 15] 
 - principal_order_ideal(i)[source]¶
- Return the order ideal generated by \(i\). - EXAMPLES: - sage: H = posets.BooleanLattice(4)._hasse_diagram sage: H.principal_order_ideal(6) [0, 2, 4, 6] - >>> from sage.all import * >>> H = posets.BooleanLattice(Integer(4))._hasse_diagram >>> H.principal_order_ideal(Integer(6)) [0, 2, 4, 6] 
 - pseudocomplement(element)[source]¶
- Return the pseudocomplement of - element, if it exists.- The pseudocomplement is the greatest element whose meet with given element is the bottom element. It may not exist, and then the function returns - None.- INPUT: - element– an element of the lattice
 - OUTPUT: - An element of the Hasse diagram, i.e. an integer, or - Noneif the pseudocomplement does not exist.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 1: [3], 2: [4], 3: [4]}) sage: H.pseudocomplement(2) # needs sage.modules 3 sage: H = HasseDiagram({0: [1, 2, 3], 1: [4], 2: [4], 3: [4]}) sage: H.pseudocomplement(2) is None # needs sage.modules True - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(3)], Integer(2): [Integer(4)], Integer(3): [Integer(4)]}) >>> H.pseudocomplement(Integer(2)) # needs sage.modules 3 >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2), Integer(3)], Integer(1): [Integer(4)], Integer(2): [Integer(4)], Integer(3): [Integer(4)]}) >>> H.pseudocomplement(Integer(2)) is None # needs sage.modules True 
 - rank(element=None)[source]¶
- Return the rank of - element, or the rank of the poset if- elementis- None. (The rank of a poset is the length of the longest chain of elements of the poset.)- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,3,2],1:[4],2:[4,5,6],3:[6],4:[7],5:[7],6:[7],7:[]}) sage: H.rank(5) 2 sage: H.rank() 3 sage: Q = HasseDiagram({0:[1,2],1:[3],2:[],3:[]}) sage: Q.rank() 2 sage: Q.rank(1) 1 - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(3),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(4),Integer(5),Integer(6)],Integer(3):[Integer(6)],Integer(4):[Integer(7)],Integer(5):[Integer(7)],Integer(6):[Integer(7)],Integer(7):[]}) >>> H.rank(Integer(5)) 2 >>> H.rank() 3 >>> Q = HasseDiagram({Integer(0):[Integer(1),Integer(2)],Integer(1):[Integer(3)],Integer(2):[],Integer(3):[]}) >>> Q.rank() 2 >>> Q.rank(Integer(1)) 1 
 - rank_function()[source]¶
- Return the (normalized) rank function of the poset, if it exists. - A rank function of a poset \(P\) is a function \(r\) that maps elements of \(P\) to integers and satisfies: \(r(x) = r(y) + 1\) if \(x\) covers \(y\). The function \(r\) is normalized such that its minimum value on every connected component of the Hasse diagram of \(P\) is \(0\). This determines the function \(r\) uniquely (when it exists). - OUTPUT: - a lambda function, if the poset admits a rank function 
- None, if the poset does not admit a rank function
 - EXAMPLES: - sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]]) sage: P.rank_function() is not None True sage: P = Poset(([1,2,3,4],[[1,4],[2,3],[3,4]]), facade = True) sage: P.rank_function() is not None True sage: P = Poset(([1,2,3,4,5],[[1,2],[2,3],[3,4],[1,5],[5,4]]), facade = True) sage: P.rank_function() is not None False sage: P = Poset(([1,2,3,4,5,6,7,8],[[1,4],[2,3],[3,4],[5,7],[6,7]]), facade = True) sage: f = P.rank_function(); f is not None True sage: f(5) 0 sage: f(2) 0 - >>> from sage.all import * >>> P = Poset([[Integer(1),Integer(3),Integer(2)],[Integer(4)],[Integer(4),Integer(5),Integer(6)],[Integer(6)],[Integer(7)],[Integer(7)],[Integer(7)],[]]) >>> P.rank_function() is not None True >>> P = Poset(([Integer(1),Integer(2),Integer(3),Integer(4)],[[Integer(1),Integer(4)],[Integer(2),Integer(3)],[Integer(3),Integer(4)]]), facade = True) >>> P.rank_function() is not None True >>> P = Poset(([Integer(1),Integer(2),Integer(3),Integer(4),Integer(5)],[[Integer(1),Integer(2)],[Integer(2),Integer(3)],[Integer(3),Integer(4)],[Integer(1),Integer(5)],[Integer(5),Integer(4)]]), facade = True) >>> P.rank_function() is not None False >>> P = Poset(([Integer(1),Integer(2),Integer(3),Integer(4),Integer(5),Integer(6),Integer(7),Integer(8)],[[Integer(1),Integer(4)],[Integer(2),Integer(3)],[Integer(3),Integer(4)],[Integer(5),Integer(7)],[Integer(6),Integer(7)]]), facade = True) >>> f = P.rank_function(); f is not None True >>> f(Integer(5)) 0 >>> f(Integer(2)) 0 
 - skeleton()[source]¶
- Return the skeleton of the lattice. - The lattice is expected to be pseudocomplemented and non-empty. - The skeleton of the lattice is the subposet induced by those elements that are the pseudocomplement to at least one element. - OUTPUT: - List of elements such that the subposet induced by them is the skeleton of the lattice. - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 1: [3, 4], 2: [4], ....: 3: [5], 4: [5]}) sage: H.skeleton() # needs sage.modules [5, 2, 0, 3] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1): [Integer(3), Integer(4)], Integer(2): [Integer(4)], ... Integer(3): [Integer(5)], Integer(4): [Integer(5)]}) >>> H.skeleton() # needs sage.modules [5, 2, 0, 3] 
 - sublattices_iterator(elms, min_e)[source]¶
- Return an iterator over sublattices of the Hasse diagram. - INPUT: - elms– elements already in sublattice; use set() at start
- min_e– smallest new element to add for new sublattices
 - OUTPUT: list of sublattices as sets of integers - EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 1:[3], 2:[3]}) sage: it = H.sublattices_iterator(set(), 0); it <generator object ...sublattices_iterator at ...> sage: next(it) # needs sage.modules set() sage: next(it) # needs sage.modules {0} - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(1):[Integer(3)], Integer(2):[Integer(3)]}) >>> it = H.sublattices_iterator(set(), Integer(0)); it <generator object ...sublattices_iterator at ...> >>> next(it) # needs sage.modules set() >>> next(it) # needs sage.modules {0} 
 - supergreedy_linear_extensions_iterator()[source]¶
- Return an iterator over supergreedy linear extensions of the Hasse diagram. - A linear extension \([e_1, e_2, \ldots, e_n]\) is supergreedy if, for every \(i\) and \(j\) where \(i > j\), \(e_i\) covers \(e_j\) if for every \(i > k > j\) at least one lower cover of \(e_k\) is not in \([e_1, e_2, \ldots, e_k]\). - Informally said a linear extension is supergreedy if it “always goes as high possible, and withdraw so less as possible”. These are also called depth-first linear extensions. - EXAMPLES: - We show the difference between “only greedy” and supergreedy extensions: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0: [1, 2], 2: [3, 4]}) sage: G_ext = list(H.greedy_linear_extensions_iterator()) sage: SG_ext = list(H.supergreedy_linear_extensions_iterator()) sage: [0, 2, 3, 1, 4] in G_ext True sage: [0, 2, 3, 1, 4] in SG_ext False sage: len(SG_ext) 4 - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0): [Integer(1), Integer(2)], Integer(2): [Integer(3), Integer(4)]}) >>> G_ext = list(H.greedy_linear_extensions_iterator()) >>> SG_ext = list(H.supergreedy_linear_extensions_iterator()) >>> [Integer(0), Integer(2), Integer(3), Integer(1), Integer(4)] in G_ext True >>> [Integer(0), Integer(2), Integer(3), Integer(1), Integer(4)] in SG_ext False >>> len(SG_ext) 4 
 - top()[source]¶
- Return the top element of the poset, if it exists. - EXAMPLES: - sage: P = Poset({0:[3],1:[3],2:[3],3:[4,5],4:[],5:[]}) sage: P.top() is None True sage: Q = Poset({0:[1],1:[]}) sage: Q.top() 1 - >>> from sage.all import * >>> P = Poset({Integer(0):[Integer(3)],Integer(1):[Integer(3)],Integer(2):[Integer(3)],Integer(3):[Integer(4),Integer(5)],Integer(4):[],Integer(5):[]}) >>> P.top() is None True >>> Q = Poset({Integer(0):[Integer(1)],Integer(1):[]}) >>> Q.top() 1 
 - upper_covers_iterator(element)[source]¶
- Return the list of elements that cover - element.- EXAMPLES: - sage: from sage.combinat.posets.hasse_diagram import HasseDiagram sage: H = HasseDiagram({0:[1,3,2],1:[4],2:[4,5,6],3:[6],4:[7],5:[7],6:[7],7:[]}) sage: list(H.upper_covers_iterator(0)) [1, 2, 3] sage: list(H.upper_covers_iterator(7)) [] - >>> from sage.all import * >>> from sage.combinat.posets.hasse_diagram import HasseDiagram >>> H = HasseDiagram({Integer(0):[Integer(1),Integer(3),Integer(2)],Integer(1):[Integer(4)],Integer(2):[Integer(4),Integer(5),Integer(6)],Integer(3):[Integer(6)],Integer(4):[Integer(7)],Integer(5):[Integer(7)],Integer(6):[Integer(7)],Integer(7):[]}) >>> list(H.upper_covers_iterator(Integer(0))) [1, 2, 3] >>> list(H.upper_covers_iterator(Integer(7))) [] 
 - vertical_decomposition(return_list=False)[source]¶
- Return vertical decomposition of the lattice. - This is the backend function for vertical decomposition functions of lattices. - The property of being vertically decomposable is defined for lattices. This is not checked, and the function works with any bounded poset. - INPUT: - return_list– boolean (default:- False); if- False(the default), return an element that is not the top neither the bottom element of the lattice, but is comparable to all elements of the lattice, if the lattice is vertically decomposable and- Noneotherwise. If- True, return list of decomposition elements.
 - EXAMPLES: - sage: H = posets.BooleanLattice(4)._hasse_diagram sage: H.vertical_decomposition() is None True sage: P = Poset( ([1,2,3,6,12,18,36], attrcall("divides")) ) sage: P._hasse_diagram.vertical_decomposition() 3 sage: P._hasse_diagram.vertical_decomposition(return_list=True) [3] - >>> from sage.all import * >>> H = posets.BooleanLattice(Integer(4))._hasse_diagram >>> H.vertical_decomposition() is None True >>> P = Poset( ([Integer(1),Integer(2),Integer(3),Integer(6),Integer(12),Integer(18),Integer(36)], attrcall("divides")) ) >>> P._hasse_diagram.vertical_decomposition() 3 >>> P._hasse_diagram.vertical_decomposition(return_list=True) [3] 
 
- exception sage.combinat.posets.hasse_diagram.LatticeError(fail, x, y)[source]¶
- Bases: - ValueError- Helper exception class to forward elements without meet or join to upper level, so that the user will see “No meet for a and b” instead of “No meet for 1 and 2”.