passagemath-combinat 10.6.42__cp314-cp314-musllinux_1_2_x86_64.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.
Files changed (400) hide show
  1. passagemath_combinat/__init__.py +3 -0
  2. passagemath_combinat-10.6.42.dist-info/METADATA +160 -0
  3. passagemath_combinat-10.6.42.dist-info/RECORD +400 -0
  4. passagemath_combinat-10.6.42.dist-info/WHEEL +5 -0
  5. passagemath_combinat-10.6.42.dist-info/top_level.txt +3 -0
  6. passagemath_combinat.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
  7. passagemath_combinat.libs/libsymmetrica-81fe8739.so.3.0.0 +0 -0
  8. sage/algebras/affine_nil_temperley_lieb.py +263 -0
  9. sage/algebras/all.py +24 -0
  10. sage/algebras/all__sagemath_combinat.py +35 -0
  11. sage/algebras/askey_wilson.py +935 -0
  12. sage/algebras/associated_graded.py +345 -0
  13. sage/algebras/cellular_basis.py +350 -0
  14. sage/algebras/cluster_algebra.py +2766 -0
  15. sage/algebras/down_up_algebra.py +860 -0
  16. sage/algebras/free_algebra.py +1698 -0
  17. sage/algebras/free_algebra_element.py +345 -0
  18. sage/algebras/free_algebra_quotient.py +405 -0
  19. sage/algebras/free_algebra_quotient_element.py +295 -0
  20. sage/algebras/free_zinbiel_algebra.py +885 -0
  21. sage/algebras/hall_algebra.py +783 -0
  22. sage/algebras/hecke_algebras/all.py +4 -0
  23. sage/algebras/hecke_algebras/ariki_koike_algebra.py +1796 -0
  24. sage/algebras/hecke_algebras/ariki_koike_specht_modules.py +475 -0
  25. sage/algebras/hecke_algebras/cubic_hecke_algebra.py +3520 -0
  26. sage/algebras/hecke_algebras/cubic_hecke_base_ring.py +1473 -0
  27. sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py +1079 -0
  28. sage/algebras/iwahori_hecke_algebra.py +3095 -0
  29. sage/algebras/jordan_algebra.py +1773 -0
  30. sage/algebras/lie_conformal_algebras/abelian_lie_conformal_algebra.py +113 -0
  31. sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py +156 -0
  32. sage/algebras/lie_conformal_algebras/all.py +18 -0
  33. sage/algebras/lie_conformal_algebras/bosonic_ghosts_lie_conformal_algebra.py +134 -0
  34. sage/algebras/lie_conformal_algebras/examples.py +43 -0
  35. sage/algebras/lie_conformal_algebras/fermionic_ghosts_lie_conformal_algebra.py +131 -0
  36. sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py +139 -0
  37. sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py +174 -0
  38. sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py +167 -0
  39. sage/algebras/lie_conformal_algebras/freely_generated_lie_conformal_algebra.py +107 -0
  40. sage/algebras/lie_conformal_algebras/graded_lie_conformal_algebra.py +135 -0
  41. sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py +353 -0
  42. sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py +236 -0
  43. sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_basis.py +78 -0
  44. sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py +328 -0
  45. sage/algebras/lie_conformal_algebras/n2_lie_conformal_algebra.py +117 -0
  46. sage/algebras/lie_conformal_algebras/neveu_schwarz_lie_conformal_algebra.py +86 -0
  47. sage/algebras/lie_conformal_algebras/virasoro_lie_conformal_algebra.py +82 -0
  48. sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py +205 -0
  49. sage/algebras/nil_coxeter_algebra.py +191 -0
  50. sage/algebras/q_commuting_polynomials.py +673 -0
  51. sage/algebras/q_system.py +608 -0
  52. sage/algebras/quantum_clifford.py +959 -0
  53. sage/algebras/quantum_groups/ace_quantum_onsager.py +693 -0
  54. sage/algebras/quantum_groups/all.py +9 -0
  55. sage/algebras/quantum_groups/fock_space.py +2219 -0
  56. sage/algebras/quantum_groups/q_numbers.py +207 -0
  57. sage/algebras/quantum_groups/quantum_group_gap.py +2695 -0
  58. sage/algebras/quantum_groups/representations.py +591 -0
  59. sage/algebras/quantum_matrix_coordinate_algebra.py +1006 -0
  60. sage/algebras/quantum_oscillator.py +623 -0
  61. sage/algebras/quaternion_algebra.py +20 -0
  62. sage/algebras/quaternion_algebra_element.py +55 -0
  63. sage/algebras/rational_cherednik_algebra.py +525 -0
  64. sage/algebras/schur_algebra.py +670 -0
  65. sage/algebras/shuffle_algebra.py +1011 -0
  66. sage/algebras/splitting_algebra.py +779 -0
  67. sage/algebras/tensor_algebra.py +709 -0
  68. sage/algebras/yangian.py +1082 -0
  69. sage/algebras/yokonuma_hecke_algebra.py +1018 -0
  70. sage/all__sagemath_combinat.py +35 -0
  71. sage/combinat/SJT.py +255 -0
  72. sage/combinat/affine_permutation.py +2405 -0
  73. sage/combinat/algebraic_combinatorics.py +55 -0
  74. sage/combinat/all.py +53 -0
  75. sage/combinat/all__sagemath_combinat.py +195 -0
  76. sage/combinat/alternating_sign_matrix.py +2063 -0
  77. sage/combinat/baxter_permutations.py +346 -0
  78. sage/combinat/bijectionist.py +3220 -0
  79. sage/combinat/binary_recurrence_sequences.py +1180 -0
  80. sage/combinat/blob_algebra.py +685 -0
  81. sage/combinat/catalog_partitions.py +27 -0
  82. sage/combinat/chas/all.py +23 -0
  83. sage/combinat/chas/fsym.py +1180 -0
  84. sage/combinat/chas/wqsym.py +2601 -0
  85. sage/combinat/cluster_complex.py +326 -0
  86. sage/combinat/colored_permutations.py +2039 -0
  87. sage/combinat/colored_permutations_representations.py +964 -0
  88. sage/combinat/composition_signed.py +142 -0
  89. sage/combinat/composition_tableau.py +855 -0
  90. sage/combinat/constellation.py +1729 -0
  91. sage/combinat/core.py +751 -0
  92. sage/combinat/counting.py +12 -0
  93. sage/combinat/crystals/affine.py +742 -0
  94. sage/combinat/crystals/affine_factorization.py +518 -0
  95. sage/combinat/crystals/affinization.py +331 -0
  96. sage/combinat/crystals/alcove_path.py +2013 -0
  97. sage/combinat/crystals/all.py +22 -0
  98. sage/combinat/crystals/bkk_crystals.py +141 -0
  99. sage/combinat/crystals/catalog.py +115 -0
  100. sage/combinat/crystals/catalog_elementary_crystals.py +18 -0
  101. sage/combinat/crystals/catalog_infinity_crystals.py +33 -0
  102. sage/combinat/crystals/catalog_kirillov_reshetikhin.py +18 -0
  103. sage/combinat/crystals/crystals.py +257 -0
  104. sage/combinat/crystals/direct_sum.py +260 -0
  105. sage/combinat/crystals/elementary_crystals.py +1251 -0
  106. sage/combinat/crystals/fast_crystals.py +441 -0
  107. sage/combinat/crystals/fully_commutative_stable_grothendieck.py +1205 -0
  108. sage/combinat/crystals/generalized_young_walls.py +1076 -0
  109. sage/combinat/crystals/highest_weight_crystals.py +436 -0
  110. sage/combinat/crystals/induced_structure.py +695 -0
  111. sage/combinat/crystals/infinity_crystals.py +730 -0
  112. sage/combinat/crystals/kac_modules.py +863 -0
  113. sage/combinat/crystals/kirillov_reshetikhin.py +4196 -0
  114. sage/combinat/crystals/kyoto_path_model.py +497 -0
  115. sage/combinat/crystals/letters.cpython-314-x86_64-linux-musl.so +0 -0
  116. sage/combinat/crystals/letters.pxd +79 -0
  117. sage/combinat/crystals/letters.pyx +3056 -0
  118. sage/combinat/crystals/littelmann_path.py +1518 -0
  119. sage/combinat/crystals/monomial_crystals.py +1262 -0
  120. sage/combinat/crystals/multisegments.py +462 -0
  121. sage/combinat/crystals/mv_polytopes.py +467 -0
  122. sage/combinat/crystals/pbw_crystal.py +511 -0
  123. sage/combinat/crystals/pbw_datum.cpython-314-x86_64-linux-musl.so +0 -0
  124. sage/combinat/crystals/pbw_datum.pxd +4 -0
  125. sage/combinat/crystals/pbw_datum.pyx +487 -0
  126. sage/combinat/crystals/polyhedral_realization.py +372 -0
  127. sage/combinat/crystals/spins.cpython-314-x86_64-linux-musl.so +0 -0
  128. sage/combinat/crystals/spins.pxd +21 -0
  129. sage/combinat/crystals/spins.pyx +756 -0
  130. sage/combinat/crystals/star_crystal.py +290 -0
  131. sage/combinat/crystals/subcrystal.py +464 -0
  132. sage/combinat/crystals/tensor_product.py +1177 -0
  133. sage/combinat/crystals/tensor_product_element.cpython-314-x86_64-linux-musl.so +0 -0
  134. sage/combinat/crystals/tensor_product_element.pxd +35 -0
  135. sage/combinat/crystals/tensor_product_element.pyx +1870 -0
  136. sage/combinat/crystals/virtual_crystal.py +420 -0
  137. sage/combinat/cyclic_sieving_phenomenon.py +204 -0
  138. sage/combinat/debruijn_sequence.cpython-314-x86_64-linux-musl.so +0 -0
  139. sage/combinat/debruijn_sequence.pyx +355 -0
  140. sage/combinat/decorated_permutation.py +270 -0
  141. sage/combinat/degree_sequences.cpython-314-x86_64-linux-musl.so +0 -0
  142. sage/combinat/degree_sequences.pyx +588 -0
  143. sage/combinat/derangements.py +527 -0
  144. sage/combinat/descent_algebra.py +1008 -0
  145. sage/combinat/diagram.py +1551 -0
  146. sage/combinat/diagram_algebras.py +5886 -0
  147. sage/combinat/dyck_word.py +4349 -0
  148. sage/combinat/e_one_star.py +1623 -0
  149. sage/combinat/enumerated_sets.py +123 -0
  150. sage/combinat/expnums.cpython-314-x86_64-linux-musl.so +0 -0
  151. sage/combinat/expnums.pyx +148 -0
  152. sage/combinat/fast_vector_partitions.cpython-314-x86_64-linux-musl.so +0 -0
  153. sage/combinat/fast_vector_partitions.pyx +346 -0
  154. sage/combinat/fqsym.py +1977 -0
  155. sage/combinat/free_dendriform_algebra.py +954 -0
  156. sage/combinat/free_prelie_algebra.py +1141 -0
  157. sage/combinat/fully_commutative_elements.py +1077 -0
  158. sage/combinat/fully_packed_loop.py +1523 -0
  159. sage/combinat/gelfand_tsetlin_patterns.py +1409 -0
  160. sage/combinat/gray_codes.py +311 -0
  161. sage/combinat/grossman_larson_algebras.py +667 -0
  162. sage/combinat/growth.py +4352 -0
  163. sage/combinat/hall_polynomial.py +188 -0
  164. sage/combinat/hillman_grassl.py +866 -0
  165. sage/combinat/integer_matrices.py +329 -0
  166. sage/combinat/integer_vectors_mod_permgroup.py +1238 -0
  167. sage/combinat/k_tableau.py +4564 -0
  168. sage/combinat/kazhdan_lusztig.py +215 -0
  169. sage/combinat/key_polynomial.py +885 -0
  170. sage/combinat/knutson_tao_puzzles.py +2286 -0
  171. sage/combinat/lr_tableau.py +311 -0
  172. sage/combinat/matrices/all.py +24 -0
  173. sage/combinat/matrices/hadamard_matrix.py +3790 -0
  174. sage/combinat/matrices/latin.py +2912 -0
  175. sage/combinat/misc.py +401 -0
  176. sage/combinat/multiset_partition_into_sets_ordered.py +3541 -0
  177. sage/combinat/ncsf_qsym/all.py +21 -0
  178. sage/combinat/ncsf_qsym/combinatorics.py +317 -0
  179. sage/combinat/ncsf_qsym/generic_basis_code.py +1427 -0
  180. sage/combinat/ncsf_qsym/ncsf.py +5637 -0
  181. sage/combinat/ncsf_qsym/qsym.py +4053 -0
  182. sage/combinat/ncsf_qsym/tutorial.py +447 -0
  183. sage/combinat/ncsym/all.py +21 -0
  184. sage/combinat/ncsym/bases.py +855 -0
  185. sage/combinat/ncsym/dual.py +593 -0
  186. sage/combinat/ncsym/ncsym.py +2076 -0
  187. sage/combinat/necklace.py +551 -0
  188. sage/combinat/non_decreasing_parking_function.py +634 -0
  189. sage/combinat/nu_dyck_word.py +1474 -0
  190. sage/combinat/output.py +861 -0
  191. sage/combinat/parallelogram_polyomino.py +4326 -0
  192. sage/combinat/parking_functions.py +1602 -0
  193. sage/combinat/partition_algebra.py +1998 -0
  194. sage/combinat/partition_kleshchev.py +1982 -0
  195. sage/combinat/partition_shifting_algebras.py +584 -0
  196. sage/combinat/partition_tuple.py +3114 -0
  197. sage/combinat/path_tableaux/all.py +13 -0
  198. sage/combinat/path_tableaux/catalog.py +29 -0
  199. sage/combinat/path_tableaux/dyck_path.py +380 -0
  200. sage/combinat/path_tableaux/frieze.py +476 -0
  201. sage/combinat/path_tableaux/path_tableau.py +728 -0
  202. sage/combinat/path_tableaux/semistandard.py +510 -0
  203. sage/combinat/perfect_matching.py +779 -0
  204. sage/combinat/plane_partition.py +3300 -0
  205. sage/combinat/q_bernoulli.cpython-314-x86_64-linux-musl.so +0 -0
  206. sage/combinat/q_bernoulli.pyx +128 -0
  207. sage/combinat/quickref.py +81 -0
  208. sage/combinat/recognizable_series.py +2051 -0
  209. sage/combinat/regular_sequence.py +4316 -0
  210. sage/combinat/regular_sequence_bounded.py +543 -0
  211. sage/combinat/restricted_growth.py +81 -0
  212. sage/combinat/ribbon.py +20 -0
  213. sage/combinat/ribbon_shaped_tableau.py +489 -0
  214. sage/combinat/ribbon_tableau.py +1180 -0
  215. sage/combinat/rigged_configurations/all.py +46 -0
  216. sage/combinat/rigged_configurations/bij_abstract_class.py +548 -0
  217. sage/combinat/rigged_configurations/bij_infinity.py +370 -0
  218. sage/combinat/rigged_configurations/bij_type_A.py +163 -0
  219. sage/combinat/rigged_configurations/bij_type_A2_dual.py +338 -0
  220. sage/combinat/rigged_configurations/bij_type_A2_even.py +218 -0
  221. sage/combinat/rigged_configurations/bij_type_A2_odd.py +199 -0
  222. sage/combinat/rigged_configurations/bij_type_B.py +900 -0
  223. sage/combinat/rigged_configurations/bij_type_C.py +267 -0
  224. sage/combinat/rigged_configurations/bij_type_D.py +771 -0
  225. sage/combinat/rigged_configurations/bij_type_D_tri.py +392 -0
  226. sage/combinat/rigged_configurations/bij_type_D_twisted.py +576 -0
  227. sage/combinat/rigged_configurations/bij_type_E67.py +402 -0
  228. sage/combinat/rigged_configurations/bijection.py +143 -0
  229. sage/combinat/rigged_configurations/kleber_tree.py +1475 -0
  230. sage/combinat/rigged_configurations/kr_tableaux.py +1898 -0
  231. sage/combinat/rigged_configurations/rc_crystal.py +461 -0
  232. sage/combinat/rigged_configurations/rc_infinity.py +540 -0
  233. sage/combinat/rigged_configurations/rigged_configuration_element.py +2403 -0
  234. sage/combinat/rigged_configurations/rigged_configurations.py +1918 -0
  235. sage/combinat/rigged_configurations/rigged_partition.cpython-314-x86_64-linux-musl.so +0 -0
  236. sage/combinat/rigged_configurations/rigged_partition.pxd +15 -0
  237. sage/combinat/rigged_configurations/rigged_partition.pyx +680 -0
  238. sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py +499 -0
  239. sage/combinat/rigged_configurations/tensor_product_kr_tableaux_element.py +428 -0
  240. sage/combinat/rsk.py +3438 -0
  241. sage/combinat/schubert_polynomial.py +508 -0
  242. sage/combinat/set_partition.py +3318 -0
  243. sage/combinat/set_partition_iterator.cpython-314-x86_64-linux-musl.so +0 -0
  244. sage/combinat/set_partition_iterator.pyx +136 -0
  245. sage/combinat/set_partition_ordered.py +1590 -0
  246. sage/combinat/sf/abreu_nigro.py +346 -0
  247. sage/combinat/sf/all.py +52 -0
  248. sage/combinat/sf/character.py +576 -0
  249. sage/combinat/sf/classical.py +319 -0
  250. sage/combinat/sf/dual.py +996 -0
  251. sage/combinat/sf/elementary.py +549 -0
  252. sage/combinat/sf/hall_littlewood.py +1028 -0
  253. sage/combinat/sf/hecke.py +336 -0
  254. sage/combinat/sf/homogeneous.py +464 -0
  255. sage/combinat/sf/jack.py +1428 -0
  256. sage/combinat/sf/k_dual.py +1458 -0
  257. sage/combinat/sf/kfpoly.py +447 -0
  258. sage/combinat/sf/llt.py +789 -0
  259. sage/combinat/sf/macdonald.py +2019 -0
  260. sage/combinat/sf/monomial.py +525 -0
  261. sage/combinat/sf/multiplicative.py +113 -0
  262. sage/combinat/sf/new_kschur.py +1786 -0
  263. sage/combinat/sf/ns_macdonald.py +964 -0
  264. sage/combinat/sf/orthogonal.py +246 -0
  265. sage/combinat/sf/orthotriang.py +355 -0
  266. sage/combinat/sf/powersum.py +963 -0
  267. sage/combinat/sf/schur.py +880 -0
  268. sage/combinat/sf/sf.py +1653 -0
  269. sage/combinat/sf/sfa.py +7053 -0
  270. sage/combinat/sf/symplectic.py +253 -0
  271. sage/combinat/sf/witt.py +721 -0
  272. sage/combinat/shifted_primed_tableau.py +2735 -0
  273. sage/combinat/shuffle.py +830 -0
  274. sage/combinat/sidon_sets.py +146 -0
  275. sage/combinat/similarity_class_type.py +1721 -0
  276. sage/combinat/sine_gordon.py +618 -0
  277. sage/combinat/six_vertex_model.py +784 -0
  278. sage/combinat/skew_partition.py +2053 -0
  279. sage/combinat/skew_tableau.py +2989 -0
  280. sage/combinat/sloane_functions.py +8935 -0
  281. sage/combinat/specht_module.py +1403 -0
  282. sage/combinat/species/all.py +48 -0
  283. sage/combinat/species/characteristic_species.py +321 -0
  284. sage/combinat/species/composition_species.py +273 -0
  285. sage/combinat/species/cycle_species.py +284 -0
  286. sage/combinat/species/empty_species.py +155 -0
  287. sage/combinat/species/functorial_composition_species.py +148 -0
  288. sage/combinat/species/generating_series.py +673 -0
  289. sage/combinat/species/library.py +148 -0
  290. sage/combinat/species/linear_order_species.py +169 -0
  291. sage/combinat/species/misc.py +83 -0
  292. sage/combinat/species/partition_species.py +290 -0
  293. sage/combinat/species/permutation_species.py +268 -0
  294. sage/combinat/species/product_species.py +423 -0
  295. sage/combinat/species/recursive_species.py +476 -0
  296. sage/combinat/species/set_species.py +192 -0
  297. sage/combinat/species/species.py +820 -0
  298. sage/combinat/species/structure.py +539 -0
  299. sage/combinat/species/subset_species.py +243 -0
  300. sage/combinat/species/sum_species.py +225 -0
  301. sage/combinat/subword.py +564 -0
  302. sage/combinat/subword_complex.py +2122 -0
  303. sage/combinat/subword_complex_c.cpython-314-x86_64-linux-musl.so +0 -0
  304. sage/combinat/subword_complex_c.pyx +119 -0
  305. sage/combinat/super_tableau.py +821 -0
  306. sage/combinat/superpartition.py +1154 -0
  307. sage/combinat/symmetric_group_algebra.py +3774 -0
  308. sage/combinat/symmetric_group_representations.py +1830 -0
  309. sage/combinat/t_sequences.py +877 -0
  310. sage/combinat/tableau.py +9506 -0
  311. sage/combinat/tableau_residues.py +860 -0
  312. sage/combinat/tableau_tuple.py +5353 -0
  313. sage/combinat/tiling.py +2432 -0
  314. sage/combinat/triangles_FHM.py +777 -0
  315. sage/combinat/tutorial.py +1857 -0
  316. sage/combinat/vector_partition.py +337 -0
  317. sage/combinat/words/abstract_word.py +1722 -0
  318. sage/combinat/words/all.py +59 -0
  319. sage/combinat/words/alphabet.py +268 -0
  320. sage/combinat/words/finite_word.py +7201 -0
  321. sage/combinat/words/infinite_word.py +113 -0
  322. sage/combinat/words/lyndon_word.py +652 -0
  323. sage/combinat/words/morphic.py +351 -0
  324. sage/combinat/words/morphism.py +3878 -0
  325. sage/combinat/words/paths.py +2932 -0
  326. sage/combinat/words/shuffle_product.py +278 -0
  327. sage/combinat/words/suffix_trees.py +1873 -0
  328. sage/combinat/words/word.py +769 -0
  329. sage/combinat/words/word_char.cpython-314-x86_64-linux-musl.so +0 -0
  330. sage/combinat/words/word_char.pyx +847 -0
  331. sage/combinat/words/word_datatypes.cpython-314-x86_64-linux-musl.so +0 -0
  332. sage/combinat/words/word_datatypes.pxd +4 -0
  333. sage/combinat/words/word_datatypes.pyx +1067 -0
  334. sage/combinat/words/word_generators.py +2026 -0
  335. sage/combinat/words/word_infinite_datatypes.py +1218 -0
  336. sage/combinat/words/word_options.py +99 -0
  337. sage/combinat/words/words.py +2396 -0
  338. sage/data_structures/all__sagemath_combinat.py +1 -0
  339. sage/databases/all__sagemath_combinat.py +13 -0
  340. sage/databases/findstat.py +4897 -0
  341. sage/databases/oeis.py +2058 -0
  342. sage/databases/sloane.py +393 -0
  343. sage/dynamics/all__sagemath_combinat.py +14 -0
  344. sage/dynamics/cellular_automata/all.py +7 -0
  345. sage/dynamics/cellular_automata/catalog.py +34 -0
  346. sage/dynamics/cellular_automata/elementary.py +612 -0
  347. sage/dynamics/cellular_automata/glca.py +477 -0
  348. sage/dynamics/cellular_automata/solitons.py +1463 -0
  349. sage/dynamics/finite_dynamical_system.py +1249 -0
  350. sage/dynamics/finite_dynamical_system_catalog.py +382 -0
  351. sage/games/all.py +7 -0
  352. sage/games/hexad.py +704 -0
  353. sage/games/quantumino.py +591 -0
  354. sage/games/sudoku.py +889 -0
  355. sage/games/sudoku_backtrack.cpython-314-x86_64-linux-musl.so +0 -0
  356. sage/games/sudoku_backtrack.pyx +189 -0
  357. sage/groups/all__sagemath_combinat.py +1 -0
  358. sage/groups/indexed_free_group.py +489 -0
  359. sage/libs/all__sagemath_combinat.py +6 -0
  360. sage/libs/lrcalc/__init__.py +1 -0
  361. sage/libs/lrcalc/lrcalc.py +525 -0
  362. sage/libs/symmetrica/__init__.py +7 -0
  363. sage/libs/symmetrica/all.py +101 -0
  364. sage/libs/symmetrica/kostka.pxi +168 -0
  365. sage/libs/symmetrica/part.pxi +193 -0
  366. sage/libs/symmetrica/plet.pxi +42 -0
  367. sage/libs/symmetrica/sab.pxi +196 -0
  368. sage/libs/symmetrica/sb.pxi +332 -0
  369. sage/libs/symmetrica/sc.pxi +192 -0
  370. sage/libs/symmetrica/schur.pxi +956 -0
  371. sage/libs/symmetrica/symmetrica.cpython-314-x86_64-linux-musl.so +0 -0
  372. sage/libs/symmetrica/symmetrica.pxi +1172 -0
  373. sage/libs/symmetrica/symmetrica.pyx +39 -0
  374. sage/monoids/all.py +13 -0
  375. sage/monoids/automatic_semigroup.py +1054 -0
  376. sage/monoids/free_abelian_monoid.py +315 -0
  377. sage/monoids/free_abelian_monoid_element.cpython-314-x86_64-linux-musl.so +0 -0
  378. sage/monoids/free_abelian_monoid_element.pxd +16 -0
  379. sage/monoids/free_abelian_monoid_element.pyx +397 -0
  380. sage/monoids/free_monoid.py +335 -0
  381. sage/monoids/free_monoid_element.py +431 -0
  382. sage/monoids/hecke_monoid.py +65 -0
  383. sage/monoids/string_monoid.py +817 -0
  384. sage/monoids/string_monoid_element.py +547 -0
  385. sage/monoids/string_ops.py +143 -0
  386. sage/monoids/trace_monoid.py +972 -0
  387. sage/rings/all__sagemath_combinat.py +2 -0
  388. sage/sat/all.py +4 -0
  389. sage/sat/boolean_polynomials.py +405 -0
  390. sage/sat/converters/__init__.py +6 -0
  391. sage/sat/converters/anf2cnf.py +14 -0
  392. sage/sat/converters/polybori.py +611 -0
  393. sage/sat/solvers/__init__.py +5 -0
  394. sage/sat/solvers/cryptominisat.py +287 -0
  395. sage/sat/solvers/dimacs.py +783 -0
  396. sage/sat/solvers/picosat.py +228 -0
  397. sage/sat/solvers/sat_lp.py +156 -0
  398. sage/sat/solvers/satsolver.cpython-314-x86_64-linux-musl.so +0 -0
  399. sage/sat/solvers/satsolver.pxd +3 -0
  400. sage/sat/solvers/satsolver.pyx +405 -0
@@ -0,0 +1,709 @@
1
+ # sage_setup: distribution = sagemath-combinat
2
+ # sage.doctest: needs sage.combinat sage.modules
3
+ r"""
4
+ Tensor Algebras
5
+
6
+ AUTHORS:
7
+
8
+ - Travis Scrimshaw (2014-01-24): Initial version
9
+
10
+ .. TODO::
11
+
12
+ - Coerce to/from free algebra.
13
+ """
14
+
15
+ #*****************************************************************************
16
+ # Copyright (C) 2014 Travis Scrimshaw <tscrim at ucdavis.edu>
17
+ #
18
+ # Distributed under the terms of the GNU General Public License (GPL)
19
+ # http://www.gnu.org/licenses/
20
+ #*****************************************************************************
21
+
22
+ from sage.categories.algebras import Algebras
23
+ from sage.categories.pushout import ConstructionFunctor
24
+ from sage.categories.graded_hopf_algebras_with_basis import GradedHopfAlgebrasWithBasis
25
+ from sage.categories.homset import Hom
26
+ from sage.categories.morphism import Morphism
27
+ from sage.categories.modules import Modules
28
+ from sage.categories.tensor import tensor
29
+ from sage.combinat.free_module import CombinatorialFreeModule, CombinatorialFreeModule_Tensor
30
+ from sage.monoids.indexed_free_monoid import IndexedFreeMonoid
31
+ from sage.misc.cachefunc import cached_method
32
+ from sage.sets.family import Family
33
+
34
+
35
+ class TensorAlgebra(CombinatorialFreeModule):
36
+ r"""
37
+ The tensor algebra `T(M)` of a module `M`.
38
+
39
+ Let `\{ b_i \}_{i \in I}` be a basis of the `R`-module `M`. Then the
40
+ tensor algebra `T(M)` of `M` is an associative `R`-algebra, with a
41
+ basis consisting of all tensors of the form
42
+ `b_{i_1} \otimes b_{i_2} \otimes \cdots \otimes b_{i_n}` for
43
+ nonnegative integers `n` and `n`-tuples
44
+ `(i_1, i_2, \ldots, i_n) \in I^n`. The product of `T(M)` is given by
45
+
46
+ .. MATH::
47
+
48
+ (b_{i_1} \otimes \cdots \otimes b_{i_m}) \cdot (b_{j_1} \otimes
49
+ \cdots \otimes b_{j_n}) = b_{i_1} \otimes \cdots \otimes b_{i_m}
50
+ \otimes b_{j_1} \otimes \cdots \otimes b_{j_n}.
51
+
52
+ As an algebra, it is generated by the basis vectors `b_i` of `M`. It
53
+ is an `\NN`-graded `R`-algebra, with the degree of each `b_i` being
54
+ `1`.
55
+
56
+ It also has a Hopf algebra structure: The comultiplication is the
57
+ unique algebra morphism `\delta : T(M) \to T(M) \otimes T(M)` defined
58
+ by:
59
+
60
+ .. MATH::
61
+
62
+ \delta(b_i) = b_i \otimes 1 + 1 \otimes b_i
63
+
64
+ (where the `\otimes` symbol here forms tensors in
65
+ `T(M) \otimes T(M)`, not inside `T(M)` itself). The counit is the
66
+ unique algebra morphism `T(M) \to R` sending each `b_i` to `0`. Its
67
+ antipode `S` satisfies
68
+
69
+ .. MATH::
70
+
71
+ S(b_{i_1} \otimes \cdots \otimes b_{i_m}) = (-1)^m (b_{i_m} \otimes
72
+ \cdots \otimes b_{i_1}).
73
+
74
+ This is a connected graded cocommutative Hopf algebra.
75
+
76
+ REFERENCES:
77
+
78
+ - :wikipedia:`Tensor_algebra`
79
+
80
+ .. SEEALSO::
81
+
82
+ :class:`TensorAlgebra`
83
+
84
+ EXAMPLES::
85
+
86
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
87
+ sage: TA = TensorAlgebra(C)
88
+ sage: TA.dimension()
89
+ +Infinity
90
+ sage: TA.base_ring()
91
+ Rational Field
92
+ sage: TA.algebra_generators()
93
+ Finite family {'a': B['a'], 'b': B['b'], 'c': B['c']}
94
+ """
95
+ def __init__(self, M, prefix='T', category=None, **options):
96
+ r"""
97
+ Initialize ``self``.
98
+
99
+ EXAMPLES::
100
+
101
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
102
+ sage: TA = TensorAlgebra(C)
103
+ sage: TestSuite(TA).run()
104
+ sage: m = SymmetricFunctions(QQ).m()
105
+ sage: Tm = TensorAlgebra(m)
106
+ sage: TestSuite(Tm).run()
107
+ """
108
+ self._base_module = M
109
+ R = M.base_ring()
110
+ category = GradedHopfAlgebrasWithBasis(R.category()).or_subcategory(category)
111
+
112
+ CombinatorialFreeModule.__init__(self, R, IndexedFreeMonoid(M.indices()),
113
+ prefix=prefix, category=category, **options)
114
+
115
+ # the following is not the best option, but it's better than nothing.
116
+ self._print_options['tensor_symbol'] = options.get('tensor_symbol', tensor.symbol)
117
+
118
+ def _repr_(self):
119
+ r"""
120
+ Return a string representation of ``self``.
121
+
122
+ EXAMPLES::
123
+
124
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
125
+ sage: TensorAlgebra(C)
126
+ Tensor Algebra of Free module generated by {'a', 'b', 'c'} over Rational Field
127
+ """
128
+ return "Tensor Algebra of {}".format(self._base_module)
129
+
130
+ def _repr_term(self, m):
131
+ """
132
+ Return a string of representation of the term indexed by ``m``.
133
+
134
+ TESTS::
135
+
136
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
137
+ sage: TA = TensorAlgebra(C)
138
+ sage: s = TA(['a','b','c']).leading_support()
139
+ sage: TA._repr_term(s)
140
+ "B['a'] # B['b'] # B['c']"
141
+ sage: s = TA(['a']*3 + ['b']*2 + ['a','c','b']).leading_support()
142
+ sage: TA._repr_term(s)
143
+ "B['a'] # B['a'] # B['a'] # B['b'] # B['b'] # B['a'] # B['c'] # B['b']"
144
+
145
+ sage: I = TA.indices()
146
+ sage: TA._repr_term(I.one())
147
+ '1'
148
+ """
149
+ if len(m) == 0:
150
+ return '1'
151
+ symb = self._print_options['tensor_symbol']
152
+ if symb is None:
153
+ symb = tensor.symbol
154
+ return symb.join(self._base_module._repr_term(k) for k,e in m._monomial for i in range(e))
155
+
156
+ def _latex_term(self, m):
157
+ r"""
158
+ Return a latex representation of the term indexed by ``m``.
159
+
160
+ TESTS::
161
+
162
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
163
+ sage: TA = TensorAlgebra(C)
164
+ sage: s = TA(['a','b','c']).leading_support()
165
+ sage: TA._latex_term(s)
166
+ 'B_{a} \\otimes B_{b} \\otimes B_{c}'
167
+
168
+ sage: I = TA.indices()
169
+ sage: TA._latex_term(I.one())
170
+ '1'
171
+ """
172
+ if len(m) == 0:
173
+ return '1'
174
+ symb = " \\otimes "
175
+ return symb.join(self._base_module._latex_term(k) for k,e in m._monomial for i in range(e))
176
+
177
+ def _ascii_art_term(self, m):
178
+ """
179
+ Return an ascii art representation of the term indexed by ``m``.
180
+
181
+ TESTS::
182
+
183
+ sage: C = CombinatorialFreeModule(QQ, Partitions())
184
+ sage: TA = TensorAlgebra(C)
185
+ sage: s = TA([Partition([3,2,2,1]), Partition([3])]).leading_support()
186
+ sage: TA._ascii_art_term(s)
187
+ B # B
188
+ *** ***
189
+ **
190
+ **
191
+ *
192
+ sage: s = TA([Partition([3,2,2,1])]*2 + [Partition([3])]*3 + [Partition([1])]*2).leading_support()
193
+ sage: t = TA._ascii_art_term(s); t
194
+ B # B # B # B # B # B # B
195
+ *** *** *** *** *** * *
196
+ ** **
197
+ ** **
198
+ * *
199
+ sage: t._breakpoints
200
+ [7, 14, 21, 28, 35, 40]
201
+
202
+ sage: I = TA.indices()
203
+ sage: TA._ascii_art_term(I.one())
204
+ '1'
205
+ """
206
+ if len(m) == 0:
207
+ return '1'
208
+ from sage.typeset.ascii_art import AsciiArt, ascii_art
209
+ symb = self._print_options['tensor_symbol']
210
+ if symb is None:
211
+ symb = tensor.symbol
212
+ M = self._base_module
213
+ return ascii_art(*(M._ascii_art_term(k)
214
+ for k, e in m._monomial for _ in range(e)),
215
+ sep=AsciiArt([symb], breakpoints=[len(symb)]))
216
+
217
+ def _element_constructor_(self, x):
218
+ """
219
+ Construct an element of ``self``.
220
+
221
+ EXAMPLES::
222
+
223
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
224
+ sage: TA = TensorAlgebra(C)
225
+ sage: TA(['a','b','c'])
226
+ B['a'] # B['b'] # B['c']
227
+ sage: TA(['a','b','b'])
228
+ B['a'] # B['b'] # B['b']
229
+ sage: TA(['a','b','c']) + TA(['a'])
230
+ B['a'] + B['a'] # B['b'] # B['c']
231
+ sage: TA(['a','b','c']) + TA(['a','b','a'])
232
+ B['a'] # B['b'] # B['a'] + B['a'] # B['b'] # B['c']
233
+ sage: TA(['a','b','c']) + TA(['a','b','c'])
234
+ 2*B['a'] # B['b'] # B['c']
235
+ sage: TA(C.an_element())
236
+ 2*B['a'] + 2*B['b'] + 3*B['c']
237
+ """
238
+ FM = self._indices
239
+ if isinstance(x, (list, tuple)):
240
+ x = FM.prod(FM.gen(elt) for elt in x)
241
+ return self.monomial(x)
242
+ if x in FM._indices:
243
+ return self.monomial(FM.gen(x))
244
+ if x in self._base_module:
245
+ return self.sum_of_terms((FM.gen(k), v) for k,v in x)
246
+ return CombinatorialFreeModule._element_constructor_(self, x)
247
+
248
+ def _tensor_constructor_(self, elts):
249
+ """
250
+ Construct an element of ``self`` that is the tensor product of
251
+ the list of base module elements ``elts``.
252
+
253
+ TESTS::
254
+
255
+ sage: C = CombinatorialFreeModule(ZZ, ['a','b'])
256
+ sage: TA = TensorAlgebra(C)
257
+ sage: x = C.an_element(); x
258
+ 2*B['a'] + 2*B['b']
259
+ sage: TA._tensor_constructor_([x, x])
260
+ 4*B['a'] # B['a'] + 4*B['a'] # B['b']
261
+ + 4*B['b'] # B['a'] + 4*B['b'] # B['b']
262
+ sage: y = C.monomial('b') + 3*C.monomial('a')
263
+ sage: TA._tensor_constructor_([x, y])
264
+ 6*B['a'] # B['a'] + 2*B['a'] # B['b'] + 6*B['b'] # B['a']
265
+ + 2*B['b'] # B['b']
266
+ sage: TA._tensor_constructor_([y]) == y
267
+ True
268
+ sage: TA._tensor_constructor_([x]) == x
269
+ True
270
+ sage: TA._tensor_constructor_([]) == TA.one()
271
+ True
272
+ """
273
+ if not elts:
274
+ return self.one()
275
+
276
+ zero = self.base_ring().zero()
277
+ I = self._indices
278
+ cur = {I.gen(k): v for k,v in elts[0]}
279
+ for x in elts[1:]:
280
+ next = {}
281
+ for k,v in cur.items():
282
+ for m,c in x:
283
+ i = k * I.gen(m)
284
+ next[i] = cur.get(i, zero) + v * c
285
+ cur = next
286
+ return self._from_dict(cur)
287
+
288
+ def _coerce_map_from_(self, R):
289
+ """
290
+ Return ``True`` if there is a coercion from ``R`` into ``self`` and
291
+ ``False`` otherwise. The things that coerce into ``self`` are:
292
+
293
+ - Anything with a coercion into ``self.base_ring()``.
294
+
295
+ - Anything with a coercion into the base module of ``self``.
296
+
297
+ - A tensor algebra whose base module has a coercion into the base
298
+ module of ``self``.
299
+
300
+ - A tensor module whose factors have a coercion into the base
301
+ module of ``self``.
302
+
303
+ TESTS::
304
+
305
+ sage: C = CombinatorialFreeModule(ZZ, Set([1,2]))
306
+ sage: TAC = TensorAlgebra(C)
307
+ sage: TAC.has_coerce_map_from(ZZ)
308
+ True
309
+ sage: TAC(1) == TAC.one()
310
+ True
311
+ sage: TAC.has_coerce_map_from(C)
312
+ True
313
+ sage: c = C.monomial(2)
314
+ sage: TAC(c)
315
+ B[2]
316
+ sage: d = C.monomial(1)
317
+ sage: TAC(c) * TAC(d)
318
+ B[2] # B[1]
319
+ sage: TAC(c-d) * TAC(c+d)
320
+ -B[1] # B[1] - B[1] # B[2] + B[2] # B[1] + B[2] # B[2]
321
+
322
+ sage: TCC = tensor((C,C))
323
+ sage: TAC.has_coerce_map_from(TCC)
324
+ True
325
+ sage: TAC(tensor([c, d]))
326
+ B[2] # B[1]
327
+
328
+ ::
329
+
330
+ sage: D = CombinatorialFreeModule(ZZ, Set([2,4]))
331
+ sage: TAD = TensorAlgebra(D)
332
+ sage: f = C.module_morphism(on_basis=lambda x: D.monomial(2*x), codomain=D)
333
+ sage: f.register_as_coercion()
334
+
335
+ sage: TCD = tensor((C,D))
336
+ sage: TAD.has_coerce_map_from(TCC)
337
+ True
338
+ sage: TAD.has_coerce_map_from(TCD)
339
+ True
340
+ sage: TAC.has_coerce_map_from(TCD)
341
+ False
342
+ sage: TAD.has_coerce_map_from(TAC)
343
+ True
344
+ sage: TAD(3 * TAC([1, 2, 2, 1, 1]))
345
+ 3*B[2] # B[4] # B[4] # B[2] # B[2]
346
+ """
347
+ # Base ring coercions
348
+ self_base_ring = self.base_ring()
349
+ if self_base_ring == R:
350
+ return BaseRingLift(Hom(self_base_ring, self))
351
+ if self_base_ring.has_coerce_map_from(R):
352
+ return BaseRingLift(Hom(self_base_ring, self)) * self_base_ring.coerce_map_from(R)
353
+
354
+ M = self._base_module
355
+ # Base module coercions
356
+ if R == M:
357
+ return True
358
+ if M.has_coerce_map_from(R):
359
+ phi = M.coerce_map_from(R)
360
+ return self.coerce_map_from(M) * phi
361
+
362
+ # Tensor algebra coercions
363
+ if isinstance(R, TensorAlgebra) and M.has_coerce_map_from(R._base_module):
364
+ RM = R._base_module
365
+ phi = M.coerce_map_from(RM)
366
+ return R.module_morphism(lambda m: self._tensor_constructor_(
367
+ [phi(RM.monomial(k)) for k in m.to_word_list()]),
368
+ codomain=self)
369
+
370
+ # Coercions from tensor products
371
+ if (R in Modules(self_base_ring).WithBasis().TensorProducts()
372
+ and isinstance(R, CombinatorialFreeModule_Tensor)
373
+ and all(M.has_coerce_map_from(RM) for RM in R._sets)):
374
+ modules = R._sets
375
+ vector_map = [M.coerce_map_from(RM) for RM in R._sets]
376
+ return R.module_morphism(lambda x: self._tensor_constructor_(
377
+ [vector_map[i](M.monomial(x[i]))
378
+ for i,M in enumerate(modules)]),
379
+ codomain=self)
380
+
381
+ return super()._coerce_map_from_(R)
382
+
383
+ def construction(self):
384
+ """
385
+ Return the functorial construction of ``self``.
386
+
387
+ EXAMPLES::
388
+
389
+ sage: C = CombinatorialFreeModule(ZZ, ['a','b','c'])
390
+ sage: TA = TensorAlgebra(C)
391
+ sage: f, M = TA.construction()
392
+ sage: M == C
393
+ True
394
+ sage: f(M) == TA
395
+ True
396
+ """
397
+ return (TensorAlgebraFunctor(self.category().base()), self._base_module)
398
+
399
+ def degree_on_basis(self, m):
400
+ """
401
+ Return the degree of the simple tensor ``m``, which is its length
402
+ (thought of as an element in the free monoid).
403
+
404
+ EXAMPLES::
405
+
406
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
407
+ sage: TA = TensorAlgebra(C)
408
+ sage: s = TA(['a','b','c']).leading_support(); s
409
+ F['a']*F['b']*F['c']
410
+ sage: TA.degree_on_basis(s)
411
+ 3
412
+ """
413
+ return m.length()
414
+
415
+ def base_module(self):
416
+ """
417
+ Return the base module of ``self``.
418
+
419
+ EXAMPLES::
420
+
421
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
422
+ sage: TA = TensorAlgebra(C)
423
+ sage: TA.base_module() is C
424
+ True
425
+ """
426
+ return self._base_module
427
+
428
+ @cached_method
429
+ def one_basis(self):
430
+ r"""
431
+ Return the empty word, which indexes the `1` of this algebra.
432
+
433
+ EXAMPLES::
434
+
435
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
436
+ sage: TA = TensorAlgebra(C)
437
+ sage: TA.one_basis()
438
+ 1
439
+ sage: TA.one_basis().parent()
440
+ Free monoid indexed by {'a', 'b', 'c'}
441
+ sage: m = SymmetricFunctions(QQ).m()
442
+ sage: Tm = TensorAlgebra(m)
443
+ sage: Tm.one_basis()
444
+ 1
445
+ sage: Tm.one_basis().parent()
446
+ Free monoid indexed by Partitions
447
+ """
448
+ return self._indices.one()
449
+
450
+ @cached_method
451
+ def algebra_generators(self):
452
+ r"""
453
+ Return the generators of this algebra.
454
+
455
+ EXAMPLES::
456
+
457
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
458
+ sage: TA = TensorAlgebra(C)
459
+ sage: TA.algebra_generators()
460
+ Finite family {'a': B['a'], 'b': B['b'], 'c': B['c']}
461
+ sage: m = SymmetricFunctions(QQ).m()
462
+ sage: Tm = TensorAlgebra(m)
463
+ sage: Tm.algebra_generators()
464
+ Lazy family (generator(i))_{i in Partitions}
465
+ """
466
+ return Family(self._indices.indices(),
467
+ lambda i: self.monomial(self._indices.gen(i)),
468
+ name='generator')
469
+
470
+ gens = algebra_generators
471
+
472
+ def product_on_basis(self, a, b):
473
+ r"""
474
+ Return the product of the basis elements indexed by ``a`` and
475
+ ``b``, as per
476
+ :meth:`AlgebrasWithBasis.ParentMethods.product_on_basis()`.
477
+
478
+ INPUT:
479
+
480
+ - ``a``, ``b`` -- basis indices
481
+
482
+ EXAMPLES::
483
+
484
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
485
+ sage: TA = TensorAlgebra(C)
486
+ sage: I = TA.indices()
487
+ sage: g = I.gens()
488
+ sage: TA.product_on_basis(g['a']*g['b'], g['a']*g['c'])
489
+ B['a'] # B['b'] # B['a'] # B['c']
490
+ """
491
+ return self.monomial(a * b)
492
+
493
+ def counit(self, x):
494
+ """
495
+ Return the counit of ``x``.
496
+
497
+ INPUT:
498
+
499
+ - ``x`` -- an element of ``self``
500
+
501
+ EXAMPLES::
502
+
503
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
504
+ sage: TA = TensorAlgebra(C)
505
+ sage: x = TA(['a','b','c'])
506
+ sage: TA.counit(x)
507
+ 0
508
+ sage: TA.counit(x + 3)
509
+ 3
510
+ """
511
+ return x[self.one_basis()]
512
+
513
+ def antipode_on_basis(self, m):
514
+ """
515
+ Return the antipode of the simple tensor indexed by ``m``.
516
+
517
+ EXAMPLES::
518
+
519
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
520
+ sage: TA = TensorAlgebra(C)
521
+ sage: s = TA(['a','b','c']).leading_support()
522
+ sage: TA.antipode_on_basis(s)
523
+ -B['c'] # B['b'] # B['a']
524
+ sage: t = TA(['a', 'b', 'b', 'b']).leading_support()
525
+ sage: TA.antipode_on_basis(t)
526
+ B['b'] # B['b'] # B['b'] # B['a']
527
+ """
528
+ m = self._indices(reversed(m._monomial))
529
+ R = self.base_ring()
530
+ if len(m) % 2 == 1:
531
+ return self.term(m, -R.one())
532
+ else:
533
+ return self.term(m, R.one())
534
+
535
+ def coproduct_on_basis(self, m):
536
+ r"""
537
+ Return the coproduct of the simple tensor indexed by ``m``.
538
+
539
+ EXAMPLES::
540
+
541
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
542
+ sage: TA = TensorAlgebra(C, tensor_symbol="(X)")
543
+ sage: TA.coproduct_on_basis(TA.one_basis())
544
+ 1 # 1
545
+ sage: I = TA.indices()
546
+ sage: ca = TA.coproduct_on_basis(I.gen('a')); ca
547
+ 1 # B['a'] + B['a'] # 1
548
+ sage: s = TA(['a','b','c']).leading_support()
549
+ sage: cp = TA.coproduct_on_basis(s); cp
550
+ 1 # B['a'](X)B['b'](X)B['c'] + B['a'] # B['b'](X)B['c']
551
+ + B['a'](X)B['b'] # B['c'] + B['a'](X)B['b'](X)B['c'] # 1
552
+ + B['a'](X)B['c'] # B['b'] + B['b'] # B['a'](X)B['c']
553
+ + B['b'](X)B['c'] # B['a'] + B['c'] # B['a'](X)B['b']
554
+
555
+ We check that `\Delta(a \otimes b \otimes c) =
556
+ \Delta(a) \Delta(b) \Delta(c)`::
557
+
558
+ sage: cb = TA.coproduct_on_basis(I.gen('b'))
559
+ sage: cc = TA.coproduct_on_basis(I.gen('c'))
560
+ sage: cp == ca * cb * cc
561
+ True
562
+ """
563
+ S = self.tensor_square()
564
+ if len(m) == 0:
565
+ return S.one()
566
+
567
+ if len(m) == 1:
568
+ ob = self.one_basis()
569
+ return S.sum_of_monomials([(m, ob), (ob, m)])
570
+
571
+ I = self._indices
572
+ m_word = [k for k,e in m._monomial for dummy in range(e)]
573
+ ob = self.one_basis()
574
+ return S.prod(S.sum_of_monomials([(I.gen(x), ob), (ob, I.gen(x))])
575
+ for x in m_word)
576
+
577
+ # TODO: Implement a coproduct using shuffles.
578
+ # This isn't quite right:
579
+ #from sage.combinat.words.word import Word
580
+ #k = len(m)
581
+ #return S.sum_of_monomials( (I.prod(I.gen(m_word[i]) for i in w[:p]),
582
+ # I.prod(I.gen(m_word[i]) for i in w[p:]))
583
+ # for p in range(k+1)
584
+ # for w in Word(range(p)).shuffle(range(p, k)) )
585
+
586
+ #####################################################################
587
+ # TensorAlgebra functor
588
+
589
+
590
+ class TensorAlgebraFunctor(ConstructionFunctor):
591
+ r"""
592
+ The tensor algebra functor.
593
+
594
+ Let `R` be a unital ring. Let `V_R` and `A_R` be the categories of
595
+ `R`-modules and `R`-algebras respectively. The functor
596
+ `T : V_R \to A_R` sends an `R`-module `M` to the tensor
597
+ algebra `T(M)`. The functor `T` is left-adjoint to the forgetful
598
+ functor `F : A_R \to V_R`.
599
+
600
+ INPUT:
601
+
602
+ - ``base`` -- the base `R`
603
+ """
604
+ # We choose a larger (functor) rank than most ConstructionFunctors
605
+ # since this should be applied after all of the module functors
606
+ rank = 20
607
+
608
+ def __init__(self, base):
609
+ """
610
+ Initialize ``self``.
611
+
612
+ EXAMPLES::
613
+
614
+ sage: from sage.algebras.tensor_algebra import TensorAlgebraFunctor
615
+ sage: F = TensorAlgebraFunctor(Rings())
616
+ sage: TestSuite(F).run()
617
+ """
618
+ ConstructionFunctor.__init__(self, Modules(base), Algebras(base))
619
+
620
+ def _repr_(self):
621
+ """
622
+ Return a string representation of ``self``.
623
+
624
+ EXAMPLES::
625
+
626
+ sage: from sage.algebras.tensor_algebra import TensorAlgebraFunctor
627
+ sage: TensorAlgebraFunctor(Rings())
628
+ Tensor algebra functor on modules over rings
629
+ sage: TensorAlgebraFunctor(QQ)
630
+ Tensor algebra functor on vector spaces over Rational Field
631
+ """
632
+ return "Tensor algebra functor on {}".format(self.domain()._repr_object_names())
633
+
634
+ def _apply_functor(self, M):
635
+ """
636
+ Construct the tensor algebra `T(M)`.
637
+
638
+ EXAMPLES::
639
+
640
+ sage: from sage.algebras.tensor_algebra import TensorAlgebraFunctor
641
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
642
+ sage: F = TensorAlgebraFunctor(QQ)
643
+ sage: F._apply_functor(C)
644
+ Tensor Algebra of Free module generated by {'a', 'b', 'c'} over Rational Field
645
+ """
646
+ if M not in self.domain().WithBasis():
647
+ raise NotImplementedError("currently only for modules with basis")
648
+ return TensorAlgebra(M)
649
+
650
+ def _apply_functor_to_morphism(self, f):
651
+ """
652
+ Apply ``self`` to a morphism ``f`` in the domain of ``self``.
653
+
654
+ EXAMPLES::
655
+
656
+ sage: from sage.algebras.tensor_algebra import TensorAlgebraFunctor
657
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
658
+ sage: D = CombinatorialFreeModule(QQ, ['x','y'])
659
+ sage: on_basis = lambda m: C.term('a', 2) + C.monomial('b') if m == 'x' else sum(C.basis())
660
+ sage: phi = D.module_morphism(on_basis, codomain=C); phi
661
+ Generic morphism:
662
+ From: Free module generated by {'x', 'y'} over Rational Field
663
+ To: Free module generated by {'a', 'b', 'c'} over Rational Field
664
+ sage: list(map(phi, D.basis()))
665
+ [2*B['a'] + B['b'], B['a'] + B['b'] + B['c']]
666
+ sage: F = TensorAlgebraFunctor(QQ)
667
+ sage: Tphi = F._apply_functor_to_morphism(phi); Tphi
668
+ Generic morphism:
669
+ From: Tensor Algebra of Free module generated by {'x', 'y'} over Rational Field
670
+ To: Tensor Algebra of Free module generated by {'a', 'b', 'c'} over Rational Field
671
+ sage: G = F(D).algebra_generators()
672
+ sage: list(map(Tphi, G))
673
+ [2*B['a'] + B['b'], B['a'] + B['b'] + B['c']]
674
+ sage: Tphi(sum(G))
675
+ 3*B['a'] + 2*B['b'] + B['c']
676
+ sage: Tphi(G['x'] * G['y'])
677
+ 2*B['a'] # B['a'] + 2*B['a'] # B['b'] + 2*B['a'] # B['c']
678
+ + B['b'] # B['a'] + B['b'] # B['b'] + B['b'] # B['c']
679
+ """
680
+ DB = f.domain()
681
+ D = self(DB)
682
+ C = self(f.codomain())
683
+ phi = lambda m: C._tensor_constructor_([f(DB.monomial(k))
684
+ for k in m.to_word_list()])
685
+ return D.module_morphism(phi, codomain=C)
686
+
687
+ #####################################################################
688
+ # Lift map from the base ring
689
+
690
+
691
+ class BaseRingLift(Morphism):
692
+ r"""
693
+ Morphism `R \to T(M)` which identifies the base ring `R` of a tensor
694
+ algebra `T(M)` with the `0`-th graded part of `T(M)`.
695
+ """
696
+ def _call_(self, x):
697
+ """
698
+ Construct the image of ``x``.
699
+
700
+ TESTS::
701
+
702
+ sage: C = CombinatorialFreeModule(QQ, Set([1,2]))
703
+ sage: TA = TensorAlgebra(C)
704
+ sage: TA(ZZ(2))
705
+ 2
706
+ """
707
+ T = self.codomain()
708
+ R = T.base_ring()
709
+ return T.term(T.indices().one(), R(x))