passagemath-graphs 10.6.1rc1__cp310-cp310-musllinux_1_2_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passagemath_graphs-10.6.1rc1.dist-info/METADATA +292 -0
- passagemath_graphs-10.6.1rc1.dist-info/RECORD +260 -0
- passagemath_graphs-10.6.1rc1.dist-info/WHEEL +5 -0
- passagemath_graphs-10.6.1rc1.dist-info/top_level.txt +2 -0
- passagemath_graphs.libs/libgcc_s-69c45f16.so.1 +0 -0
- passagemath_graphs.libs/libgmp-8e78bd9b.so.10.5.0 +0 -0
- passagemath_graphs.libs/libstdc++-1f1a71be.so.6.0.33 +0 -0
- sage/all__sagemath_graphs.py +39 -0
- sage/combinat/abstract_tree.py +2723 -0
- sage/combinat/all__sagemath_graphs.py +34 -0
- sage/combinat/binary_tree.py +5306 -0
- sage/combinat/cluster_algebra_quiver/all.py +22 -0
- sage/combinat/cluster_algebra_quiver/cluster_seed.py +5208 -0
- sage/combinat/cluster_algebra_quiver/interact.py +124 -0
- sage/combinat/cluster_algebra_quiver/mutation_class.py +625 -0
- sage/combinat/cluster_algebra_quiver/mutation_type.py +1555 -0
- sage/combinat/cluster_algebra_quiver/quiver.py +2290 -0
- sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +2468 -0
- sage/combinat/designs/MOLS_handbook_data.py +570 -0
- sage/combinat/designs/all.py +58 -0
- sage/combinat/designs/bibd.py +1655 -0
- sage/combinat/designs/block_design.py +1071 -0
- sage/combinat/designs/covering_array.py +269 -0
- sage/combinat/designs/covering_design.py +530 -0
- sage/combinat/designs/database.py +5615 -0
- sage/combinat/designs/design_catalog.py +122 -0
- sage/combinat/designs/designs_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/designs_pyx.pxd +21 -0
- sage/combinat/designs/designs_pyx.pyx +993 -0
- sage/combinat/designs/difference_family.py +3951 -0
- sage/combinat/designs/difference_matrices.py +279 -0
- sage/combinat/designs/evenly_distributed_sets.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/evenly_distributed_sets.pyx +661 -0
- sage/combinat/designs/ext_rep.py +1064 -0
- sage/combinat/designs/gen_quadrangles_with_spread.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/gen_quadrangles_with_spread.pyx +339 -0
- sage/combinat/designs/group_divisible_designs.py +361 -0
- sage/combinat/designs/incidence_structures.py +2357 -0
- sage/combinat/designs/latin_squares.py +581 -0
- sage/combinat/designs/orthogonal_arrays.py +2244 -0
- sage/combinat/designs/orthogonal_arrays_build_recursive.py +1780 -0
- sage/combinat/designs/orthogonal_arrays_find_recursive.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +967 -0
- sage/combinat/designs/resolvable_bibd.py +815 -0
- sage/combinat/designs/steiner_quadruple_systems.py +1306 -0
- sage/combinat/designs/subhypergraph_search.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/subhypergraph_search.pyx +530 -0
- sage/combinat/designs/twographs.py +306 -0
- sage/combinat/finite_state_machine.py +14874 -0
- sage/combinat/finite_state_machine_generators.py +2006 -0
- sage/combinat/graph_path.py +448 -0
- sage/combinat/interval_posets.py +3908 -0
- sage/combinat/nu_tamari_lattice.py +269 -0
- sage/combinat/ordered_tree.py +1446 -0
- sage/combinat/posets/all.py +46 -0
- sage/combinat/posets/bubble_shuffle.py +247 -0
- sage/combinat/posets/cartesian_product.py +493 -0
- sage/combinat/posets/d_complete.py +182 -0
- sage/combinat/posets/elements.py +273 -0
- sage/combinat/posets/forest.py +30 -0
- sage/combinat/posets/hasse_cython.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/posets/hasse_cython.pyx +174 -0
- sage/combinat/posets/hasse_diagram.py +3672 -0
- sage/combinat/posets/hochschild_lattice.py +158 -0
- sage/combinat/posets/incidence_algebras.py +794 -0
- sage/combinat/posets/lattices.py +5117 -0
- sage/combinat/posets/linear_extension_iterator.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/posets/linear_extension_iterator.pyx +292 -0
- sage/combinat/posets/linear_extensions.py +1037 -0
- sage/combinat/posets/mobile.py +275 -0
- sage/combinat/posets/moebius_algebra.py +776 -0
- sage/combinat/posets/poset_examples.py +2178 -0
- sage/combinat/posets/posets.py +9360 -0
- sage/combinat/rooted_tree.py +1070 -0
- sage/combinat/shard_order.py +239 -0
- sage/combinat/tamari_lattices.py +384 -0
- sage/combinat/yang_baxter_graph.py +923 -0
- sage/databases/all__sagemath_graphs.py +1 -0
- sage/databases/knotinfo_db.py +1231 -0
- sage/ext_data/all__sagemath_graphs.py +1 -0
- sage/ext_data/graphs/graph_plot_js.html +330 -0
- sage/ext_data/kenzo/CP2.txt +45 -0
- sage/ext_data/kenzo/CP3.txt +349 -0
- sage/ext_data/kenzo/CP4.txt +4774 -0
- sage/ext_data/kenzo/README.txt +49 -0
- sage/ext_data/kenzo/S4.txt +20 -0
- sage/graphs/all.py +42 -0
- sage/graphs/asteroidal_triples.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/asteroidal_triples.pyx +320 -0
- sage/graphs/base/all.py +1 -0
- sage/graphs/base/boost_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/boost_graph.pxd +106 -0
- sage/graphs/base/boost_graph.pyx +3045 -0
- sage/graphs/base/c_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/c_graph.pxd +106 -0
- sage/graphs/base/c_graph.pyx +5096 -0
- sage/graphs/base/dense_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/dense_graph.pxd +28 -0
- sage/graphs/base/dense_graph.pyx +801 -0
- sage/graphs/base/graph_backends.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/graph_backends.pxd +5 -0
- sage/graphs/base/graph_backends.pyx +797 -0
- sage/graphs/base/overview.py +85 -0
- sage/graphs/base/sparse_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/sparse_graph.pxd +90 -0
- sage/graphs/base/sparse_graph.pyx +1653 -0
- sage/graphs/base/static_dense_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/static_dense_graph.pxd +5 -0
- sage/graphs/base/static_dense_graph.pyx +1032 -0
- sage/graphs/base/static_sparse_backend.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/static_sparse_backend.pxd +27 -0
- sage/graphs/base/static_sparse_backend.pyx +1583 -0
- sage/graphs/base/static_sparse_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/static_sparse_graph.pxd +37 -0
- sage/graphs/base/static_sparse_graph.pyx +1375 -0
- sage/graphs/bipartite_graph.py +2732 -0
- sage/graphs/centrality.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/centrality.pyx +1038 -0
- sage/graphs/cographs.py +519 -0
- sage/graphs/comparability.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/comparability.pyx +851 -0
- sage/graphs/connectivity.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/connectivity.pxd +157 -0
- sage/graphs/connectivity.pyx +4813 -0
- sage/graphs/convexity_properties.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/convexity_properties.pxd +16 -0
- sage/graphs/convexity_properties.pyx +870 -0
- sage/graphs/digraph.py +4754 -0
- sage/graphs/digraph_generators.py +1993 -0
- sage/graphs/distances_all_pairs.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/distances_all_pairs.pxd +12 -0
- sage/graphs/distances_all_pairs.pyx +2938 -0
- sage/graphs/domination.py +1363 -0
- sage/graphs/dot2tex_utils.py +100 -0
- sage/graphs/edge_connectivity.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/edge_connectivity.pyx +1215 -0
- sage/graphs/generators/all.py +1 -0
- sage/graphs/generators/basic.py +1769 -0
- sage/graphs/generators/chessboard.py +538 -0
- sage/graphs/generators/classical_geometries.py +1611 -0
- sage/graphs/generators/degree_sequence.py +235 -0
- sage/graphs/generators/distance_regular.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/generators/distance_regular.pyx +2846 -0
- sage/graphs/generators/families.py +4759 -0
- sage/graphs/generators/intersection.py +565 -0
- sage/graphs/generators/platonic_solids.py +262 -0
- sage/graphs/generators/random.py +2623 -0
- sage/graphs/generators/smallgraphs.py +5741 -0
- sage/graphs/generators/world_map.py +724 -0
- sage/graphs/generic_graph.py +26867 -0
- sage/graphs/generic_graph_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/generic_graph_pyx.pxd +34 -0
- sage/graphs/generic_graph_pyx.pyx +1673 -0
- sage/graphs/genus.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/genus.pyx +622 -0
- sage/graphs/graph.py +9645 -0
- sage/graphs/graph_coloring.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_coloring.pyx +2284 -0
- sage/graphs/graph_database.py +1177 -0
- sage/graphs/graph_decompositions/all.py +1 -0
- sage/graphs/graph_decompositions/bandwidth.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/bandwidth.pyx +428 -0
- sage/graphs/graph_decompositions/clique_separators.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/clique_separators.pyx +616 -0
- sage/graphs/graph_decompositions/cutwidth.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/cutwidth.pyx +753 -0
- sage/graphs/graph_decompositions/fast_digraph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/fast_digraph.pxd +13 -0
- sage/graphs/graph_decompositions/fast_digraph.pyx +212 -0
- sage/graphs/graph_decompositions/graph_products.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/graph_products.pyx +508 -0
- sage/graphs/graph_decompositions/modular_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/modular_decomposition.pxd +27 -0
- sage/graphs/graph_decompositions/modular_decomposition.pyx +1536 -0
- sage/graphs/graph_decompositions/slice_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/slice_decomposition.pxd +18 -0
- sage/graphs/graph_decompositions/slice_decomposition.pyx +1106 -0
- sage/graphs/graph_decompositions/tree_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/tree_decomposition.pxd +17 -0
- sage/graphs/graph_decompositions/tree_decomposition.pyx +1996 -0
- sage/graphs/graph_decompositions/vertex_separation.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/vertex_separation.pxd +5 -0
- sage/graphs/graph_decompositions/vertex_separation.pyx +1963 -0
- sage/graphs/graph_editor.py +82 -0
- sage/graphs/graph_generators.py +3314 -0
- sage/graphs/graph_generators_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_generators_pyx.pyx +95 -0
- sage/graphs/graph_input.py +812 -0
- sage/graphs/graph_latex.py +2064 -0
- sage/graphs/graph_list.py +410 -0
- sage/graphs/graph_plot.py +1756 -0
- sage/graphs/graph_plot_js.py +338 -0
- sage/graphs/hyperbolicity.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/hyperbolicity.pyx +1704 -0
- sage/graphs/hypergraph_generators.py +364 -0
- sage/graphs/independent_sets.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/independent_sets.pxd +13 -0
- sage/graphs/independent_sets.pyx +402 -0
- sage/graphs/isgci.py +1033 -0
- sage/graphs/isoperimetric_inequalities.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/isoperimetric_inequalities.pyx +489 -0
- sage/graphs/line_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/line_graph.pyx +743 -0
- sage/graphs/lovasz_theta.py +77 -0
- sage/graphs/matching.py +1633 -0
- sage/graphs/matching_covered_graph.py +3590 -0
- sage/graphs/orientations.py +1489 -0
- sage/graphs/partial_cube.py +459 -0
- sage/graphs/path_enumeration.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/path_enumeration.pyx +2040 -0
- sage/graphs/pq_trees.py +1129 -0
- sage/graphs/print_graphs.py +201 -0
- sage/graphs/schnyder.py +865 -0
- sage/graphs/spanning_tree.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/spanning_tree.pyx +1457 -0
- sage/graphs/strongly_regular_db.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/strongly_regular_db.pyx +3340 -0
- sage/graphs/traversals.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/traversals.pxd +9 -0
- sage/graphs/traversals.pyx +1872 -0
- sage/graphs/trees.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/trees.pxd +15 -0
- sage/graphs/trees.pyx +310 -0
- sage/graphs/tutte_polynomial.py +713 -0
- sage/graphs/views.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/views.pyx +794 -0
- sage/graphs/weakly_chordal.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/weakly_chordal.pyx +604 -0
- sage/groups/all__sagemath_graphs.py +1 -0
- sage/groups/perm_gps/all__sagemath_graphs.py +1 -0
- sage/groups/perm_gps/partn_ref/all__sagemath_graphs.py +1 -0
- sage/groups/perm_gps/partn_ref/refinement_graphs.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/groups/perm_gps/partn_ref/refinement_graphs.pxd +38 -0
- sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +1666 -0
- sage/knots/all.py +6 -0
- sage/knots/free_knotinfo_monoid.py +507 -0
- sage/knots/gauss_code.py +291 -0
- sage/knots/knot.py +682 -0
- sage/knots/knot_table.py +284 -0
- sage/knots/knotinfo.py +2900 -0
- sage/knots/link.py +4715 -0
- sage/sandpiles/all.py +13 -0
- sage/sandpiles/examples.py +225 -0
- sage/sandpiles/sandpile.py +6365 -0
- sage/topology/all.py +22 -0
- sage/topology/cell_complex.py +1214 -0
- sage/topology/cubical_complex.py +1976 -0
- sage/topology/delta_complex.py +1806 -0
- sage/topology/filtered_simplicial_complex.py +744 -0
- sage/topology/moment_angle_complex.py +823 -0
- sage/topology/simplicial_complex.py +5160 -0
- sage/topology/simplicial_complex_catalog.py +92 -0
- sage/topology/simplicial_complex_examples.py +1680 -0
- sage/topology/simplicial_complex_homset.py +205 -0
- sage/topology/simplicial_complex_morphism.py +836 -0
- sage/topology/simplicial_set.py +4102 -0
- sage/topology/simplicial_set_catalog.py +55 -0
- sage/topology/simplicial_set_constructions.py +2954 -0
- sage/topology/simplicial_set_examples.py +865 -0
- sage/topology/simplicial_set_morphism.py +1464 -0
@@ -0,0 +1,794 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-graphs
|
2
|
+
# sage.doctest: needs sage.modules
|
3
|
+
r"""
|
4
|
+
Incidence algebras
|
5
|
+
"""
|
6
|
+
# ****************************************************************************
|
7
|
+
# Copyright (C) 2014 Travis Scrimshaw <tscrim at ucdavis.edu>
|
8
|
+
#
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 2 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
# https://www.gnu.org/licenses/
|
14
|
+
# ****************************************************************************
|
15
|
+
from copy import copy
|
16
|
+
from typing import Any
|
17
|
+
|
18
|
+
from sage.misc.cachefunc import cached_method
|
19
|
+
from sage.misc.lazy_attribute import lazy_attribute
|
20
|
+
from sage.categories.algebras import Algebras
|
21
|
+
from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
|
22
|
+
from sage.combinat.free_module import CombinatorialFreeModule
|
23
|
+
from sage.matrix.matrix_space import MatrixSpace
|
24
|
+
|
25
|
+
|
26
|
+
class IncidenceAlgebra(CombinatorialFreeModule):
|
27
|
+
r"""
|
28
|
+
The incidence algebra of a poset.
|
29
|
+
|
30
|
+
Let `P` be a poset and `R` be a commutative unital associative ring.
|
31
|
+
The *incidence algebra* `I_P` is the algebra of functions
|
32
|
+
`\alpha \colon P \times P \to R` such that `\alpha(x, y) = 0`
|
33
|
+
if `x \not\leq y` where multiplication is given by convolution:
|
34
|
+
|
35
|
+
.. MATH::
|
36
|
+
|
37
|
+
(\alpha \ast \beta)(x, y) = \sum_{x \leq k \leq y}
|
38
|
+
\alpha(x, k) \beta(k, y).
|
39
|
+
|
40
|
+
This has a natural basis given by indicator functions for the
|
41
|
+
interval `[a, b]`, i.e. `X_{a,b}(x,y) = \delta_{ax} \delta_{by}`.
|
42
|
+
The incidence algebra is a unital algebra with the identity given
|
43
|
+
by the Kronecker delta `\delta(x, y) = \delta_{xy}`. The Möbius
|
44
|
+
function of `P` is another element of `I_p` whose inverse is the
|
45
|
+
`\zeta` function of the poset (so `\zeta(x, y) = 1` for
|
46
|
+
every interval `[x, y]`).
|
47
|
+
|
48
|
+
.. TODO::
|
49
|
+
|
50
|
+
Implement the incidence coalgebra.
|
51
|
+
|
52
|
+
REFERENCES:
|
53
|
+
|
54
|
+
- :wikipedia:`Incidence_algebra`
|
55
|
+
"""
|
56
|
+
def __init__(self, R, P, prefix='I') -> None:
|
57
|
+
"""
|
58
|
+
Initialize ``self``.
|
59
|
+
|
60
|
+
TESTS::
|
61
|
+
|
62
|
+
sage: P = posets.BooleanLattice(3)
|
63
|
+
sage: I = P.incidence_algebra(QQ)
|
64
|
+
sage: TestSuite(I).run() # long time
|
65
|
+
"""
|
66
|
+
cat = Algebras(R).WithBasis()
|
67
|
+
if P in FiniteEnumeratedSets():
|
68
|
+
cat = cat.FiniteDimensional()
|
69
|
+
self._poset = P
|
70
|
+
CombinatorialFreeModule.__init__(self, R, map(tuple, P.relations()),
|
71
|
+
prefix=prefix, category=cat)
|
72
|
+
|
73
|
+
def _repr_term(self, A) -> str:
|
74
|
+
"""
|
75
|
+
Return a string representation of the term labeled by ``A``.
|
76
|
+
|
77
|
+
EXAMPLES::
|
78
|
+
|
79
|
+
sage: P = posets.BooleanLattice(4)
|
80
|
+
sage: I = P.incidence_algebra(QQ)
|
81
|
+
sage: I._repr_term((4, 12))
|
82
|
+
'I[4, 12]'
|
83
|
+
"""
|
84
|
+
return self.prefix() + str(list(A))
|
85
|
+
|
86
|
+
def _repr_(self) -> str:
|
87
|
+
r"""
|
88
|
+
Return a string representation of ``self``.
|
89
|
+
|
90
|
+
EXAMPLES::
|
91
|
+
|
92
|
+
sage: P = posets.BooleanLattice(4)
|
93
|
+
sage: P.incidence_algebra(QQ)
|
94
|
+
Incidence algebra of Finite lattice containing 16 elements
|
95
|
+
over Rational Field
|
96
|
+
"""
|
97
|
+
return f"Incidence algebra of {self._poset} over {self.base_ring()}"
|
98
|
+
|
99
|
+
def _coerce_map_from_(self, R):
|
100
|
+
"""
|
101
|
+
Return the coerce map from ``R`` into ``self`` if it exists
|
102
|
+
or ``False`` otherwise.
|
103
|
+
|
104
|
+
EXAMPLES::
|
105
|
+
|
106
|
+
sage: P = posets.BooleanLattice(4)
|
107
|
+
sage: I = P.incidence_algebra(QQ)
|
108
|
+
sage: R = I.reduced_subalgebra()
|
109
|
+
sage: I.has_coerce_map_from(R)
|
110
|
+
True
|
111
|
+
sage: I.has_coerce_map_from(QQ)
|
112
|
+
True
|
113
|
+
sage: Pp = posets.BooleanLattice(3)
|
114
|
+
sage: Rp = Pp.incidence_algebra(QQ).reduced_subalgebra()
|
115
|
+
sage: I.has_coerce_map_from(Rp)
|
116
|
+
False
|
117
|
+
"""
|
118
|
+
if isinstance(R, ReducedIncidenceAlgebra) and R._ambient is self:
|
119
|
+
return copy(R.lift)
|
120
|
+
return super()._coerce_map_from_(R)
|
121
|
+
|
122
|
+
def reduced_subalgebra(self, prefix='R'):
|
123
|
+
"""
|
124
|
+
Return the reduced incidence subalgebra.
|
125
|
+
|
126
|
+
EXAMPLES::
|
127
|
+
|
128
|
+
sage: P = posets.BooleanLattice(4)
|
129
|
+
sage: I = P.incidence_algebra(QQ)
|
130
|
+
sage: I.reduced_subalgebra()
|
131
|
+
Reduced incidence algebra of Finite lattice containing 16 elements
|
132
|
+
over Rational Field
|
133
|
+
"""
|
134
|
+
return ReducedIncidenceAlgebra(self, prefix)
|
135
|
+
|
136
|
+
def poset(self):
|
137
|
+
"""
|
138
|
+
Return the defining poset of ``self``.
|
139
|
+
|
140
|
+
EXAMPLES::
|
141
|
+
|
142
|
+
sage: P = posets.BooleanLattice(4)
|
143
|
+
sage: I = P.incidence_algebra(QQ)
|
144
|
+
sage: I.poset()
|
145
|
+
Finite lattice containing 16 elements
|
146
|
+
sage: I.poset() == P
|
147
|
+
True
|
148
|
+
"""
|
149
|
+
return self._poset
|
150
|
+
|
151
|
+
def some_elements(self) -> list:
|
152
|
+
"""
|
153
|
+
Return a list of elements of ``self``.
|
154
|
+
|
155
|
+
EXAMPLES::
|
156
|
+
|
157
|
+
sage: P = posets.BooleanLattice(1)
|
158
|
+
sage: I = P.incidence_algebra(QQ)
|
159
|
+
sage: Ielts = I.some_elements(); Ielts # random
|
160
|
+
[2*I[0, 0] + 2*I[0, 1] + 3*I[1, 1],
|
161
|
+
I[0, 0] - I[0, 1] + I[1, 1],
|
162
|
+
I[0, 0] + I[0, 1] + I[1, 1]]
|
163
|
+
sage: [a in I for a in Ielts]
|
164
|
+
[True, True, True]
|
165
|
+
"""
|
166
|
+
return [self.an_element(), self.moebius(), self.zeta()]
|
167
|
+
|
168
|
+
def product_on_basis(self, A, B):
|
169
|
+
r"""
|
170
|
+
Return the product of basis elements indexed by ``A`` and ``B``.
|
171
|
+
|
172
|
+
EXAMPLES::
|
173
|
+
|
174
|
+
sage: P = posets.BooleanLattice(4)
|
175
|
+
sage: I = P.incidence_algebra(QQ)
|
176
|
+
sage: I.product_on_basis((1, 3), (3, 11))
|
177
|
+
I[1, 11]
|
178
|
+
sage: I.product_on_basis((1, 3), (2, 2))
|
179
|
+
0
|
180
|
+
"""
|
181
|
+
if A[1] == B[0]:
|
182
|
+
return self.monomial((A[0], B[1]))
|
183
|
+
return self.zero()
|
184
|
+
|
185
|
+
@cached_method
|
186
|
+
def one(self):
|
187
|
+
r"""
|
188
|
+
Return the element `1` in ``self`` (which is the Kronecker
|
189
|
+
delta `\delta(x, y)`).
|
190
|
+
|
191
|
+
EXAMPLES::
|
192
|
+
|
193
|
+
sage: P = posets.BooleanLattice(4)
|
194
|
+
sage: I = P.incidence_algebra(QQ)
|
195
|
+
sage: I.one()
|
196
|
+
I[0, 0] + I[1, 1] + I[2, 2] + I[3, 3] + I[4, 4] + I[5, 5]
|
197
|
+
+ I[6, 6] + I[7, 7] + I[8, 8] + I[9, 9] + I[10, 10]
|
198
|
+
+ I[11, 11] + I[12, 12] + I[13, 13] + I[14, 14] + I[15, 15]
|
199
|
+
"""
|
200
|
+
return self.sum_of_monomials((x, x) for x in self._poset)
|
201
|
+
|
202
|
+
delta = one
|
203
|
+
|
204
|
+
@cached_method
|
205
|
+
def zeta(self):
|
206
|
+
r"""
|
207
|
+
Return the `\zeta` function in ``self``.
|
208
|
+
|
209
|
+
The `\zeta` function on a poset `P` is given by
|
210
|
+
|
211
|
+
.. MATH::
|
212
|
+
|
213
|
+
\zeta(x, y) = \begin{cases}
|
214
|
+
1 & x \leq y, \\
|
215
|
+
0 & x \not\leq y.
|
216
|
+
\end{cases}
|
217
|
+
|
218
|
+
EXAMPLES::
|
219
|
+
|
220
|
+
sage: P = posets.BooleanLattice(4)
|
221
|
+
sage: I = P.incidence_algebra(QQ)
|
222
|
+
sage: I.zeta() * I.moebius() == I.one()
|
223
|
+
True
|
224
|
+
"""
|
225
|
+
return self.sum(self.basis())
|
226
|
+
|
227
|
+
@cached_method
|
228
|
+
def moebius(self):
|
229
|
+
"""
|
230
|
+
Return the Möbius function of ``self``.
|
231
|
+
|
232
|
+
EXAMPLES::
|
233
|
+
|
234
|
+
sage: P = posets.BooleanLattice(2)
|
235
|
+
sage: I = P.incidence_algebra(QQ)
|
236
|
+
sage: I.moebius()
|
237
|
+
I[0, 0] - I[0, 1] - I[0, 2] + I[0, 3] + I[1, 1]
|
238
|
+
- I[1, 3] + I[2, 2] - I[2, 3] + I[3, 3]
|
239
|
+
"""
|
240
|
+
mu = self._poset.moebius_function
|
241
|
+
R = self.base_ring()
|
242
|
+
return self.sum_of_terms((A, R(mu(*A))) for A in self.basis().keys())
|
243
|
+
|
244
|
+
def __getitem__(self, A):
|
245
|
+
"""
|
246
|
+
Return the basis element indexed by ``A``.
|
247
|
+
|
248
|
+
EXAMPLES::
|
249
|
+
|
250
|
+
sage: P = posets.BooleanLattice(4)
|
251
|
+
sage: I = P.incidence_algebra(QQ)
|
252
|
+
sage: I[2, 6]
|
253
|
+
I[2, 6]
|
254
|
+
sage: I[(2, 6)]
|
255
|
+
I[2, 6]
|
256
|
+
sage: I[[2, 6]]
|
257
|
+
I[2, 6]
|
258
|
+
sage: I[2]
|
259
|
+
I[2, 2]
|
260
|
+
|
261
|
+
sage: I[2, 5]
|
262
|
+
Traceback (most recent call last):
|
263
|
+
...
|
264
|
+
ValueError: not an interval
|
265
|
+
|
266
|
+
sage: I[-1]
|
267
|
+
Traceback (most recent call last):
|
268
|
+
...
|
269
|
+
ValueError: not an element of the poset
|
270
|
+
"""
|
271
|
+
if not isinstance(A, (list, tuple)):
|
272
|
+
if A not in self._poset.list():
|
273
|
+
raise ValueError("not an element of the poset")
|
274
|
+
A = (A, A)
|
275
|
+
else:
|
276
|
+
A = tuple(A)
|
277
|
+
if len(A) != 2 or A not in self.basis().keys():
|
278
|
+
raise ValueError("not an interval")
|
279
|
+
return self.monomial(A)
|
280
|
+
|
281
|
+
@lazy_attribute
|
282
|
+
def _linear_extension(self) -> tuple:
|
283
|
+
"""
|
284
|
+
Return a fixed linear extension of the defining poset of ``self``.
|
285
|
+
|
286
|
+
EXAMPLES::
|
287
|
+
|
288
|
+
sage: P = posets.BooleanLattice(4)
|
289
|
+
sage: I = P.incidence_algebra(QQ)
|
290
|
+
sage: I._linear_extension
|
291
|
+
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
|
292
|
+
"""
|
293
|
+
return tuple(self._poset.linear_extension())
|
294
|
+
|
295
|
+
class Element(CombinatorialFreeModule.Element):
|
296
|
+
"""
|
297
|
+
An element of an incidence algebra.
|
298
|
+
"""
|
299
|
+
def __call__(self, x, y):
|
300
|
+
"""
|
301
|
+
Return ``self(x, y)``.
|
302
|
+
|
303
|
+
EXAMPLES::
|
304
|
+
|
305
|
+
sage: P = posets.BooleanLattice(4)
|
306
|
+
sage: I = P.incidence_algebra(QQ)
|
307
|
+
sage: mu = I.moebius()
|
308
|
+
sage: mu(0, 12)
|
309
|
+
1
|
310
|
+
sage: mu(0, 7)
|
311
|
+
-1
|
312
|
+
sage: mu(15, 0)
|
313
|
+
0
|
314
|
+
"""
|
315
|
+
P = self.parent()._poset
|
316
|
+
x = P(x)
|
317
|
+
y = P(y)
|
318
|
+
return self[x, y]
|
319
|
+
|
320
|
+
@cached_method
|
321
|
+
def to_matrix(self):
|
322
|
+
r"""
|
323
|
+
Return ``self`` as a matrix.
|
324
|
+
|
325
|
+
We define a matrix `M_{xy} = \alpha(x, y)` for some element
|
326
|
+
`\alpha \in I_P` in the incidence algebra `I_P` and we order
|
327
|
+
the elements `x,y \in P` by some linear extension of `P`. This
|
328
|
+
defines an algebra (iso)morphism; in particular, multiplication
|
329
|
+
in the incidence algebra goes to matrix multiplication.
|
330
|
+
|
331
|
+
EXAMPLES::
|
332
|
+
|
333
|
+
sage: P = posets.BooleanLattice(2)
|
334
|
+
sage: I = P.incidence_algebra(QQ)
|
335
|
+
sage: I.moebius().to_matrix()
|
336
|
+
[ 1 -1 -1 1]
|
337
|
+
[ 0 1 0 -1]
|
338
|
+
[ 0 0 1 -1]
|
339
|
+
[ 0 0 0 1]
|
340
|
+
sage: I.zeta().to_matrix()
|
341
|
+
[1 1 1 1]
|
342
|
+
[0 1 0 1]
|
343
|
+
[0 0 1 1]
|
344
|
+
[0 0 0 1]
|
345
|
+
|
346
|
+
TESTS:
|
347
|
+
|
348
|
+
We check that this is an algebra (iso)morphism::
|
349
|
+
|
350
|
+
sage: P = posets.BooleanLattice(4)
|
351
|
+
sage: I = P.incidence_algebra(QQ)
|
352
|
+
sage: mu = I.moebius()
|
353
|
+
sage: (mu*mu).to_matrix() == mu.to_matrix() * mu.to_matrix()
|
354
|
+
True
|
355
|
+
"""
|
356
|
+
P = self.parent()
|
357
|
+
MS = MatrixSpace(P.base_ring(), P._poset.cardinality(), sparse=True)
|
358
|
+
L = P._linear_extension
|
359
|
+
M = copy(MS.zero())
|
360
|
+
for i, c in self:
|
361
|
+
M[L.index(i[0]), L.index(i[1])] = c
|
362
|
+
M.set_immutable()
|
363
|
+
return M
|
364
|
+
|
365
|
+
def is_unit(self) -> bool:
|
366
|
+
"""
|
367
|
+
Return if ``self`` is a unit.
|
368
|
+
|
369
|
+
EXAMPLES::
|
370
|
+
|
371
|
+
sage: P = posets.BooleanLattice(2)
|
372
|
+
sage: I = P.incidence_algebra(QQ)
|
373
|
+
sage: mu = I.moebius()
|
374
|
+
sage: mu.is_unit()
|
375
|
+
True
|
376
|
+
sage: zeta = I.zeta()
|
377
|
+
sage: zeta.is_unit()
|
378
|
+
True
|
379
|
+
sage: x = mu - I.zeta() + I[2,2]
|
380
|
+
sage: x.is_unit()
|
381
|
+
False
|
382
|
+
sage: y = I.moebius() + I.zeta()
|
383
|
+
sage: y.is_unit()
|
384
|
+
True
|
385
|
+
|
386
|
+
This depends on the base ring::
|
387
|
+
|
388
|
+
sage: I = P.incidence_algebra(ZZ)
|
389
|
+
sage: y = I.moebius() + I.zeta()
|
390
|
+
sage: y.is_unit()
|
391
|
+
False
|
392
|
+
"""
|
393
|
+
return all(self[x, x].is_unit() for x in self.parent()._poset)
|
394
|
+
|
395
|
+
def __invert__(self):
|
396
|
+
"""
|
397
|
+
Return the inverse of ``self`` if it exists.
|
398
|
+
|
399
|
+
EXAMPLES::
|
400
|
+
|
401
|
+
sage: P = posets.BooleanLattice(2)
|
402
|
+
sage: I = P.incidence_algebra(QQ)
|
403
|
+
sage: mu = I.moebius()
|
404
|
+
sage: ~mu
|
405
|
+
I[0, 0] + I[0, 1] + I[0, 2] + I[0, 3] + I[1, 1]
|
406
|
+
+ I[1, 3] + I[2, 2] + I[2, 3] + I[3, 3]
|
407
|
+
sage: x = mu - I.zeta() + I[2,2]
|
408
|
+
sage: ~x
|
409
|
+
Traceback (most recent call last):
|
410
|
+
...
|
411
|
+
ValueError: element is not invertible
|
412
|
+
|
413
|
+
TESTS::
|
414
|
+
|
415
|
+
sage: P = posets.BooleanLattice(4)
|
416
|
+
sage: I = P.incidence_algebra(QQ)
|
417
|
+
sage: mu = I.moebius()
|
418
|
+
sage: ~mu == I.zeta()
|
419
|
+
True
|
420
|
+
sage: ~I.one() == I.one()
|
421
|
+
True
|
422
|
+
"""
|
423
|
+
M = self.to_matrix()
|
424
|
+
if not M.is_invertible():
|
425
|
+
raise ValueError("element is not invertible")
|
426
|
+
inv = ~M
|
427
|
+
L = self.parent()._linear_extension
|
428
|
+
return self.parent().sum_of_terms(
|
429
|
+
((L[i], L[j]), inv[i, j])
|
430
|
+
for i, j in inv.nonzero_positions(copy=False))
|
431
|
+
|
432
|
+
|
433
|
+
class ReducedIncidenceAlgebra(CombinatorialFreeModule):
|
434
|
+
r"""
|
435
|
+
The reduced incidence algebra of a poset.
|
436
|
+
|
437
|
+
The reduced incidence algebra `R_P` is a subalgebra of the
|
438
|
+
incidence algebra `I_P` where `\alpha(x, y) = \alpha(x', y')` when
|
439
|
+
`[x, y]` is isomorphic to `[x', y']` as posets. Thus the delta, Möbius,
|
440
|
+
and zeta functions are all elements of `R_P`.
|
441
|
+
"""
|
442
|
+
def __init__(self, I, prefix='R') -> None:
|
443
|
+
"""
|
444
|
+
Initialize ``self``.
|
445
|
+
|
446
|
+
TESTS::
|
447
|
+
|
448
|
+
sage: P = posets.BooleanLattice(3)
|
449
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
450
|
+
sage: TestSuite(R).run() # long time
|
451
|
+
"""
|
452
|
+
self._ambient = I
|
453
|
+
EC: dict[Any, list] = {}
|
454
|
+
P = self._ambient._poset
|
455
|
+
if not P.is_finite():
|
456
|
+
raise NotImplementedError("only implemented for finite posets")
|
457
|
+
for i in self._ambient.basis().keys():
|
458
|
+
S = P.subposet(P.interval(*i))
|
459
|
+
added = False
|
460
|
+
for k, ECk in EC.items():
|
461
|
+
if S._hasse_diagram.is_isomorphic(k._hasse_diagram):
|
462
|
+
ECk.append(i)
|
463
|
+
added = True
|
464
|
+
break
|
465
|
+
if not added:
|
466
|
+
EC[S] = [i]
|
467
|
+
equiv_classes = map(sorted, EC.values())
|
468
|
+
self._equiv_classes = {cls[0]: cls for cls in equiv_classes}
|
469
|
+
cat = Algebras(I.base_ring()).FiniteDimensional().WithBasis()
|
470
|
+
CombinatorialFreeModule.__init__(self, I.base_ring(),
|
471
|
+
sorted(self._equiv_classes.keys()),
|
472
|
+
prefix=prefix, category=cat)
|
473
|
+
|
474
|
+
def _repr_(self) -> str:
|
475
|
+
r"""
|
476
|
+
Return a string representation of ``self``.
|
477
|
+
|
478
|
+
EXAMPLES::
|
479
|
+
|
480
|
+
sage: P = posets.BooleanLattice(4)
|
481
|
+
sage: P.incidence_algebra(QQ).reduced_subalgebra()
|
482
|
+
Reduced incidence algebra of Finite lattice containing 16 elements
|
483
|
+
over Rational Field
|
484
|
+
"""
|
485
|
+
msg = "Reduced incidence algebra of {} over {}"
|
486
|
+
return msg.format(self._ambient._poset, self.base_ring())
|
487
|
+
|
488
|
+
def poset(self):
|
489
|
+
"""
|
490
|
+
Return the defining poset of ``self``.
|
491
|
+
|
492
|
+
EXAMPLES::
|
493
|
+
|
494
|
+
sage: P = posets.BooleanLattice(4)
|
495
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
496
|
+
sage: R.poset()
|
497
|
+
Finite lattice containing 16 elements
|
498
|
+
sage: R.poset() == P
|
499
|
+
True
|
500
|
+
"""
|
501
|
+
return self._ambient._poset
|
502
|
+
|
503
|
+
def some_elements(self) -> list:
|
504
|
+
"""
|
505
|
+
Return a list of elements of ``self``.
|
506
|
+
|
507
|
+
EXAMPLES::
|
508
|
+
|
509
|
+
sage: P = posets.BooleanLattice(4)
|
510
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
511
|
+
sage: R.some_elements()
|
512
|
+
[2*R[(0, 0)] + 2*R[(0, 1)] + 3*R[(0, 3)],
|
513
|
+
R[(0, 0)] - R[(0, 1)] + R[(0, 3)] - R[(0, 7)] + R[(0, 15)],
|
514
|
+
R[(0, 0)] + R[(0, 1)] + R[(0, 3)] + R[(0, 7)] + R[(0, 15)]]
|
515
|
+
"""
|
516
|
+
return [self.an_element(), self.moebius(), self.zeta()]
|
517
|
+
|
518
|
+
@cached_method
|
519
|
+
def one_basis(self):
|
520
|
+
"""
|
521
|
+
Return the index of the element `1` in ``self``.
|
522
|
+
|
523
|
+
EXAMPLES::
|
524
|
+
|
525
|
+
sage: P = posets.BooleanLattice(4)
|
526
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
527
|
+
sage: R.one_basis()
|
528
|
+
(0, 0)
|
529
|
+
"""
|
530
|
+
return next(A for A in self.basis().keys() if A[0] == A[1])
|
531
|
+
|
532
|
+
def delta(self):
|
533
|
+
"""
|
534
|
+
Return the Kronecker delta function in ``self``.
|
535
|
+
|
536
|
+
EXAMPLES::
|
537
|
+
|
538
|
+
sage: P = posets.BooleanLattice(4)
|
539
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
540
|
+
sage: R.delta()
|
541
|
+
R[(0, 0)]
|
542
|
+
"""
|
543
|
+
return self.one()
|
544
|
+
|
545
|
+
@cached_method
|
546
|
+
def zeta(self):
|
547
|
+
r"""
|
548
|
+
Return the `\zeta` function in ``self``.
|
549
|
+
|
550
|
+
The `\zeta` function on a poset `P` is given by
|
551
|
+
|
552
|
+
.. MATH::
|
553
|
+
|
554
|
+
\zeta(x, y) = \begin{cases}
|
555
|
+
1 & x \leq y, \\
|
556
|
+
0 & x \not\leq y.
|
557
|
+
\end{cases}
|
558
|
+
|
559
|
+
EXAMPLES::
|
560
|
+
|
561
|
+
sage: P = posets.BooleanLattice(4)
|
562
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
563
|
+
sage: R.zeta()
|
564
|
+
R[(0, 0)] + R[(0, 1)] + R[(0, 3)] + R[(0, 7)] + R[(0, 15)]
|
565
|
+
"""
|
566
|
+
return self.sum(self.basis())
|
567
|
+
|
568
|
+
@cached_method
|
569
|
+
def moebius(self):
|
570
|
+
"""
|
571
|
+
Return the Möbius function of ``self``.
|
572
|
+
|
573
|
+
EXAMPLES::
|
574
|
+
|
575
|
+
sage: P = posets.BooleanLattice(4)
|
576
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
577
|
+
sage: R.moebius()
|
578
|
+
R[(0, 0)] - R[(0, 1)] + R[(0, 3)] - R[(0, 7)] + R[(0, 15)]
|
579
|
+
"""
|
580
|
+
mu = self._ambient._poset.moebius_function
|
581
|
+
R = self.base_ring()
|
582
|
+
return self.sum_of_terms((A, R(mu(*A))) for A in self.basis().keys())
|
583
|
+
|
584
|
+
@cached_method
|
585
|
+
def _lift_basis(self, x):
|
586
|
+
"""
|
587
|
+
Lift the basis element indexed by ``x`` to the ambient incidence
|
588
|
+
algebra of ``self``.
|
589
|
+
|
590
|
+
EXAMPLES::
|
591
|
+
|
592
|
+
sage: P = posets.BooleanLattice(4)
|
593
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
594
|
+
sage: R._lift_basis((0, 7))
|
595
|
+
I[0, 7] + I[0, 11] + I[0, 13] + I[0, 14] + I[1, 15]
|
596
|
+
+ I[2, 15] + I[4, 15] + I[8, 15]
|
597
|
+
"""
|
598
|
+
return self._ambient.sum_of_monomials(self._equiv_classes[x])
|
599
|
+
|
600
|
+
@lazy_attribute
|
601
|
+
def lift(self):
|
602
|
+
"""
|
603
|
+
Return the lift morphism from ``self`` to the ambient space.
|
604
|
+
|
605
|
+
EXAMPLES::
|
606
|
+
|
607
|
+
sage: P = posets.BooleanLattice(2)
|
608
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
609
|
+
sage: R.lift
|
610
|
+
Generic morphism:
|
611
|
+
From: Reduced incidence algebra of Finite lattice containing 4 elements over Rational Field
|
612
|
+
To: Incidence algebra of Finite lattice containing 4 elements over Rational Field
|
613
|
+
sage: R.an_element() - R.one()
|
614
|
+
R[(0, 0)] + 2*R[(0, 1)] + 3*R[(0, 3)]
|
615
|
+
sage: R.lift(R.an_element() - R.one())
|
616
|
+
I[0, 0] + 2*I[0, 1] + 2*I[0, 2] + 3*I[0, 3] + I[1, 1]
|
617
|
+
+ 2*I[1, 3] + I[2, 2] + 2*I[2, 3] + I[3, 3]
|
618
|
+
"""
|
619
|
+
return self.module_morphism(self._lift_basis, codomain=self._ambient)
|
620
|
+
|
621
|
+
def __getitem__(self, A):
|
622
|
+
"""
|
623
|
+
Return the basis element indexed by ``A``.
|
624
|
+
|
625
|
+
EXAMPLES::
|
626
|
+
|
627
|
+
sage: P = posets.BooleanLattice(4)
|
628
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
629
|
+
sage: R[0, 0]
|
630
|
+
R[(0, 0)]
|
631
|
+
sage: R[0, 1]
|
632
|
+
R[(0, 1)]
|
633
|
+
sage: R[0, 15]
|
634
|
+
R[(0, 15)]
|
635
|
+
sage: R[0]
|
636
|
+
R[(0, 0)]
|
637
|
+
|
638
|
+
This works for any representative of the equivalence class::
|
639
|
+
|
640
|
+
sage: R[3, 3]
|
641
|
+
R[(0, 0)]
|
642
|
+
sage: R[3, 11]
|
643
|
+
R[(0, 1)]
|
644
|
+
|
645
|
+
TESTS::
|
646
|
+
|
647
|
+
sage: R[2, 5]
|
648
|
+
Traceback (most recent call last):
|
649
|
+
...
|
650
|
+
ValueError: not an interval
|
651
|
+
|
652
|
+
sage: R[-1]
|
653
|
+
Traceback (most recent call last):
|
654
|
+
...
|
655
|
+
ValueError: not an element of the poset
|
656
|
+
"""
|
657
|
+
if not isinstance(A, (list, tuple)):
|
658
|
+
if A not in self._ambient._poset.list():
|
659
|
+
raise ValueError("not an element of the poset")
|
660
|
+
return self.one()
|
661
|
+
|
662
|
+
A = tuple(A)
|
663
|
+
if len(A) != 2:
|
664
|
+
raise ValueError("not an interval")
|
665
|
+
for k in self._equiv_classes:
|
666
|
+
if A in self._equiv_classes[k]:
|
667
|
+
return self.monomial(k)
|
668
|
+
raise ValueError("not an interval")
|
669
|
+
|
670
|
+
def _retract(self, x):
|
671
|
+
"""
|
672
|
+
Return the retract of ``x`` from the incidence algebra to ``self``.
|
673
|
+
|
674
|
+
EXAMPLES::
|
675
|
+
|
676
|
+
sage: P = posets.BooleanLattice(4)
|
677
|
+
sage: I = P.incidence_algebra(QQ)
|
678
|
+
sage: R = I.reduced_subalgebra()
|
679
|
+
sage: all(R._retract(R.lift(x)) == x for x in R.basis())
|
680
|
+
True
|
681
|
+
sage: R._retract(I.zeta()) == R.zeta()
|
682
|
+
True
|
683
|
+
sage: R._retract(I.delta()) == R.delta()
|
684
|
+
True
|
685
|
+
sage: R._retract(I.moebius()) == R.moebius()
|
686
|
+
True
|
687
|
+
"""
|
688
|
+
return self.sum_of_terms((k, x[k]) for k in self.basis().keys())
|
689
|
+
|
690
|
+
class Element(CombinatorialFreeModule.Element):
|
691
|
+
"""
|
692
|
+
An element of a reduced incidence algebra.
|
693
|
+
"""
|
694
|
+
def __call__(self, x, y):
|
695
|
+
"""
|
696
|
+
Return ``self(x, y)``.
|
697
|
+
|
698
|
+
EXAMPLES::
|
699
|
+
|
700
|
+
sage: P = posets.BooleanLattice(4)
|
701
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
702
|
+
sage: x = R.an_element()
|
703
|
+
sage: x(0, 7)
|
704
|
+
0
|
705
|
+
sage: x(7, 15)
|
706
|
+
2
|
707
|
+
sage: x(4, 15)
|
708
|
+
0
|
709
|
+
"""
|
710
|
+
return self.parent().lift(self)(x, y)
|
711
|
+
|
712
|
+
def _mul_(self, other):
|
713
|
+
"""
|
714
|
+
Return the product of ``self`` and ``other``.
|
715
|
+
|
716
|
+
EXAMPLES::
|
717
|
+
|
718
|
+
sage: P = posets.BooleanLattice(4)
|
719
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
720
|
+
sage: x = R.an_element()
|
721
|
+
sage: x * R.zeta()
|
722
|
+
2*R[(0, 0)] + 4*R[(0, 1)] + 9*R[(0, 3)] + 17*R[(0, 7)] + 28*R[(0, 15)]
|
723
|
+
sage: x * R.moebius()
|
724
|
+
2*R[(0, 0)] + R[(0, 3)] - 5*R[(0, 7)] + 12*R[(0, 15)]
|
725
|
+
sage: x * R.moebius() * R.zeta() == x
|
726
|
+
True
|
727
|
+
"""
|
728
|
+
P = self.parent()
|
729
|
+
return P._retract(P.lift(self) * P.lift(other))
|
730
|
+
|
731
|
+
@cached_method
|
732
|
+
def to_matrix(self):
|
733
|
+
r"""
|
734
|
+
Return ``self`` as a matrix.
|
735
|
+
|
736
|
+
EXAMPLES::
|
737
|
+
|
738
|
+
sage: P = posets.BooleanLattice(2)
|
739
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
740
|
+
sage: mu = R.moebius()
|
741
|
+
sage: mu.to_matrix()
|
742
|
+
[ 1 -1 -1 1]
|
743
|
+
[ 0 1 0 -1]
|
744
|
+
[ 0 0 1 -1]
|
745
|
+
[ 0 0 0 1]
|
746
|
+
"""
|
747
|
+
return self.parent().lift(self).to_matrix()
|
748
|
+
|
749
|
+
def is_unit(self) -> bool:
|
750
|
+
"""
|
751
|
+
Return if ``self`` is a unit.
|
752
|
+
|
753
|
+
EXAMPLES::
|
754
|
+
|
755
|
+
sage: P = posets.BooleanLattice(4)
|
756
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
757
|
+
sage: x = R.an_element()
|
758
|
+
sage: x.is_unit()
|
759
|
+
True
|
760
|
+
"""
|
761
|
+
return self[self.parent().one_basis()].is_unit()
|
762
|
+
|
763
|
+
def __invert__(self):
|
764
|
+
"""
|
765
|
+
Return the inverse of ``self``.
|
766
|
+
|
767
|
+
EXAMPLES::
|
768
|
+
|
769
|
+
sage: P = posets.BooleanLattice(4)
|
770
|
+
sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
|
771
|
+
sage: x = R.an_element()
|
772
|
+
sage: ~x
|
773
|
+
1/2*R[(0, 0)] - 1/2*R[(0, 1)] + 1/4*R[(0, 3)]
|
774
|
+
+ 3/2*R[(0, 7)] - 33/4*R[(0, 15)]
|
775
|
+
"""
|
776
|
+
P = self.parent()
|
777
|
+
return P._retract(~P.lift(self))
|
778
|
+
|
779
|
+
def lift(self):
|
780
|
+
"""
|
781
|
+
Return the lift of ``self`` to the ambient space.
|
782
|
+
|
783
|
+
EXAMPLES::
|
784
|
+
|
785
|
+
sage: P = posets.BooleanLattice(2)
|
786
|
+
sage: I = P.incidence_algebra(QQ)
|
787
|
+
sage: R = I.reduced_subalgebra()
|
788
|
+
sage: x = R.an_element(); x
|
789
|
+
2*R[(0, 0)] + 2*R[(0, 1)] + 3*R[(0, 3)]
|
790
|
+
sage: x.lift()
|
791
|
+
2*I[0, 0] + 2*I[0, 1] + 2*I[0, 2] + 3*I[0, 3] + 2*I[1, 1]
|
792
|
+
+ 2*I[1, 3] + 2*I[2, 2] + 2*I[2, 3] + 2*I[3, 3]
|
793
|
+
"""
|
794
|
+
return self.parent().lift(self)
|