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,1870 @@
1
+ # sage_setup: distribution = sagemath-combinat
2
+ # sage.doctest: needs sage.combinat sage.graphs sage.modules
3
+ """
4
+ Tensor products of crystal elements
5
+
6
+ AUTHORS:
7
+
8
+ - Anne Schilling, Nicolas Thiery (2007): initial version
9
+ - Ben Salisbury, Travis Scrimshaw (2013): refactored tensor products to handle
10
+ non-regular crystals and created new subclass to take advantage of
11
+ the regularity
12
+ - Travis Scrimshaw (2017): cythonized element classes
13
+ - Franco Saliola (2017): tensor products for crystal of super algebras
14
+ - Anne Schilling (2018): tensor products for crystals of queer super algebras
15
+ """
16
+ #*****************************************************************************
17
+ # Copyright (C) 2007 Anne Schilling <anne at math.ucdavis.edu>
18
+ # Nicolas Thiery <nthiery at users.sf.net>
19
+ # 2017 Franco Saliola <saliola@gmail.com>
20
+ # 2017 Travis Scrimshaw <tcscrims at gmail.com>
21
+ #
22
+ # Distributed under the terms of the GNU General Public License (GPL)
23
+ #
24
+ # This code is distributed in the hope that it will be useful,
25
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27
+ # General Public License for more details.
28
+ #
29
+ # The full text of the GPL is available at:
30
+ #
31
+ # https://www.gnu.org/licenses/
32
+ #****************************************************************************
33
+
34
+ from sage.structure.parent cimport Parent
35
+
36
+ from sage.misc.cachefunc import cached_method, cached_in_parent_method
37
+ from sage.combinat.tableau import Tableau
38
+ from sage.rings.integer_ring import ZZ
39
+
40
+ ##############################################################################
41
+ # Support classes
42
+ ##############################################################################
43
+
44
+ cdef class ImmutableListWithParent(ClonableArray):
45
+ r"""
46
+ A class for lists having a parent.
47
+
48
+ Specification: any subclass ``C`` should implement ``__init__`` which
49
+ accepts the following form ``C(parent, list=list)``
50
+ """
51
+ def __init__(self, Parent parent, list):
52
+ """
53
+ Initialize ``self``.
54
+
55
+ TESTS::
56
+
57
+ sage: b = crystals.Tableaux(['A',2], shape=[2,1]).module_generators[0]
58
+ sage: TestSuite(b).run()
59
+ """
60
+ ClonableArray.__init__(self, parent, list, check=False)
61
+
62
+ def __setstate__(self, state):
63
+ """
64
+ For unpickling old pickles.
65
+
66
+ EXAMPLES::
67
+
68
+ sage: T = crystals.Tableaux(['A',2], shape=[2,1])
69
+ sage: b = T.module_generators[0]
70
+ sage: b.__setstate__([T, {'_list': list(b)}])
71
+ """
72
+ self._parent = state[0]
73
+ self._list = state[1]['_list']
74
+ self._is_immutable = True
75
+ self._hash = 0
76
+
77
+ cpdef _set_index(self, k, value):
78
+ r"""
79
+ Return a sibling of ``self`` obtained by setting the
80
+ `k`-th entry of ``self`` to value.
81
+
82
+ EXAMPLES::
83
+
84
+ sage: b = crystals.Tableaux(['A',2], shape=[3]).module_generators[0]
85
+ sage: list(b._set_index(0, 2))
86
+ [2, 1, 1]
87
+ sage: list(b._set_index(1, 4))
88
+ [1, 4, 1]
89
+ """
90
+ cdef list l = list(self._list) # Make a (shallow) copy
91
+ l[k] = value
92
+ return type(self)(self._parent, list=l)
93
+
94
+ ##############################################################################
95
+ # Primary classes
96
+ ##############################################################################
97
+
98
+ cdef class TensorProductOfCrystalsElement(ImmutableListWithParent):
99
+ r"""
100
+ A class for elements of tensor products of crystals.
101
+ """
102
+ def _repr_(self):
103
+ """
104
+ Return a string representation of ``self``.
105
+
106
+ EXAMPLES::
107
+
108
+ sage: C = crystals.Letters(['A',3])
109
+ sage: T = crystals.TensorProduct(C,C)
110
+ sage: T(C(1),C(2))
111
+ [1, 2]
112
+ """
113
+ if self._parent.options.convention == "Kashiwara":
114
+ return repr(list(reversed(self._list)))
115
+ return repr(self._list)
116
+
117
+ def _latex_(self):
118
+ r"""
119
+ Return latex code for ``self``.
120
+
121
+ EXAMPLES::
122
+
123
+ sage: C = crystals.Letters(["A",2])
124
+ sage: D = crystals.Tableaux(["A",2], shape=[2])
125
+ sage: E = crystals.TensorProduct(C,D)
126
+ sage: latex(E.module_generators[0])
127
+ 1 \otimes {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
128
+ \raisebox{-.6ex}{$\begin{array}[b]{*{2}c}\cline{1-2}
129
+ \lr{1}&\lr{1}\\\cline{1-2}
130
+ \end{array}$}
131
+ }
132
+ """
133
+ from sage.misc.latex import latex
134
+ if self._parent.options.convention == "Kashiwara":
135
+ return r' \otimes '.join(latex(c) for c in reversed(self))
136
+ return r' \otimes '.join(latex(c) for c in self)
137
+
138
+ def _ascii_art_(self):
139
+ """
140
+ Return an ASCII art representation of ``self``.
141
+
142
+ EXAMPLES::
143
+
144
+ sage: KT = crystals.TensorProductOfKirillovReshetikhinTableaux(['D',4,1],[[3,3],[2,1],[1,2]])
145
+ sage: ascii_art(KT.module_generators[0])
146
+ 1 1 1
147
+ 2 2 2 # 1 # 1 1
148
+ 3 3 3 2
149
+ -4 -4 -4
150
+ """
151
+ if self._parent.options.convention == "Kashiwara":
152
+ lst = list(reversed(self))
153
+ else:
154
+ lst = self
155
+ from sage.typeset.ascii_art import ascii_art, AsciiArt
156
+ s = ascii_art(lst[0])
157
+ s._baseline = s._h // 2
158
+ ret = s
159
+ for tableau in lst[1:]:
160
+ s = ascii_art(tableau)
161
+ s._baseline = s._h // 2
162
+ ret += AsciiArt([" # "]) + s
163
+ return ret
164
+
165
+ def _unicode_art_(self):
166
+ """
167
+ Return a unicode art representation of ``self``.
168
+
169
+ EXAMPLES::
170
+
171
+ sage: KT = crystals.TensorProductOfKirillovReshetikhinTableaux(['D',4,1],[[3,3],[2,1],[1,2]])
172
+ sage: unicode_art(KT.module_generators[0])
173
+ ┌───┬───┬───┐
174
+ │ 1 │ 1 │ 1 │
175
+ ├───┼───┼───┤ ┌───┐
176
+ │ 2 │ 2 │ 2 │ │ 1 │ ┌───┬───┐
177
+ ├───┼───┼───┤ ⊗ ├───┤ ⊗ │ 1 │ 1 │
178
+ │ 3 │ 3 │ 3 │ │ 2 │ └───┴───┘
179
+ ├───┼───┼───┤ └───┘
180
+ │ 4̄ │ 4̄ │ 4̄ │
181
+ └───┴───┴───┘
182
+ """
183
+ if self._parent.options.convention == "Kashiwara":
184
+ lst = list(reversed(self))
185
+ else:
186
+ lst = self
187
+ from sage.typeset.unicode_art import unicode_art, UnicodeArt
188
+ s = unicode_art(lst[0])
189
+ s._baseline = s._h // 2
190
+ ret = s
191
+ for tableau in lst[1:]:
192
+ s = unicode_art(tableau)
193
+ s._baseline = s._h // 2
194
+ ret += UnicodeArt([u" ⊗ "]) + s
195
+ return ret
196
+
197
+ def _repr_diagram(self):
198
+ r"""
199
+ Return a string representation of ``self`` as a diagram.
200
+
201
+ EXAMPLES::
202
+
203
+ sage: C = crystals.Tableaux(['A',3], shape=[3,1])
204
+ sage: D = crystals.Tableaux(['A',3], shape=[1])
205
+ sage: E = crystals.Tableaux(['A',3], shape=[2,2,2])
206
+ sage: T = crystals.TensorProduct(C,D,E)
207
+ sage: print(T.module_generators[0]._repr_diagram())
208
+ 1 1 1 (X) 1 (X) 1 1
209
+ 2 2 2
210
+ 3 3
211
+ """
212
+ pplist = []
213
+ max_widths = []
214
+ num_cols = len(self._list)
215
+ for c in self:
216
+ try:
217
+ pplist.append(c._repr_diagram().split('\n'))
218
+ except AttributeError:
219
+ pplist.append(c._repr_().split('\n'))
220
+ max_widths.append(max(map(len, pplist[-1])))
221
+ num_rows = max(map(len, pplist))
222
+ ret = ""
223
+ for i in range(num_rows):
224
+ if i > 0:
225
+ ret += '\n'
226
+ for j in range(num_cols):
227
+ if j > 0:
228
+ if i == 0:
229
+ ret += ' (X) '
230
+ else:
231
+ ret += ' '
232
+ if i < len(pplist[j]):
233
+ ret += pplist[j][i]
234
+ ret += ' '*(max_widths[j] - len(pplist[j][i]))
235
+ else:
236
+ ret += ' '*max_widths[j]
237
+ return ret
238
+
239
+ def pp(self):
240
+ """
241
+ Pretty print ``self``.
242
+
243
+ EXAMPLES::
244
+
245
+ sage: C = crystals.Tableaux(['A',3], shape=[3,1])
246
+ sage: D = crystals.Tableaux(['A',3], shape=[1])
247
+ sage: E = crystals.Tableaux(['A',3], shape=[2,2,2])
248
+ sage: T = crystals.TensorProduct(C,D,E)
249
+ sage: T.module_generators[0].pp()
250
+ 1 1 1 (X) 1 (X) 1 1
251
+ 2 2 2
252
+ 3 3
253
+ """
254
+ print(self._repr_diagram())
255
+
256
+ def weight(self):
257
+ r"""
258
+ Return the weight of ``self``.
259
+
260
+ EXAMPLES::
261
+
262
+ sage: B = crystals.infinity.Tableaux("A3")
263
+ sage: T = crystals.TensorProduct(B,B)
264
+ sage: b1 = B.highest_weight_vector().f_string([2,1,3])
265
+ sage: b2 = B.highest_weight_vector().f(1)
266
+ sage: t = T(b2, b1)
267
+ sage: t
268
+ [[[1, 1, 1, 2], [2, 2], [3]], [[1, 1, 1, 1, 2], [2, 2, 4], [3]]]
269
+ sage: t.weight()
270
+ (-2, 1, 0, 1)
271
+
272
+ ::
273
+
274
+ sage: C = crystals.Letters(['A',3])
275
+ sage: T = crystals.TensorProduct(C,C)
276
+ sage: T(C(1),C(2)).weight()
277
+ (1, 1, 0, 0)
278
+ sage: T = crystals.Tableaux(['D',4],shape=[])
279
+ sage: T.list()[0].weight()
280
+ (0, 0, 0, 0)
281
+ """
282
+ WLR = self._parent.weight_lattice_realization()
283
+ return WLR(sum(elt.weight() for elt in self))
284
+
285
+ def epsilon(self, i):
286
+ r"""
287
+ Return `\varepsilon_i` of ``self``.
288
+
289
+ INPUT:
290
+
291
+ - ``i`` -- an element of the index set
292
+
293
+ EXAMPLES::
294
+
295
+ sage: B = crystals.infinity.Tableaux("G2")
296
+ sage: T = crystals.TensorProduct(B,B)
297
+ sage: b1 = B.highest_weight_vector().f(2)
298
+ sage: b2 = B.highest_weight_vector().f_string([2,2,1])
299
+ sage: t = T(b2, b1)
300
+ sage: [t.epsilon(i) for i in B.index_set()]
301
+ [0, 3]
302
+ """
303
+ return max(self._sig(i, k) for k in range(1, len(self._list)+1))
304
+
305
+ def phi(self, i):
306
+ r"""
307
+ Return `\varphi_i` of ``self``.
308
+
309
+ INPUT:
310
+
311
+ - ``i`` -- an element of the index set
312
+
313
+ EXAMPLES::
314
+
315
+ sage: La = RootSystem(['A',2,1]).weight_lattice(extended=True).fundamental_weights()
316
+ sage: B = crystals.GeneralizedYoungWalls(2,La[0]+La[1])
317
+ sage: T = crystals.TensorProduct(B,B)
318
+ sage: b1 = B.highest_weight_vector().f_string([1,0])
319
+ sage: b2 = B.highest_weight_vector().f_string([0,1])
320
+ sage: t = T(b2, b1)
321
+ sage: [t.phi(i) for i in B.index_set()]
322
+ [1, 1, 4]
323
+
324
+ TESTS:
325
+
326
+ Check that :issue:`15462` is fixed::
327
+
328
+ sage: B = crystals.Tableaux(['A',2], shape=[2,1])
329
+ sage: La = RootSystem(['A',2]).ambient_space().fundamental_weights()
330
+ sage: T = crystals.TensorProduct(crystals.elementary.T(['A',2], La[1]+La[2]), B)
331
+ sage: t = T.an_element()
332
+ sage: t.phi(1)
333
+ 2
334
+ sage: t.phi(2)
335
+ 2
336
+ """
337
+ P = self._list[-1].parent().weight_lattice_realization()
338
+ h = P.simple_coroots()
339
+ omega = P(self.weight()).scalar(h[i])
340
+ return max(omega + self._sig(i, k) for k in range(1, len(self._list)+1))
341
+
342
+ @cached_in_parent_method
343
+ def _sig(self, i, k):
344
+ r"""
345
+ Return `a_i(k)` of ``self``.
346
+
347
+ The value `a_i(k)` of a crystal `b = b_N \otimes \cdots \otimes b_1`
348
+ is defined as:
349
+
350
+ .. MATH::
351
+
352
+ a_i(k) = \varepsilon_i(b_k) - \sum_{j=1}^{k-1} \langle h_i,
353
+ \mathrm{wt}(b_j) \rangle
354
+
355
+ where `\mathrm{wt}` is the :meth:`weight` of `b_j`.
356
+
357
+ INPUT:
358
+
359
+ - ``i`` -- an element of the index set
360
+
361
+ - ``k`` -- the (1-based) index of the tensor factor of ``self``
362
+
363
+ EXAMPLES::
364
+
365
+ sage: B = crystals.infinity.GeneralizedYoungWalls(3)
366
+ sage: T = crystals.TensorProduct(B,B)
367
+ sage: b1 = B.highest_weight_vector().f_string([0,3,1])
368
+ sage: b2 = B.highest_weight_vector().f_string([3,2,1,0,2,3])
369
+ sage: t = T(b1, b2)
370
+ sage: [[t._sig(i,k) for k in range(1,len(t)+1)] for i in B.index_set()]
371
+ [[0, -1], [0, 0], [0, 1], [1, 2]]
372
+
373
+ TESTS:
374
+
375
+ Check that :issue:`18469` is fixed::
376
+
377
+ sage: E1 = crystals.elementary.B(['A',2], 1)
378
+ sage: E2 = crystals.elementary.B(['A',2], 2)
379
+ sage: T = crystals.TensorProduct(E1, E2)
380
+ sage: x = T(E1.module_generators[0], E2.module_generators[0]); x
381
+ [0, 0]
382
+ sage: [[x._sig(i,k) for k in range(1,3)] for i in T.index_set()]
383
+ [[-inf, 0], [0, -inf]]
384
+ sage: x.f(1)
385
+ [-1, 0]
386
+ sage: x.e(1)
387
+ [1, 0]
388
+ """
389
+ if k == 1:
390
+ return self._list[-1].epsilon(i)
391
+ ep = self._list[-k].epsilon(i)
392
+ if ep == float("-inf"):
393
+ return ep
394
+
395
+ P = self._list[-1].parent().weight_lattice_realization()
396
+ h = P.simple_coroots()
397
+ wt = P.sum(P(self._list[-j].weight()) for j in range(1, k))
398
+ return ep - wt.scalar(h[i])
399
+
400
+ def e(self, i):
401
+ r"""
402
+ Return the action of `e_i` on ``self``.
403
+
404
+ INPUT:
405
+
406
+ - ``i`` -- an element of the index set
407
+
408
+ EXAMPLES::
409
+
410
+ sage: B = crystals.infinity.Tableaux("D4")
411
+ sage: T = crystals.TensorProduct(B,B)
412
+ sage: b1 = B.highest_weight_vector().f_string([1,4,3])
413
+ sage: b2 = B.highest_weight_vector().f_string([2,2,3,1,4])
414
+ sage: t = T(b2, b1)
415
+ sage: t.e(1)
416
+ [[[1, 1, 1, 1, 1], [2, 2, 3, -3], [3]], [[1, 1, 1, 1, 2], [2, 2, 2], [3, -3]]]
417
+ sage: t.e(2)
418
+ sage: t.e(3)
419
+ [[[1, 1, 1, 1, 1, 2], [2, 2, 3, -4], [3]], [[1, 1, 1, 1, 2], [2, 2, 2], [3, -3]]]
420
+ sage: t.e(4)
421
+ [[[1, 1, 1, 1, 1, 2], [2, 2, 3, 4], [3]], [[1, 1, 1, 1, 2], [2, 2, 2], [3, -3]]]
422
+ """
423
+ N = len(self._list) + 1
424
+ for k in range(1, N):
425
+ if all(self._sig(i,k) > self._sig(i,j) for j in range(1, k)) and \
426
+ all(self._sig(i,k) >= self._sig(i,j) for j in range(k+1, N)):
427
+ crystal = self._list[-k].e(i)
428
+ if crystal is None:
429
+ return None
430
+ return self._set_index(-k, crystal)
431
+ return None
432
+
433
+ def f(self, i):
434
+ r"""
435
+ Return the action of `f_i` on ``self``.
436
+
437
+ INPUT:
438
+
439
+ - ``i`` -- an element of the index set
440
+
441
+ EXAMPLES::
442
+
443
+ sage: La = RootSystem(['A',3,1]).weight_lattice(extended=True).fundamental_weights()
444
+ sage: B = crystals.GeneralizedYoungWalls(3,La[0])
445
+ sage: T = crystals.TensorProduct(B,B,B)
446
+ sage: b1 = B.highest_weight_vector().f_string([0,3])
447
+ sage: b2 = B.highest_weight_vector().f_string([0])
448
+ sage: b3 = B.highest_weight_vector()
449
+ sage: t = T(b3, b2, b1)
450
+ sage: t.f(0)
451
+ [[[0]], [[0]], [[0, 3]]]
452
+ sage: t.f(1)
453
+ [[], [[0]], [[0, 3], [1]]]
454
+ sage: t.f(2)
455
+ [[], [[0]], [[0, 3, 2]]]
456
+ sage: t.f(3)
457
+ [[], [[0, 3]], [[0, 3]]]
458
+ """
459
+ N = len(self._list) + 1
460
+ for k in range(1, N):
461
+ if all(self._sig(i,k) >= self._sig(i,j) for j in range(1, k)) and \
462
+ all(self._sig(i,k) > self._sig(i,j) for j in range(k+1, N)):
463
+ crystal = self._list[-k].f(i)
464
+ if crystal is None:
465
+ return None
466
+ return self._set_index(-k, crystal)
467
+ return None
468
+
469
+
470
+ cdef class TensorProductOfRegularCrystalsElement(TensorProductOfCrystalsElement):
471
+ """
472
+ Element class for a tensor product of regular crystals.
473
+
474
+ TESTS::
475
+
476
+ sage: C = crystals.Letters(['A',2])
477
+ sage: T = crystals.TensorProduct(C, C)
478
+ sage: elt = T(C(1), C(2))
479
+ sage: from sage.combinat.crystals.tensor_product import TensorProductOfRegularCrystalsElement
480
+ sage: isinstance(elt, TensorProductOfRegularCrystalsElement)
481
+ True
482
+ """
483
+ def e(self, i):
484
+ """
485
+ Return the action of `e_i` on ``self``.
486
+
487
+ EXAMPLES::
488
+
489
+ sage: C = crystals.Letters(['A',5])
490
+ sage: T = crystals.TensorProduct(C,C)
491
+ sage: T(C(1),C(2)).e(1) == T(C(1),C(1))
492
+ True
493
+ sage: T(C(2),C(1)).e(1) is None
494
+ True
495
+ sage: T(C(2),C(2)).e(1) == T(C(1),C(2))
496
+ True
497
+ """
498
+ if i not in self.index_set():
499
+ raise ValueError("i must be in the index set")
500
+ k = self.position_of_first_unmatched_plus(i)
501
+ if k is None:
502
+ return None
503
+ return self._set_index(k, self._list[k].e(i))
504
+
505
+ def f(self, i):
506
+ """
507
+ Return the action of `f_i` on ``self``.
508
+
509
+ EXAMPLES::
510
+
511
+ sage: C = crystals.Letters(['A',5])
512
+ sage: T = crystals.TensorProduct(C,C)
513
+ sage: T(C(1),C(1)).f(1)
514
+ [1, 2]
515
+ sage: T(C(1),C(2)).f(1)
516
+ [2, 2]
517
+ sage: T(C(2),C(1)).f(1) is None
518
+ True
519
+ """
520
+ if i not in self.index_set():
521
+ raise ValueError("i must be in the index set")
522
+ k = self.position_of_last_unmatched_minus(i)
523
+ if k is None:
524
+ return None
525
+ return self._set_index(k, self._list[k].f(i))
526
+
527
+ def phi(self, i):
528
+ r"""
529
+ Return `\varphi_i` of ``self``.
530
+
531
+ EXAMPLES::
532
+
533
+ sage: C = crystals.Letters(['A',5])
534
+ sage: T = crystals.TensorProduct(C,C)
535
+ sage: T(C(1),C(1)).phi(1)
536
+ 2
537
+ sage: T(C(1),C(2)).phi(1)
538
+ 1
539
+ sage: T(C(2),C(1)).phi(1)
540
+ 0
541
+ """
542
+ height = 0
543
+ for elt in reversed(self._list):
544
+ plus = elt.epsilon(i)
545
+ minus = elt.phi(i)
546
+ if height - plus < 0:
547
+ height = minus
548
+ else:
549
+ height = height - plus + minus
550
+ return height
551
+
552
+ def epsilon(self, i):
553
+ r"""
554
+ Return `\varepsilon_i` of ``self``.
555
+
556
+ EXAMPLES::
557
+
558
+ sage: C = crystals.Letters(['A',5])
559
+ sage: T = crystals.TensorProduct(C,C)
560
+ sage: T(C(1),C(1)).epsilon(1)
561
+ 0
562
+ sage: T(C(1),C(2)).epsilon(1)
563
+ 1
564
+ sage: T(C(2),C(1)).epsilon(1)
565
+ 0
566
+ """
567
+ height = 0
568
+ for elt in self:
569
+ minus = elt.phi(i)
570
+ plus = elt.epsilon(i)
571
+ if height - minus < 0:
572
+ height = plus
573
+ else:
574
+ height = height - minus + plus
575
+ return height
576
+
577
+ cpdef position_of_last_unmatched_minus(self, i):
578
+ """
579
+ Return the position of the last unmatched `-` or ``None`` if
580
+ there is no unmatched `-`.
581
+
582
+ EXAMPLES::
583
+
584
+ sage: C = crystals.Letters(['A',5])
585
+ sage: T = crystals.TensorProduct(C,C)
586
+ sage: T(C(2),C(1)).position_of_last_unmatched_minus(1)
587
+ sage: T(C(1),C(2)).position_of_last_unmatched_minus(1)
588
+ 0
589
+ """
590
+ unmatched_minus = None
591
+ height = 0
592
+ cdef int j
593
+ for j,elt in enumerate(self):
594
+ plus = elt.epsilon(i)
595
+ minus = elt.phi(i)
596
+ if height - minus < 0:
597
+ unmatched_minus = j
598
+ height = plus
599
+ else:
600
+ height = height - minus + plus
601
+ return unmatched_minus
602
+
603
+ cpdef position_of_first_unmatched_plus(self, i):
604
+ """
605
+ Return the position of the first unmatched `+` or ``None`` if
606
+ there is no unmatched `+`.
607
+
608
+ EXAMPLES::
609
+
610
+ sage: C = crystals.Letters(['A',5])
611
+ sage: T = crystals.TensorProduct(C,C)
612
+ sage: T(C(2),C(1)).position_of_first_unmatched_plus(1)
613
+ sage: T(C(1),C(2)).position_of_first_unmatched_plus(1)
614
+ 1
615
+ """
616
+ unmatched_plus = None
617
+ height = 0
618
+ cdef int N = len(self._list) - 1
619
+ cdef int j
620
+ for j, elt in enumerate(reversed(self._list)):
621
+ plus = elt.epsilon(i)
622
+ minus = elt.phi(i)
623
+ if height - plus < 0:
624
+ unmatched_plus = N - j
625
+ height = minus
626
+ else:
627
+ height = height - plus + minus
628
+ return unmatched_plus
629
+
630
+ # Legacy function
631
+ def positions_of_unmatched_minus(self, i, dual=False, reverse=False):
632
+ """
633
+ EXAMPLES::
634
+
635
+ sage: C = crystals.Letters(['A',5])
636
+ sage: T = crystals.TensorProduct(C,C)
637
+ sage: T(C(2),C(1)).positions_of_unmatched_minus(1)
638
+ []
639
+ sage: T(C(1),C(2)).positions_of_unmatched_minus(1)
640
+ [0]
641
+ """
642
+ cdef list unmatched_plus = []
643
+ cdef int j
644
+ height = 0
645
+ if reverse:
646
+ self = type(self)(self._parent, list(reversed(self._list)))
647
+ if not dual:
648
+ for j,elt in enumerate(self):
649
+ minus = elt.phi(i)
650
+ plus = elt.epsilon(i)
651
+ if height-minus < 0:
652
+ unmatched_plus.append(j)
653
+ height = plus
654
+ else:
655
+ height = height - minus + plus
656
+ else:
657
+ for j,elt in enumerate(self):
658
+ plus = elt.epsilon(i)
659
+ minus = elt.phi(i)
660
+ if height-plus < 0:
661
+ unmatched_plus.append(j)
662
+ height = minus
663
+ else:
664
+ height = height - plus + minus
665
+ return unmatched_plus
666
+
667
+ # Legacy function
668
+ def positions_of_unmatched_plus(self, i):
669
+ """
670
+ EXAMPLES::
671
+
672
+ sage: C = crystals.Letters(['A',5])
673
+ sage: T = crystals.TensorProduct(C,C)
674
+ sage: T(C(2),C(1)).positions_of_unmatched_plus(1)
675
+ []
676
+ sage: T(C(1),C(2)).positions_of_unmatched_plus(1)
677
+ [1]
678
+ """
679
+ cdef list L = self.positions_of_unmatched_minus(i, dual=True, reverse=True)
680
+ L.reverse()
681
+ cdef int N = len(self._list) - 1
682
+ return [N - val for val in L]
683
+
684
+ cdef class CrystalOfTableauxElement(TensorProductOfRegularCrystalsElement):
685
+ """
686
+ Element in a crystal of tableaux.
687
+ """
688
+ def __init__(self, parent, *args, **options):
689
+ """
690
+ There are several ways to input tableaux, by rows, by columns,
691
+ by columns, as the list of column elements, or as a sequence
692
+ of numbers in column reading.
693
+
694
+ EXAMPLES::
695
+
696
+ sage: T = crystals.Tableaux(['A',3], shape = [2,2])
697
+ sage: t = T(rows=[[1,2],[3,4]])
698
+ sage: t
699
+ [[1, 2], [3, 4]]
700
+ sage: TestSuite(t).run()
701
+
702
+ sage: t = T(columns=[[3,1],[4,2]])
703
+ sage: t
704
+ [[1, 2], [3, 4]]
705
+ sage: TestSuite(t).run()
706
+
707
+ sage: t = T(list=[3,1,4,2])
708
+ sage: t
709
+ [[1, 2], [3, 4]]
710
+
711
+ sage: t = T(3,1,4,2)
712
+ sage: t
713
+ [[1, 2], [3, 4]]
714
+
715
+ Currently inputting the empty tableau as an empty sequence is
716
+ broken due to a bug in the generic __call__ method (see :issue:`8648`).
717
+
718
+ EXAMPLES::
719
+
720
+ sage: T = crystals.Tableaux(['A',3], shape=[])
721
+ sage: t = T()
722
+ sage: list(t)
723
+ [0]
724
+
725
+ TESTS:
726
+
727
+ Integer types that are not a Sage ``Integer`` (such as a Python ``int``
728
+ and typically arise from compiled code) were not converted into a
729
+ letter. This caused certain functions to fail. This is fixed in
730
+ :issue:`13204`::
731
+
732
+ sage: T = crystals.Tableaux(['A',3], shape = [2,2])
733
+ sage: t = T(list=[int(3),1,4,2])
734
+ sage: type(t[0])
735
+ <class 'sage.combinat.crystals.letters.Crystal_of_letters_type_A_element'>
736
+ sage: t = T(list=[3,int(1),4,2])
737
+ sage: type(t[1])
738
+ <class 'sage.combinat.crystals.letters.Crystal_of_letters_type_A_element'>
739
+ sage: C = crystals.KirillovReshetikhin(['A',int(3),1], 1,1)
740
+ sage: C[0].e(0)
741
+ [[4]]
742
+ """
743
+ if len(args) == 1:
744
+ if isinstance(args[0], Tableau):
745
+ options['rows'] = args[0]
746
+ if 'list' in options:
747
+ the_list = options['list']
748
+ elif 'rows' in options:
749
+ rows = options['rows']
750
+ # the_list=Tableau(rows).to_word_by_column()
751
+ rows = Tableau(rows).conjugate()
752
+ the_list = []
753
+ for col in rows:
754
+ the_list += reversed(col)
755
+ elif 'columns' in options:
756
+ columns = options['columns']
757
+ the_list = []
758
+ for col in columns:
759
+ the_list += col
760
+ else:
761
+ the_list = [i for i in args]
762
+ TensorProductOfRegularCrystalsElement.__init__(self, parent,
763
+ [parent.letters(i)
764
+ for i in the_list])
765
+
766
+ def _repr_(self):
767
+ """
768
+ EXAMPLES::
769
+
770
+ sage: T = crystals.Tableaux(['A',3], shape = [2,2])
771
+ sage: t = T(rows=[[1,2],[3,4]])
772
+ sage: t._repr_()
773
+ '[[1, 2], [3, 4]]'
774
+ """
775
+ return repr(self.to_tableau())
776
+
777
+ def _repr_diagram(self):
778
+ """
779
+ Return a string representation of ``self`` as a diagram.
780
+
781
+ EXAMPLES::
782
+
783
+ sage: C = crystals.Tableaux(['A', 4], shape=[4,2,1])
784
+ sage: elt = C(rows=[[1,1,1,2], [2,3], [4]])
785
+ sage: print(elt._repr_diagram())
786
+ 1 1 1 2
787
+ 2 3
788
+ 4
789
+ """
790
+ return self.to_tableau()._repr_diagram()
791
+
792
+ def pp(self):
793
+ """
794
+ EXAMPLES::
795
+
796
+ sage: T = crystals.Tableaux(['A',3], shape = [2,2])
797
+ sage: t = T(rows=[[1,2],[3,4]])
798
+ sage: t.pp()
799
+ 1 2
800
+ 3 4
801
+ """
802
+ return self.to_tableau().pp()
803
+
804
+ def _ascii_art_(self):
805
+ """
806
+ Return an ascii art version of ``self``.
807
+
808
+ EXAMPLES:
809
+
810
+ We check that :issue:`16486` is fixed::
811
+
812
+ sage: T = crystals.Tableaux(['B',6], shape=[1]*5)
813
+ sage: ascii_art(T.module_generators[0])
814
+ 1
815
+ 2
816
+ 3
817
+ 4
818
+ 5
819
+ sage: T = crystals.Tableaux(['D',4], shape=[2,1])
820
+ sage: t = T.module_generators[0].f_string([1,2,3,4,2,2,3,4])
821
+ sage: ascii_art(t)
822
+ 1 -2
823
+ -3
824
+ """
825
+ return self.to_tableau()._ascii_art_()
826
+
827
+ def _unicode_art_(self):
828
+ """
829
+ Return a unicode art version of ``self``.
830
+
831
+ EXAMPLES::
832
+
833
+ sage: T = crystals.Tableaux(['B',4], shape=[1]*3)
834
+ sage: unicode_art(T.module_generators[0])
835
+ ┌───┐
836
+ │ 1 │
837
+ ├───┤
838
+ │ 2 │
839
+ ├───┤
840
+ │ 3 │
841
+ └───┘
842
+ sage: T = crystals.Tableaux(['D',4], shape=[2,1])
843
+ sage: t = T.module_generators[0].f_string([1,2,3,4,2,2,3,4])
844
+ sage: unicode_art(t)
845
+ ┌───┬───┐
846
+ │ 1 │ 2̄ │
847
+ ├───┼───┘
848
+ │ 3̄ │
849
+ └───┘
850
+ """
851
+ if not self._list:
852
+ return Tableau([])._unicode_art_()
853
+ cdef list lst = self._list
854
+ cdef list tab = [ [lst[0]] ]
855
+ cdef int i
856
+ for i in range(1,len(self)):
857
+ if lst[i-1] < lst[i] or (lst[i-1].value != 0 and lst[i-1] == lst[i]):
858
+ tab.append([lst[i]])
859
+ else:
860
+ tab[len(tab)-1].append(lst[i])
861
+ for x in tab:
862
+ x.reverse()
863
+ return Tableau(tab).conjugate()._unicode_art_()
864
+
865
+ def _latex_(self):
866
+ r"""
867
+ EXAMPLES::
868
+
869
+ sage: T = crystals.Tableaux(['A',3], shape = [4,2])
870
+ sage: t = T(rows=[[1,1,2,3],[2,3]])
871
+ sage: latex(t) # indirect doctest
872
+ {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
873
+ \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\cline{1-4}
874
+ \lr{1}&\lr{1}&\lr{2}&\lr{3}\\\cline{1-4}
875
+ \lr{2}&\lr{3}\\\cline{1-2}
876
+ \end{array}$}
877
+ }
878
+ """
879
+ from sage.combinat.output import tex_from_array
880
+ # Modified version of to_tableau() to have the entries be letters
881
+ # rather than their values
882
+ if not self._list:
883
+ return "{\\emptyset}"
884
+
885
+ tab = [ [self[0]] ]
886
+ for i in range(1,len(self)):
887
+ if self[i-1] < self[i] or (self[i-1].value != 0 and self[i-1] == self[i]):
888
+ tab.append([self[i]])
889
+ else:
890
+ l = len(tab)-1
891
+ tab[l].append(self[i])
892
+ for x in tab:
893
+ x.reverse()
894
+ T = Tableau(tab).conjugate()
895
+ return tex_from_array([[letter._latex_() for letter in row] for row in T])
896
+
897
+ @cached_method
898
+ def to_tableau(self):
899
+ """
900
+ Return the :class:`Tableau` object corresponding to ``self``.
901
+
902
+ EXAMPLES::
903
+
904
+ sage: T = crystals.Tableaux(['A',3], shape = [2,2])
905
+ sage: t = T(rows=[[1,2],[3,4]]).to_tableau(); t
906
+ [[1, 2], [3, 4]]
907
+ sage: type(t)
908
+ <class 'sage.combinat.tableau.Tableaux_all_with_category.element_class'>
909
+ sage: type(t[0][0])
910
+ <class 'int'>
911
+ sage: T = crystals.Tableaux(['D',3], shape = [1,1])
912
+ sage: t=T(rows=[[-3],[3]]).to_tableau(); t
913
+ [[-3], [3]]
914
+ sage: t=T(rows=[[3],[-3]]).to_tableau(); t
915
+ [[3], [-3]]
916
+ sage: T = crystals.Tableaux(['B',2], shape = [1,1])
917
+ sage: t = T(rows=[[0],[0]]).to_tableau(); t
918
+ [[0], [0]]
919
+ """
920
+ if not self._list:
921
+ return Tableau([])
922
+ cdef list lst = self._list
923
+ cdef list tab = [ [lst[0].value] ]
924
+ cdef int i
925
+ for i in range(1,len(self)):
926
+ if lst[i-1] < lst[i] or (lst[i-1].value != 0 and lst[i-1] == lst[i]):
927
+ tab.append([lst[i].value])
928
+ else:
929
+ tab[len(tab)-1].append(lst[i].value)
930
+ for x in tab:
931
+ x.reverse()
932
+ return Tableau(tab).conjugate()
933
+
934
+ def shape(self):
935
+ r"""
936
+ Return the shape of the tableau corresponding to ``self``.
937
+
938
+ OUTPUT: an instance of :class:`Partition`
939
+
940
+ .. SEEALSO::
941
+
942
+ :meth:`to_tableau`
943
+
944
+ EXAMPLES::
945
+
946
+ sage: C = crystals.Tableaux(["A", 2], shape=[2,1])
947
+ sage: x = C.an_element()
948
+ sage: x.to_tableau().shape()
949
+ [2, 1]
950
+ sage: x.shape()
951
+ [2, 1]
952
+ """
953
+ return self.to_tableau().shape()
954
+
955
+ def promotion(self):
956
+ """
957
+ Return the result of applying promotion on ``self``.
958
+
959
+ Promotion for type A crystals of tableaux of rectangular shape.
960
+ This method only makes sense in type A with rectangular shapes.
961
+
962
+ EXAMPLES::
963
+
964
+ sage: C = crystals.Tableaux(["A",3], shape = [3,3,3])
965
+ sage: t = C(Tableau([[1,1,1],[2,2,3],[3,4,4]]))
966
+ sage: t
967
+ [[1, 1, 1], [2, 2, 3], [3, 4, 4]]
968
+ sage: t.promotion()
969
+ [[1, 1, 2], [2, 2, 3], [3, 4, 4]]
970
+ sage: t.promotion().parent()
971
+ The crystal of tableaux of type ['A', 3] and shape(s) [[3, 3, 3]]
972
+ """
973
+ crystal = self._parent
974
+ cartan_type = crystal.cartan_type()
975
+ assert cartan_type.type() == 'A'
976
+ return crystal(self.to_tableau().promotion(cartan_type.rank()))
977
+
978
+ def promotion_inverse(self):
979
+ """
980
+ Return the result of applying inverse promotion on ``self``.
981
+
982
+ Inverse promotion for type A crystals of tableaux of rectangular shape.
983
+ This method only makes sense in type A with rectangular shapes.
984
+
985
+ EXAMPLES::
986
+
987
+ sage: C = crystals.Tableaux(["A",3], shape = [3,3,3])
988
+ sage: t = C(Tableau([[1,1,1],[2,2,3],[3,4,4]]))
989
+ sage: t
990
+ [[1, 1, 1], [2, 2, 3], [3, 4, 4]]
991
+ sage: t.promotion_inverse()
992
+ [[1, 1, 2], [2, 3, 3], [4, 4, 4]]
993
+ sage: t.promotion_inverse().parent()
994
+ The crystal of tableaux of type ['A', 3] and shape(s) [[3, 3, 3]]
995
+ """
996
+ crystal = self._parent
997
+ cartan_type = crystal.cartan_type()
998
+ assert cartan_type.type() == 'A'
999
+ return crystal(self.to_tableau().promotion_inverse(cartan_type.rank()))
1000
+
1001
+ cdef class InfinityCrystalOfTableauxElement(CrystalOfTableauxElement):
1002
+ def e(self, i):
1003
+ r"""
1004
+ Return the action of `\widetilde{e}_i` on ``self``.
1005
+
1006
+ INPUT:
1007
+
1008
+ - ``i`` -- an element of the index set
1009
+
1010
+ EXAMPLES::
1011
+
1012
+ sage: B = crystals.infinity.Tableaux(['B',3])
1013
+ sage: b = B(rows=[[1,1,1,1,1,1,1,2,0,-3,-1,-1,-1,-1],[2,2,2,2,-2,-2],[3,-3,-3]])
1014
+ sage: b.e(3).pp()
1015
+ 1 1 1 1 1 1 1 2 0 -3 -1 -1 -1 -1
1016
+ 2 2 2 2 -2 -2
1017
+ 3 0 -3
1018
+ sage: b.e(1).pp()
1019
+ 1 1 1 1 1 1 1 0 -3 -1 -1 -1 -1
1020
+ 2 2 2 2 -2 -2
1021
+ 3 -3 -3
1022
+ """
1023
+ if i not in self.index_set():
1024
+ raise ValueError('i is not in the index set')
1025
+ k = self.position_of_first_unmatched_plus(i)
1026
+ if k is None:
1027
+ return None
1028
+ cdef InfinityCrystalOfTableauxElement ret
1029
+ ret = <InfinityCrystalOfTableauxElement>(self._set_index(k, self._list[k].e(i)))
1030
+ if k+i > len(self._list):
1031
+ return ret
1032
+ for j in reversed(range(1, i+1)):
1033
+ if ret._list[k+i-j].value != j:
1034
+ return ret
1035
+ # We've found a column, so we need to remove it
1036
+ for j in range(i):
1037
+ ret._list.pop(k)
1038
+ return ret
1039
+
1040
+ def f(self, i):
1041
+ r"""
1042
+ Return the action of `\widetilde{f}_i` on ``self``.
1043
+
1044
+ INPUT:
1045
+
1046
+ - ``i`` -- an element of the index set
1047
+
1048
+ EXAMPLES::
1049
+
1050
+ sage: B = crystals.infinity.Tableaux(['C',4])
1051
+ sage: b = B.highest_weight_vector()
1052
+ sage: b.f(1).pp()
1053
+ 1 1 1 1 2
1054
+ 2 2 2
1055
+ 3 3
1056
+ 4
1057
+ sage: b.f(3).pp()
1058
+ 1 1 1 1 1
1059
+ 2 2 2 2
1060
+ 3 3 4
1061
+ 4
1062
+ sage: b.f(3).f(4).pp()
1063
+ 1 1 1 1 1
1064
+ 2 2 2 2
1065
+ 3 3 -4
1066
+ 4
1067
+ """
1068
+ if i not in self.index_set():
1069
+ raise ValueError('i is not in the index set')
1070
+ k = self.position_of_last_unmatched_minus(i)
1071
+ if k is None:
1072
+ return None
1073
+ cdef InfinityCrystalOfTableauxElement ret
1074
+ ret = <InfinityCrystalOfTableauxElement>(self._set_index(k, self._list[k].f(i)))
1075
+ if k+i > len(self._list):
1076
+ return ret
1077
+ for j in reversed(range(1,i+1)):
1078
+ if self._list[k+i-j].value != j:
1079
+ return ret
1080
+ # We've found a full column, so we'll need to add a new column
1081
+ for j in range(i):
1082
+ ret._list.insert(k, self._parent.letters(j+1))
1083
+ return ret
1084
+
1085
+ cdef class InfinityCrystalOfTableauxElementTypeD(InfinityCrystalOfTableauxElement):
1086
+ def e(self, i):
1087
+ r"""
1088
+ Return the action of `\widetilde{e}_i` on ``self``.
1089
+
1090
+ INPUT:
1091
+
1092
+ - ``i`` -- an element of the index set
1093
+
1094
+ EXAMPLES::
1095
+
1096
+ sage: B = crystals.infinity.Tableaux(['D',4])
1097
+ sage: b = B.highest_weight_vector().f_string([1,4,3,1,2]); b.pp()
1098
+ 1 1 1 1 2 3
1099
+ 2 2 2
1100
+ 3 -3
1101
+ sage: b.e(2).pp()
1102
+ 1 1 1 1 2 2
1103
+ 2 2 2
1104
+ 3 -3
1105
+ """
1106
+ if i not in self.index_set():
1107
+ raise ValueError('i is not in the index set')
1108
+ k = self.position_of_first_unmatched_plus(i)
1109
+ if k is None:
1110
+ return None
1111
+ cdef InfinityCrystalOfTableauxElementTypeD ret
1112
+ ret = <InfinityCrystalOfTableauxElementTypeD>(self._set_index(k, self._list[k].e(i)))
1113
+ if i == self.cartan_type().rank():
1114
+ i -= 1
1115
+ if k+i > len(self._list):
1116
+ return ret
1117
+ for j in reversed(range(1, i+1)):
1118
+ if ret._list[k+i-j].value != j:
1119
+ return ret
1120
+ # We've found a column, so we need to remove it
1121
+ for j in range(i):
1122
+ ret._list.pop(k)
1123
+ return ret
1124
+
1125
+ def f(self, i):
1126
+ r"""
1127
+ Return the action of `\widetilde{f}_i` on ``self``.
1128
+
1129
+ INPUT:
1130
+
1131
+ - ``i`` -- an element of the index set
1132
+
1133
+ EXAMPLES::
1134
+
1135
+ sage: B = crystals.infinity.Tableaux(['D',5])
1136
+ sage: b = B.highest_weight_vector().f_string([1,4,3,1,5]); b.pp()
1137
+ 1 1 1 1 1 1 2 2
1138
+ 2 2 2 2 2
1139
+ 3 3 3 -5
1140
+ 4 5
1141
+ sage: b.f(1).pp()
1142
+ 1 1 1 1 1 1 2 2 2
1143
+ 2 2 2 2 2
1144
+ 3 3 3 -5
1145
+ 4 5
1146
+ sage: b.f(5).pp()
1147
+ 1 1 1 1 1 1 2 2
1148
+ 2 2 2 2 2
1149
+ 3 3 3 -5
1150
+ 4 -4
1151
+ """
1152
+ cdef InfinityCrystalOfTableauxElementTypeD ret
1153
+ ret = <InfinityCrystalOfTableauxElementTypeD>(InfinityCrystalOfTableauxElement.f(self, i))
1154
+ if ret._list[0].value == -self._parent.cartan_type().rank():
1155
+ # Exceptional case for f_n where we need to add a new column
1156
+ for j in range(i-1):
1157
+ ret._list.insert(0, self._parent.letters(j+1))
1158
+ return ret
1159
+
1160
+ #####################################################################
1161
+ # BKK crystal elements
1162
+
1163
+ cdef class TensorProductOfSuperCrystalsElement(TensorProductOfRegularCrystalsElement):
1164
+ r"""
1165
+ Element class for a tensor product of crystals for Lie superalgebras.
1166
+
1167
+ This implements the tensor product rule for crystals of
1168
+ Lie superalgebras of [BKK2000]_.
1169
+
1170
+ TESTS::
1171
+
1172
+ sage: C = crystals.Letters(['A', [2, 1]])
1173
+ sage: T = tensor([C,C])
1174
+ sage: T
1175
+ Full tensor product of the crystals [The crystal of letters for type ['A', [2, 1]], The crystal of letters for type ['A', [2, 1]]]
1176
+ sage: T.cardinality()
1177
+ 25
1178
+ sage: t = T.an_element(); t
1179
+ [-3, -3]
1180
+ sage: t.weight()
1181
+ (2, 0, 0, 0, 0)
1182
+ """
1183
+
1184
+ def e(self, i):
1185
+ r"""
1186
+ Return `e_i` on ``self``.
1187
+
1188
+ EXAMPLES::
1189
+
1190
+ sage: C = crystals.Letters(['A', [2, 1]])
1191
+ sage: T = tensor([C,C])
1192
+ sage: t = T(C(1),C(1))
1193
+ sage: t.e(0)
1194
+ [-1, 1]
1195
+ """
1196
+ if i > 0:
1197
+ return TensorProductOfRegularCrystalsElement.e(self, i)
1198
+ if i < 0:
1199
+ x = type(self)(self._parent, reversed(self))
1200
+ k = x.position_of_first_unmatched_plus(i)
1201
+ if k is None:
1202
+ return None
1203
+ k = len(self._list) - k - 1
1204
+ return self._set_index(k, self._list[k].e(i))
1205
+ # Otherwise i == 0
1206
+ for k,elt in enumerate(self._list):
1207
+ if elt.f(i) is not None:
1208
+ return None
1209
+ x = elt.e(i)
1210
+ if x is not None:
1211
+ return self._set_index(k, x)
1212
+ return None
1213
+
1214
+ def f(self, i):
1215
+ r"""
1216
+ Return `f_i` on ``self``.
1217
+
1218
+ EXAMPLES::
1219
+
1220
+ sage: C = crystals.Letters(['A', [2, 1]])
1221
+ sage: T = tensor([C,C])
1222
+ sage: t = T(C(1),C(1))
1223
+ sage: t.f(0)
1224
+ sage: t.f(1)
1225
+ [1, 2]
1226
+ """
1227
+ if i > 0:
1228
+ return TensorProductOfRegularCrystalsElement.f(self, i)
1229
+ if i < 0:
1230
+ x = type(self)(self._parent, reversed(self))
1231
+ k = x.position_of_last_unmatched_minus(i)
1232
+ if k is None:
1233
+ return None
1234
+ k = len(self._list) - k - 1
1235
+ return self._set_index(k, self._list[k].f(i))
1236
+ # Otherwise i == 0
1237
+ for k,elt in enumerate(self._list):
1238
+ if elt.e(i) is not None:
1239
+ return None
1240
+ x = elt.f(i)
1241
+ if x is not None:
1242
+ return self._set_index(k, x)
1243
+ return None
1244
+
1245
+ # Override epsilon/phi (for now)
1246
+ def epsilon(self, i):
1247
+ r"""
1248
+ Return `\varepsilon_i` on ``self``.
1249
+
1250
+ EXAMPLES::
1251
+
1252
+ sage: C = crystals.Letters(['A', [2, 1]])
1253
+ sage: T = tensor([C,C])
1254
+ sage: t = T(C(1),C(1))
1255
+ sage: t.epsilon(0)
1256
+ 1
1257
+ """
1258
+ string_length = 0
1259
+ x = self
1260
+ while True:
1261
+ x = x.e(i)
1262
+ if x is None:
1263
+ return string_length
1264
+ else:
1265
+ string_length += 1
1266
+
1267
+ def phi(self, i):
1268
+ r"""
1269
+ Return `\varphi_i` on ``self``.
1270
+
1271
+ EXAMPLES::
1272
+
1273
+ sage: C = crystals.Letters(['A', [2, 1]])
1274
+ sage: T = tensor([C,C])
1275
+ sage: t = T(C(1),C(1))
1276
+ sage: t.phi(0)
1277
+ 0
1278
+ """
1279
+ string_length = 0
1280
+ x = self
1281
+ while True:
1282
+ x = x.f(i)
1283
+ if x is None:
1284
+ return string_length
1285
+ else:
1286
+ string_length += 1
1287
+
1288
+ cdef class CrystalOfBKKTableauxElement(TensorProductOfSuperCrystalsElement):
1289
+ """
1290
+ Element class for the crystal of tableaux for Lie superalgebras
1291
+ of [BKK2000]_.
1292
+ """
1293
+ def _repr_(self):
1294
+ """
1295
+ Return a string representation of ``self``.
1296
+
1297
+ EXAMPLES::
1298
+
1299
+ sage: C = crystals.Tableaux(['A',[1,2]], shape=[1,1])
1300
+ sage: C.an_element()
1301
+ [[-2], [-1]]
1302
+ """
1303
+ return repr(self.to_tableau())
1304
+
1305
+ def _repr_diagram(self):
1306
+ r"""
1307
+ Return a string representation of ``self`` as a diagram.
1308
+
1309
+ EXAMPLES::
1310
+
1311
+ sage: C = crystals.Tableaux(['A',[1,2]], shape=[1,1])
1312
+ sage: c = C.an_element()
1313
+ sage: c._repr_diagram()
1314
+ ' -2\n -1'
1315
+ """
1316
+ return self.to_tableau()._repr_diagram()
1317
+
1318
+ def pp(self):
1319
+ """
1320
+ Pretty print ``self``.
1321
+
1322
+ EXAMPLES::
1323
+
1324
+ sage: C = crystals.Tableaux(['A',[1,2]], shape=[1,1])
1325
+ sage: c = C.an_element()
1326
+ sage: c.pp()
1327
+ -2
1328
+ -1
1329
+ """
1330
+ return self.to_tableau().pp()
1331
+
1332
+ def _ascii_art_(self):
1333
+ """
1334
+ Return an ascii art version of ``self``.
1335
+
1336
+ EXAMPLES::
1337
+
1338
+ sage: C = crystals.Tableaux(['A',[1,2]], shape=[1,1])
1339
+ sage: c = C.an_element()
1340
+ sage: ascii_art(c)
1341
+ -2
1342
+ -1
1343
+ """
1344
+ return self.to_tableau()._ascii_art_()
1345
+
1346
+ def _unicode_art_(self):
1347
+ """
1348
+ Return a unicode art version of ``self``.
1349
+
1350
+ EXAMPLES::
1351
+
1352
+ sage: C = crystals.Tableaux(['A',[1,2]], shape=[1,1])
1353
+ sage: c = C.an_element()
1354
+ sage: unicode_art(c)
1355
+ ┌───┐
1356
+ │ 2̄ │
1357
+ ├───┤
1358
+ │ 1̄ │
1359
+ └───┘
1360
+ """
1361
+ return self.to_tableau()._unicode_art_()
1362
+
1363
+ def _latex_(self):
1364
+ r"""
1365
+ Return the latex code of ``self``.
1366
+
1367
+ EXAMPLES::
1368
+
1369
+ sage: C = crystals.Tableaux(['A',[1,2]], shape=[1,1])
1370
+ sage: c = C.an_element()
1371
+ sage: latex(c)
1372
+ {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
1373
+ \raisebox{-.6ex}{$\begin{array}[b]{*{1}c}\cline{1-1}
1374
+ \lr{-2}\\\cline{1-1}
1375
+ \lr{-1}\\\cline{1-1}
1376
+ \end{array}$}
1377
+ }
1378
+ """
1379
+ return self.to_tableau()._latex_()
1380
+
1381
+ @cached_method
1382
+ def to_tableau(self):
1383
+ """
1384
+ Return the :class:`Tableau` object corresponding to ``self``.
1385
+
1386
+ EXAMPLES::
1387
+
1388
+ sage: C = crystals.Tableaux(['A',[1,2]], shape=[1,1])
1389
+ sage: c = C.an_element()
1390
+ sage: c.to_tableau()
1391
+ [[-2], [-1]]
1392
+ sage: type(c.to_tableau())
1393
+ <class 'sage.combinat.tableau.Tableaux_all_with_category.element_class'>
1394
+ sage: type(c)
1395
+ <class 'sage.combinat.crystals.bkk_crystals.CrystalOfBKKTableaux_with_category.element_class'>
1396
+ """
1397
+ sh = self._parent._shape.conjugate()
1398
+ tab = [[None]*row for row in sh]
1399
+ cur = 0
1400
+ lst = list(reversed(self._list))
1401
+ for r,row_len in enumerate(sh):
1402
+ for c in reversed(range(row_len)):
1403
+ tab[r][c] = lst[cur]
1404
+ cur += 1
1405
+ return Tableau(tab).conjugate()
1406
+
1407
+ #####################################################################
1408
+ # Queer crystal elements
1409
+
1410
+ cdef class TensorProductOfQueerSuperCrystalsElement(TensorProductOfRegularCrystalsElement):
1411
+ r"""
1412
+ Element class for a tensor product of crystals for queer Lie superalgebras.
1413
+
1414
+ This implements the tensor product rule for crystals of Grantcharov et al.
1415
+ [GJK+2014]_. Given crystals `B_1` and `B_2` of type `\mathfrak{q}_{n+1}`,
1416
+ we define the tensor product `b_1 \otimes b_2 \in B_1 \otimes B_2`,
1417
+ where `b_1 \in B_1` and `b_2 \in B_2`, as the following:
1418
+
1419
+ In addition to the tensor product rule for type `A_n`, the tensor product
1420
+ rule for `e_{-1}` and `f_{-1}` on `b_1\otimes b_2` are given by
1421
+
1422
+ .. MATH::
1423
+
1424
+ \begin{aligned}
1425
+ e_{-1}(b_1\otimes b_2) &=
1426
+ \begin{cases}
1427
+ b_1 \otimes e_{-1}b_2 &
1428
+ \text{if } \operatorname{wt}(b_1)_1 = \operatorname{wt}(b_1)_2 = 0,\\
1429
+ e_{-1}b_1 \otimes b_2 & \text{otherwise},
1430
+ \end{cases}
1431
+ \\
1432
+ f_{-1}(b_1\otimes b_2) &=
1433
+ \begin{cases}
1434
+ b_1 \otimes f_{-1}b_2 &
1435
+ \text{if } \operatorname{wt}(b_1)_1 = \operatorname{wt}(b_1)_2 = 0,\\
1436
+ f_{-1}b_1 \otimes b_2 & \text{otherwise}.
1437
+ \end{cases}
1438
+ \end{aligned}
1439
+
1440
+ For `1 < i \leq n`, the operators `e_{-i}` and `f_{-i}` are defined as
1441
+
1442
+ .. MATH::
1443
+
1444
+ e_{-i} = s_{w^{-1}_i} e_{-1} s_{w_i}, \quad
1445
+ f_{-i} = s_{w^{-1}_i} f_{-1} s_{w_i}.
1446
+
1447
+ Here, `w_i = s_2 \cdots s_i s_1 \cdots s_{i-1}` and `s_i` is the reflection
1448
+ along the `i`-string in the crystal. Moreover, for `1<i\leq n`, we define
1449
+ the operators `e_{-i'}` and `f_{-i'}` as
1450
+
1451
+ .. MATH::
1452
+
1453
+ e_{-i'} = s_{w_0} f_{-(n+1-i)} s_{w_0}, \quad
1454
+ f_{-i'} = s_{w_0} e_{-(n+1-i)} s_{w_0},
1455
+
1456
+ where `w_0` is the longest element in the symmetric group `S_{n+1}`
1457
+ generated by `s_1,\ldots,s_n`. In this implementation, we use the integers
1458
+ `-2n, \ldots, -(n+1)` to respectively denote the indices `-n', \ldots, -1'`.
1459
+
1460
+ TESTS::
1461
+
1462
+ sage: Q = crystals.Letters(['Q', 3])
1463
+ sage: T = tensor([Q,Q]); T
1464
+ Full tensor product of the crystals
1465
+ [The queer crystal of letters for q(3),
1466
+ The queer crystal of letters for q(3)]
1467
+ sage: T.cardinality()
1468
+ 9
1469
+ sage: t = T.an_element(); t
1470
+ [1, 1]
1471
+ sage: t.weight()
1472
+ (2, 0, 0)
1473
+ """
1474
+ def e(self, i):
1475
+ r"""
1476
+ Return `e_i` on ``self``.
1477
+
1478
+ EXAMPLES::
1479
+
1480
+ sage: Q = crystals.Letters(['Q', 3])
1481
+ sage: T = tensor([Q,Q])
1482
+ sage: t = T(Q(1),Q(1))
1483
+ sage: t.e(-1)
1484
+ sage: t = T(Q(2),Q(1))
1485
+ sage: t.e(-1)
1486
+ [1, 1]
1487
+
1488
+ sage: T = tensor([Q,Q,Q,Q])
1489
+ sage: t = T(Q(1),Q(3),Q(2),Q(1))
1490
+ sage: t.e(-2)
1491
+ [2, 2, 1, 1]
1492
+ """
1493
+ if i > 0:
1494
+ from sage.categories.regular_supercrystals import RegularSuperCrystals
1495
+ if self._parent in RegularSuperCrystals():
1496
+ return TensorProductOfRegularCrystalsElement.e(self, i)
1497
+ else:
1498
+ return TensorProductOfCrystalsElement.e(self, i)
1499
+ cdef tuple w
1500
+ cdef int k, a, l
1501
+ l = len(self._list)
1502
+ if i == -1:
1503
+ for k in range(l):
1504
+ b = self._list[k].e(i)
1505
+ if b is not None:
1506
+ return self._set_index(k, b)
1507
+ if self._list[k].f(i) is not None:
1508
+ # There are no (-1)-string of length > 1
1509
+ return None
1510
+ return None
1511
+ n = self._parent.cartan_type().n
1512
+ if i < -1 and i >= -n:
1513
+ j = -i
1514
+ b = self
1515
+ for a in range(j-1, 0, -1):
1516
+ b = b.s(a)
1517
+ for a in range(j, 1, -1):
1518
+ b = b.s(a)
1519
+ b = b.e(-1)
1520
+ if b is None:
1521
+ return None
1522
+ for a in range(2, j+1):
1523
+ b = b.s(a)
1524
+ for a in range(1, j):
1525
+ b = b.s(a)
1526
+ return b
1527
+ if i < -n:
1528
+ j = -(i+n)
1529
+ w = <tuple> (self._parent._long_element())
1530
+ b = self
1531
+ for a in w:
1532
+ b = b.s(a)
1533
+ b = b.f(-(n+1-j))
1534
+ if b is None:
1535
+ return None
1536
+ for a in w:
1537
+ b = b.s(a)
1538
+ return b
1539
+ return None
1540
+
1541
+ def f(self, i):
1542
+ r"""
1543
+ Return `f_i` on ``self``.
1544
+
1545
+ EXAMPLES::
1546
+
1547
+ sage: Q = crystals.Letters(['Q', 3])
1548
+ sage: T = tensor([Q, Q])
1549
+ sage: t = T(Q(1), Q(1))
1550
+ sage: t.f(-1)
1551
+ [2, 1]
1552
+ """
1553
+ if i > 0:
1554
+ from sage.categories.regular_supercrystals import RegularSuperCrystals
1555
+ if self._parent in RegularSuperCrystals():
1556
+ return TensorProductOfRegularCrystalsElement.f(self, i)
1557
+ else:
1558
+ return TensorProductOfCrystalsElement.f(self, i)
1559
+ cdef tuple w
1560
+ cdef int k, a, l
1561
+ l = len(self._list)
1562
+ if i == -1:
1563
+ for k in range(l):
1564
+ b = self._list[k].f(i)
1565
+ if b is not None:
1566
+ return self._set_index(k, b)
1567
+ if self._list[k].e(i) is not None:
1568
+ # There are no (-1)-string of length > 1
1569
+ return None
1570
+ return None
1571
+ n = self._parent.cartan_type().n
1572
+ if i < -1 and i >= -n:
1573
+ j = -i
1574
+ b = self
1575
+ for a in range(j-1, 0, -1):
1576
+ b = b.s(a)
1577
+ for a in range(j, 1, -1):
1578
+ b = b.s(a)
1579
+ b = b.f(-1)
1580
+ if b is None:
1581
+ return None
1582
+ for a in range(2, j+1):
1583
+ b = b.s(a)
1584
+ for a in range(1, j):
1585
+ b = b.s(a)
1586
+ return b
1587
+ if i < -n:
1588
+ j = -(i+n)
1589
+ w = <tuple> (self._parent._long_element())
1590
+ b = self
1591
+ for a in w:
1592
+ b = b.s(a)
1593
+ b = b.e(-(n+1-j))
1594
+ if b is None:
1595
+ return None
1596
+ for a in w:
1597
+ b = b.s(a)
1598
+ return b
1599
+ return None
1600
+
1601
+ # Override epsilon/phi (for now)
1602
+ def epsilon(self, i):
1603
+ r"""
1604
+ Return `\varepsilon_i` on ``self``.
1605
+
1606
+ EXAMPLES::
1607
+
1608
+ sage: Q = crystals.Letters(['Q', 3])
1609
+ sage: T = tensor([Q, Q, Q, Q])
1610
+ sage: t = T(Q(1), Q(3), Q(2), Q(1))
1611
+ sage: t.epsilon(-2)
1612
+ 1
1613
+ """
1614
+ string_length = -1
1615
+ x = self
1616
+ while x is not None:
1617
+ string_length += 1
1618
+ x = x.e(i)
1619
+ return string_length
1620
+
1621
+ def phi(self, i):
1622
+ r"""
1623
+ Return `\varphi_i` on ``self``.
1624
+
1625
+ EXAMPLES::
1626
+
1627
+ sage: Q = crystals.Letters(['Q', 3])
1628
+ sage: T = tensor([Q, Q, Q, Q])
1629
+ sage: t = T(Q(1), Q(3), Q(2), Q(1))
1630
+ sage: t.phi(-2)
1631
+ 0
1632
+ sage: t.phi(-1)
1633
+ 1
1634
+ """
1635
+ string_length = -1
1636
+ x = self
1637
+ while x is not None:
1638
+ string_length += 1
1639
+ x = x.f(i)
1640
+ return string_length
1641
+
1642
+
1643
+ cdef class InfinityQueerCrystalOfTableauxElement(TensorProductOfQueerSuperCrystalsElement):
1644
+ def __init__(self, parent, list, row_lengths=None):
1645
+ """
1646
+ Initialize ``self``.
1647
+
1648
+ EXAMPLES::
1649
+
1650
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1651
+ sage: t = B([[4,4,4,4,2,1],[3,3,3],[2,2],[1]])
1652
+ sage: t
1653
+ [[4, 4, 4, 4, 2, 1], [3, 3, 3], [2, 2], [1]]
1654
+ sage: TestSuite(t).run()
1655
+ """
1656
+ if row_lengths is None:
1657
+ row_lengths = []
1658
+ if not row_lengths and list and not isinstance(list[0], parent.letters.element_class):
1659
+ ret = []
1660
+ L = parent.letters
1661
+ row_lengths = []
1662
+ for row in list:
1663
+ ret.extend(L(val) for val in reversed(row))
1664
+ row_lengths.append(len(row))
1665
+ list = ret
1666
+ self._row_lengths = row_lengths
1667
+ super().__init__(parent, list)
1668
+
1669
+ def _repr_(self):
1670
+ r"""
1671
+ Return a string representation of ``self``.
1672
+
1673
+ EXAMPLES::
1674
+
1675
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1676
+ sage: t = B.an_element()
1677
+ sage: t
1678
+ [[4, 4, 4, 4], [3, 3, 3], [2, 2], [1]]
1679
+ """
1680
+ return repr([list(reversed(row)) for row in self.rows()])
1681
+
1682
+ def _ascii_art_(self):
1683
+ """
1684
+ Return an ASCII art representation of ``self``.
1685
+
1686
+ EXAMPLES::
1687
+
1688
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1689
+ sage: t = B([[4,4,4,4,2,1],[3,3,3],[2,2],[1]])
1690
+ sage: ascii_art(t)
1691
+ 4 4 4 4 2 1
1692
+ 3 3 3
1693
+ 2 2
1694
+ 1
1695
+ """
1696
+ from sage.typeset.ascii_art import AsciiArt
1697
+ ret = [" "*(3*i) + "".join("%3s" % str(x) for x in reversed(row))
1698
+ for i, row in enumerate(self.rows())]
1699
+ return AsciiArt(ret)
1700
+
1701
+ def _latex_(self):
1702
+ r"""
1703
+ Return latex code for ``self``.
1704
+
1705
+ EXAMPLES::
1706
+
1707
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1708
+ sage: t = B([[4,4,4,4,4,2,1],[3,3,3,3],[2,2,1],[1]])
1709
+ sage: latex(t)
1710
+ {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}}
1711
+ \raisebox{-.6ex}{$\begin{array}[b]{*{7}c}\cline{1-7}
1712
+ \lr{4}&\lr{4}&\lr{4}&\lr{4}&\lr{4}&\lr{2}&\lr{1}\\\cline{1-7}
1713
+ &\lr{3}&\lr{3}&\lr{3}&\lr{3}\\\cline{2-5}
1714
+ &&\lr{2}&\lr{2}&\lr{1}\\\cline{3-5}
1715
+ &&&\lr{1}\\\cline{4-4}
1716
+ \end{array}$}
1717
+ }
1718
+ """
1719
+ from sage.combinat.output import tex_from_array
1720
+ return tex_from_array([[None]*i + list(reversed(row))
1721
+ for i, row in enumerate(self.rows())])
1722
+
1723
+ def rows(self):
1724
+ """
1725
+ Return the list of rows of ``self``.
1726
+
1727
+ EXAMPLES::
1728
+
1729
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1730
+ sage: t = B([[4,4,4,4,4,2,1],[3,3,3,3],[2,2,1],[1]])
1731
+ sage: t.rows()
1732
+ [[1, 2, 4, 4, 4, 4, 4], [3, 3, 3, 3], [1, 2, 2], [1]]
1733
+ """
1734
+ if not self:
1735
+ return []
1736
+
1737
+ cdef list ret = []
1738
+ cdef Py_ssize_t pos = 0
1739
+ for l in self._row_lengths:
1740
+ ret.append(self._list[pos:pos+l])
1741
+ pos += l
1742
+ return ret
1743
+
1744
+ def e(self, i):
1745
+ r"""
1746
+ Return the action of `e_i` on ``self``.
1747
+
1748
+ INPUT:
1749
+
1750
+ - ``i`` -- an element of the index set
1751
+
1752
+ EXAMPLES::
1753
+
1754
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1755
+ sage: t = B([[4,4,4,4,4,2,1],[3,3,3,3],[2,2,1],[1]])
1756
+ sage: t.e(1)
1757
+ [[4, 4, 4, 4, 4, 4, 2, 1], [3, 3, 3, 3, 3], [2, 2, 1, 1], [1]]
1758
+ sage: t.e(3)
1759
+ [[4, 4, 4, 4, 4, 3, 2, 1], [3, 3, 3, 3], [2, 2, 1], [1]]
1760
+ sage: t.e(-1)
1761
+ """
1762
+ ret = super().e(i)
1763
+ if ret is None:
1764
+ return None
1765
+ (<InfinityQueerCrystalOfTableauxElement> ret)._row_lengths = self._row_lengths
1766
+ if i < 0:
1767
+ i = -i
1768
+ L = self._parent.letters
1769
+ n = self._parent._cartan_type.n
1770
+ rows = ret.rows()
1771
+ row_lens = list(self._row_lengths)
1772
+ if count_leading(rows[n-i], L(i+1)) != len(rows[n-i+1]) + 1:
1773
+ for j in range(n-i+1):
1774
+ rows[j].append(L(n+1-j))
1775
+ row_lens[j] += 1
1776
+ return type(self)(self._parent, sum(rows, []), row_lens)
1777
+
1778
+ def f(self, i):
1779
+ r"""
1780
+ Return the action of `f_i` on ``self``.
1781
+
1782
+ INPUT:
1783
+
1784
+ - ``i`` -- an element of the index set
1785
+
1786
+ EXAMPLES::
1787
+
1788
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1789
+ sage: t = B([[4,4,4,4,4,2,1],[3,3,3,3],[2,2,1],[1]])
1790
+ sage: t.f(1)
1791
+ [[4, 4, 4, 4, 4, 2, 2], [3, 3, 3, 3], [2, 2, 1], [1]]
1792
+ sage: t.f(3)
1793
+ sage: t.f(-1)
1794
+ [[4, 4, 4, 4, 4, 2, 2], [3, 3, 3, 3], [2, 2, 1], [1]]
1795
+ """
1796
+ ret = super(InfinityQueerCrystalOfTableauxElement, self).f(i)
1797
+ if ret is None:
1798
+ return None
1799
+ (<InfinityQueerCrystalOfTableauxElement> ret)._row_lengths = self._row_lengths
1800
+ if i < 0:
1801
+ i = -i
1802
+ L = self._parent.letters
1803
+ n = self._parent._cartan_type.n
1804
+ rows = ret.rows()
1805
+ row_lens = list(self._row_lengths)
1806
+ if count_leading(rows[n-i], L(i+1)) != len(rows[n-i+1]) + 1:
1807
+ for j in range(n-i+1):
1808
+ rows[j].pop()
1809
+ row_lens[j] -= 1
1810
+ return type(self)(self._parent, sum(rows, []), row_lens)
1811
+
1812
+ def epsilon(self, i):
1813
+ r"""
1814
+ Return `\varepsilon_i` of ``self``.
1815
+
1816
+ INPUT:
1817
+
1818
+ - ``i`` -- an element of the index set
1819
+
1820
+ EXAMPLES::
1821
+
1822
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1823
+ sage: t = B([[4,4,4,4,4,2,1],[3,3,3,3],[2,2,1],[1]])
1824
+ sage: [t.epsilon(i) for i in B.index_set()]
1825
+ [-1, 1, -2, 0]
1826
+ """
1827
+ if i == -1:
1828
+ if self.e(-1) is None:
1829
+ return ZZ.zero()
1830
+ return ZZ.one()
1831
+ P = self._parent.weight_lattice_realization()
1832
+ h = P.simple_coroots()
1833
+ return self.phi(i) - P(self.weight()).scalar(h[i])
1834
+
1835
+ def weight(self):
1836
+ r"""
1837
+ Return the weight of ``self``.
1838
+
1839
+ EXAMPLES::
1840
+
1841
+ sage: B = crystals.infinity.Tableaux(['Q',4])
1842
+ sage: t = B([[4,4,4,4,4,2,1],[3,3,3,3],[2,2,1],[1]])
1843
+ sage: t.weight()
1844
+ (4, 2, 2, 0)
1845
+ """
1846
+ ret = super(InfinityQueerCrystalOfTableauxElement, self).weight()
1847
+ L = self._parent.letters
1848
+ n = self._parent._cartan_type.n + 1
1849
+ zero = self._parent.weight_lattice_realization().zero()
1850
+ La = self._parent.weight_lattice_realization().fundamental_weights()
1851
+
1852
+ def fwt(i):
1853
+ return zero if i == n else La[i]
1854
+ ret -= sum((self._row_lengths[i] - 1 - self._row_lengths[i+1])*(fwt(n-i)-fwt(n-i-1))
1855
+ for i in range(n-1))
1856
+ for i, l in enumerate(self._row_lengths[1:]):
1857
+ ret -= L(n-i).weight() * (l + 1)
1858
+ ret -= L(1).weight() # From the 1 on the bottom row
1859
+ return ret
1860
+
1861
+ cdef Py_ssize_t count_leading(list row, letter) noexcept:
1862
+ cdef Py_ssize_t i
1863
+ for i in range(len(row)-1,-1,-1):
1864
+ if row[i] != letter:
1865
+ return len(row) - 1 - i
1866
+ return len(row)
1867
+
1868
+ # for unpickling
1869
+ from sage.misc.persist import register_unpickle_override
1870
+ register_unpickle_override('sage.combinat.crystals.tensor_product', 'ImmutableListWithParent', ImmutableListWithParent)