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,1463 @@
1
+ # sage_setup: distribution = sagemath-combinat
2
+ # sage.doctest: needs sage.graphs sage.modules
3
+ """
4
+ Soliton Cellular Automata
5
+
6
+ AUTHORS:
7
+
8
+ - Travis Scrimshaw (2017-06-30): Initial version
9
+ - Travis Scrimshaw (2018-02-03): Periodic version
10
+ """
11
+
12
+ # ****************************************************************************
13
+ # Copyright (C) 2017 Travis Scrimshaw <tcscrims at gmail.com>
14
+ #
15
+ # This program is free software: you can redistribute it and/or modify
16
+ # it under the terms of the GNU General Public License as published by
17
+ # the Free Software Foundation, either version 2 of the License, or
18
+ # (at your option) any later version.
19
+ # https://www.gnu.org/licenses/
20
+ # ****************************************************************************
21
+
22
+ from sage.structure.sage_object import SageObject
23
+ from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import TensorProductOfKirillovReshetikhinTableaux
24
+ from sage.combinat.rigged_configurations.kr_tableaux import KirillovReshetikhinTableaux
25
+ from sage.combinat.rigged_configurations.rigged_configurations import RiggedConfigurations
26
+ from sage.combinat.root_system.cartan_type import CartanType
27
+ from sage.typeset.ascii_art import ascii_art
28
+ from sage.rings.integer_ring import ZZ
29
+
30
+
31
+ class SolitonCellularAutomata(SageObject):
32
+ r"""
33
+ Soliton cellular automata.
34
+
35
+ Fix an affine Lie algebra `\mathfrak{g}` with index `I` and
36
+ classical index set `I_0`. Fix some `r \in I_0`. A *soliton
37
+ cellular automaton* (SCA) is a discrete (non-linear) dynamical
38
+ system given as follows. The *states* are given by elements of
39
+ a semi-infinite tensor product of Kirillov-Reshetihkin crystals
40
+ `B^{r,1}`, where only a finite number of factors are not the
41
+ maximal element `u`, which we will call the *vacuum*. The *time
42
+ evolution* `T_s` is defined by
43
+
44
+ .. MATH::
45
+
46
+ R(p \otimes u_s) = u_s \otimes T_s(p),
47
+
48
+ where `p = \cdots \otimes p_3 \otimes p_2 \otimes p_1 \otimes p_0`
49
+ is a state and `u_s` is the maximal element of `B^{r,s}`.
50
+ In more detail, we have `R(p_i \otimes u^{(i)}) =
51
+ u^{(i+1)} \otimes \widetilde{p}_i` with `u^{(0)} = u_s` and
52
+ `T_s(p) = \cdots \otimes \widetilde{p}_1 \otimes \widetilde{p}_0`.
53
+ This is well-defined since `R(u \otimes u_s) = u_s \otimes u`
54
+ and `u^{(k)} = u_s` for all `k \gg 1`.
55
+
56
+ INPUT:
57
+
58
+ - ``initial_state`` -- the list of elements, can also be a string
59
+ when ``vacuum`` is 1 and ``n`` is `\mathfrak{sl}_n`
60
+ - ``cartan_type`` -- (default: 2) the value ``n``, for `\mathfrak{sl}_n`,
61
+ or a Cartan type
62
+ - ``r`` -- (default: 1) the node index `r`; typically this
63
+ corresponds to the height of the vacuum element
64
+
65
+ EXAMPLES:
66
+
67
+ We first create an example in `\mathfrak{sl}_4` (type `A_3`)::
68
+
69
+ sage: B = SolitonCellularAutomata('3411111122411112223', 4)
70
+ sage: B
71
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
72
+ initial state:
73
+ 34......224....2223
74
+ evoltuions: []
75
+ current state:
76
+ 34......224....2223
77
+
78
+ We then apply a standard evolution::
79
+
80
+ sage: B.evolve()
81
+ sage: B
82
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
83
+ initial state:
84
+ 34......224....2223
85
+ evoltuions: [(1, 19)]
86
+ current state:
87
+ .................34.....224...2223....
88
+
89
+ Next, we apply a smaller carrier evolution. Note that the soliton
90
+ of size 4 moves only 3 steps::
91
+
92
+ sage: B.evolve(3)
93
+ sage: B
94
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
95
+ initial state:
96
+ 34......224....2223
97
+ evoltuions: [(1, 19), (1, 3)]
98
+ current state:
99
+ ...............34....224...2223.......
100
+
101
+ We can also use carriers corresponding to non-vacuum indices.
102
+ In these cases, the carrier might not return to its initial
103
+ state, which results in a message being displayed about
104
+ the resulting state of the carrier::
105
+
106
+ sage: B.evolve(carrier_capacity=7, carrier_index=3)
107
+ Last carrier:
108
+ 1 1 1 1 1 1 1
109
+ 2 2 2 2 2 3 3
110
+ 3 3 3 3 3 4 4
111
+ sage: B
112
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
113
+ initial state:
114
+ 34......224....2223
115
+ evoltuions: [(1, 19), (1, 3), (3, 7)]
116
+ current state:
117
+ .....................23....222....2223.......
118
+
119
+ sage: B.evolve(carrier_capacity=3, carrier_index=2)
120
+ Last carrier:
121
+ 1 1 1
122
+ 2 2 3
123
+ sage: B
124
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
125
+ initial state:
126
+ 34......224....2223
127
+ evoltuions: [(1, 19), (1, 3), (3, 7), (2, 3)]
128
+ current state:
129
+ .......................22.....223...2222........
130
+
131
+ To summarize our current evolutions, we can use :meth:`print_states`::
132
+
133
+ sage: B.print_states(5)
134
+ t: 0
135
+ .............................34......224....2223
136
+ t: 1
137
+ ...........................34.....224...2223....
138
+ t: 2
139
+ .........................34....224...2223.......
140
+ t: 3
141
+ ........................23....222....2223.......
142
+ t: 4
143
+ .......................22.....223...2222........
144
+
145
+ To run the SCA further under the standard evolutions, one can use
146
+ :meth:`print_states` or :meth:`latex_states`::
147
+
148
+ sage: B.print_states(15)
149
+ t: 0
150
+ ................................................34......224....2223
151
+ t: 1
152
+ ..............................................34.....224...2223....
153
+ t: 2
154
+ ............................................34....224...2223.......
155
+ t: 3
156
+ ...........................................23....222....2223.......
157
+ t: 4
158
+ ..........................................22.....223...2222........
159
+ t: 5
160
+ ........................................22....223..2222............
161
+ t: 6
162
+ ......................................22..2223..222................
163
+ t: 7
164
+ ..................................2222..23...222...................
165
+ t: 8
166
+ ..............................2222....23..222......................
167
+ t: 9
168
+ ..........................2222......23.222.........................
169
+ t: 10
170
+ ......................2222.......223.22............................
171
+ t: 11
172
+ ..................2222........223..22..............................
173
+ t: 12
174
+ ..............2222.........223...22................................
175
+ t: 13
176
+ ..........2222..........223....22..................................
177
+ t: 14
178
+ ......2222...........223.....22....................................
179
+
180
+ Next, we use `r = 2` in type `A_3`. Here, we give the data as lists of
181
+ values corresponding to the entries of the column of height 2 from
182
+ the largest entry to smallest. Our columns are drawn in French
183
+ convention::
184
+
185
+ sage: B = SolitonCellularAutomata([[4,1],[4,1],[2,1],[2,1],[2,1],[2,1],[3,1],[3,1],[3,2]], 4, 2)
186
+
187
+ We perform 3 evolutions and obtain the following::
188
+
189
+ sage: B.evolve(number=3)
190
+ sage: B
191
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 2
192
+ initial state:
193
+ 44 333
194
+ 11....112
195
+ evoltuions: [(2, 9), (2, 9), (2, 9)]
196
+ current state:
197
+ 44 333
198
+ ...11.112.........
199
+
200
+ We construct Example 2.9 from [LS2017]_::
201
+
202
+ sage: B = SolitonCellularAutomata([[2],[-3],[1],[1],[1],[4],[0],[-2],
203
+ ....: [1],[1],[1],[1],[3],[-4],[-3],[-3],[1]], ['D',5,2])
204
+ sage: B.print_states(10)
205
+ t: 0 _ _ ___
206
+ ..................................23...402....3433.
207
+ t: 1 _ _ ___
208
+ ................................23..402...3433.....
209
+ t: 2 _ _ ___
210
+ ..............................23.402..3433.........
211
+ t: 3 _ _ ___
212
+ ...........................243.02.3433.............
213
+ t: 4 _ __ __
214
+ .......................2403..42333.................
215
+ t: 5 _ ___ _
216
+ ...................2403...44243....................
217
+ t: 6 _ ___ _
218
+ ...............2403....442.43......................
219
+ t: 7 _ ___ _
220
+ ...........2403.....442..43........................
221
+ t: 8 _ ___ _
222
+ .......2403......442...43..........................
223
+ t: 9 _ ___ _
224
+ ...2403.......442....43............................
225
+
226
+ Example 3.4 from [LS2017]_::
227
+
228
+ sage: B = SolitonCellularAutomata([['E'],[1],[1],[1],[3],[0],
229
+ ....: [1],[1],[1],[1],[2],[-3],[-1],[1]], ['D',4,2])
230
+ sage: B.print_states(10)
231
+ t: 0 __
232
+ ..........................................E...30....231.
233
+ t: 1 __
234
+ .........................................E..30..231.....
235
+ t: 2 _ _
236
+ ........................................E303.21.........
237
+ t: 3 _ _
238
+ ....................................303E2.22............
239
+ t: 4 _ _
240
+ ................................303E...222..............
241
+ t: 5 _ _
242
+ ............................303E......12................
243
+ t: 6 _ _
244
+ ........................303E........1.2.................
245
+ t: 7 _ _
246
+ ....................303E..........1..2..................
247
+ t: 8 _ _
248
+ ................303E............1...2...................
249
+ t: 9 _ _
250
+ ............303E..............1....2....................
251
+
252
+ Example 3.12 from [LS2017]_::
253
+
254
+ sage: B = SolitonCellularAutomata([[-1,3,2],[3,2,1],[3,2,1],[-3,2,1],
255
+ ....: [-2,-3,1]], ['B',3,1], 3)
256
+ sage: B.print_states(6)
257
+ -1 -3-2
258
+ t: 0 3 2-3
259
+ . . . . . . . . . . . . . . . 2 . . 1 1
260
+ -1-3-2
261
+ t: 1 3 2-3
262
+ . . . . . . . . . . . . . . 2 1 1 . . .
263
+ -3-1
264
+ t: 2 2-2
265
+ . . . . . . . . . . . . 1-3 . . . . . .
266
+ -3-1 -3
267
+ t: 3 2-2 2
268
+ . . . . . . . . . 1 3 . 1 . . . . . . .
269
+ -3-1 -3
270
+ t: 4 2-2 2
271
+ . . . . . . 1 3 . . . 1 . . . . . . . .
272
+ -3-1 -3
273
+ t: 5 2-2 2
274
+ . . . 1 3 . . . . . 1 . . . . . . . . .
275
+
276
+ Example 4.12 from [LS2017]_::
277
+
278
+ sage: K = crystals.KirillovReshetikhin(['E',6,1], 1,1, 'KR')
279
+ sage: u = K.module_generators[0]
280
+ sage: x = u.f_string([1,3,4,5])
281
+ sage: y = u.f_string([1,3,4,2,5,6])
282
+ sage: a = u.f_string([1,3,4,2])
283
+ sage: B = SolitonCellularAutomata([a, u,u,u, x,y], ['E',6,1], 1)
284
+ sage: B
285
+ Soliton cellular automata of type ['E', 6, 1] and vacuum = 1
286
+ initial state:
287
+ (-2, 5) . . . (-5, 2, 6)(-2, -6, 4)
288
+ evoltuions: []
289
+ current state:
290
+ (-2, 5) . . . (-5, 2, 6)(-2, -6, 4)
291
+ sage: B.print_states(8)
292
+ t: 0 ...
293
+ t: 7
294
+ . (-2, 5)(-2, -5, 4, 6) ... (-6, 2) ...
295
+ """
296
+ def __init__(self, initial_state, cartan_type=2, vacuum=1):
297
+ """
298
+ Initialize ``self``.
299
+
300
+ EXAMPLES::
301
+
302
+ sage: B = SolitonCellularAutomata('3411111122411112223', 4)
303
+ sage: TestSuite(B).run()
304
+ """
305
+ if cartan_type in ZZ:
306
+ cartan_type = CartanType(['A',cartan_type-1,1])
307
+ else:
308
+ cartan_type = CartanType(cartan_type)
309
+ self._cartan_type = cartan_type
310
+ self._vacuum = vacuum
311
+ K = KirillovReshetikhinTableaux(self._cartan_type, self._vacuum, 1)
312
+ try:
313
+ # FIXME: the maximal_vector() does not work in type E and F
314
+ self._vacuum_elt = K.maximal_vector()
315
+ except (ValueError, TypeError, AttributeError):
316
+ self._vacuum_elt = K.module_generators[0]
317
+
318
+ if isinstance(initial_state, str):
319
+ # We consider things 1-9
320
+ initial_state = [[ZZ(x) if x != '.' else ZZ.one()] for x in initial_state]
321
+ try:
322
+ KRT = TensorProductOfKirillovReshetikhinTableaux(self._cartan_type,
323
+ [[vacuum, len(st)//vacuum]
324
+ for st in initial_state])
325
+ self._states = [KRT(pathlist=initial_state)]
326
+ except TypeError:
327
+ KRT = TensorProductOfKirillovReshetikhinTableaux(self._cartan_type,
328
+ [[vacuum, 1]
329
+ for st in initial_state])
330
+ self._states = [KRT(*initial_state)]
331
+
332
+ self._evolutions = []
333
+ self._initial_carrier = []
334
+ self._nballs = len(self._states[0])
335
+
336
+ def __eq__(self, other):
337
+ """
338
+ Check equality.
339
+
340
+ Two SCAs are equal when they have the same initial state
341
+ and evolutions.
342
+
343
+ TESTS::
344
+
345
+ sage: B1 = SolitonCellularAutomata('34112223', 4)
346
+ sage: B2 = SolitonCellularAutomata('34112223', 4)
347
+ sage: B1 == B2
348
+ True
349
+ sage: B1.evolve()
350
+ sage: B1 == B2
351
+ False
352
+ sage: B2.evolve()
353
+ sage: B1 == B2
354
+ True
355
+ sage: B1.evolve(5)
356
+ sage: B2.evolve(6)
357
+ sage: B1 == B2
358
+ False
359
+ """
360
+ return (isinstance(other, SolitonCellularAutomata)
361
+ and self._states[0] == other._states[0]
362
+ and self._evolutions == other._evolutions)
363
+
364
+ def __ne__(self, other):
365
+ """
366
+ Check non equality.
367
+
368
+ TESTS::
369
+
370
+ sage: B1 = SolitonCellularAutomata('34112223', 4)
371
+ sage: B2 = SolitonCellularAutomata('34112223', 4)
372
+ sage: B1 != B2
373
+ False
374
+ sage: B1.evolve()
375
+ sage: B1 != B2
376
+ True
377
+ sage: B2.evolve()
378
+ sage: B1 != B2
379
+ False
380
+ sage: B1.evolve(5)
381
+ sage: B2.evolve(6)
382
+ sage: B1 != B2
383
+ True
384
+ """
385
+ return not (self == other)
386
+
387
+ # Evolution functions
388
+ # -------------------
389
+
390
+ def evolve(self, carrier_capacity=None, carrier_index=None, number=None):
391
+ r"""
392
+ Evolve ``self``.
393
+
394
+ Time evolution `T_s` of a SCA state `p` is determined by
395
+
396
+ .. MATH::
397
+
398
+ u_{r,s} \otimes T_s(p) = R(p \otimes u_{r,s}),
399
+
400
+ where `u_{r,s}` is the maximal element of `B^{r,s}`.
401
+
402
+ INPUT:
403
+
404
+ - ``carrier_capacity`` -- (default: the number of balls in
405
+ the system) the size `s` of carrier
406
+
407
+ - ``carrier_index`` -- (default: the vacuum index) the index `r`
408
+ of the carrier
409
+
410
+ - ``number`` -- (optional) the number of times to perform
411
+ the evolutions
412
+
413
+ To perform multiple evolutions of the SCA, ``carrier_capacity``
414
+ and ``carrier_index`` may be lists of the same length.
415
+
416
+ EXAMPLES::
417
+
418
+ sage: B = SolitonCellularAutomata('3411111122411112223', 4)
419
+ sage: for k in range(10):
420
+ ....: B.evolve()
421
+ sage: B
422
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
423
+ initial state:
424
+ 34......224....2223
425
+ evoltuions: [(1, 19), (1, 19), (1, 19), (1, 19), (1, 19),
426
+ (1, 19), (1, 19), (1, 19), (1, 19), (1, 19)]
427
+ current state:
428
+ ......2344.......222....23...............................
429
+
430
+ sage: B.reset()
431
+ sage: B.evolve(number=10); B
432
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
433
+ initial state:
434
+ 34......224....2223
435
+ evoltuions: [(1, 19), (1, 19), (1, 19), (1, 19), (1, 19),
436
+ (1, 19), (1, 19), (1, 19), (1, 19), (1, 19)]
437
+ current state:
438
+ ......2344.......222....23...............................
439
+
440
+ sage: B.reset()
441
+ sage: B.evolve(carrier_capacity=[1,2,3,4,5,6,7,8,9,10]); B
442
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
443
+ initial state:
444
+ 34......224....2223
445
+ evoltuions: [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
446
+ (1, 6), (1, 7), (1, 8), (1, 9), (1, 10)]
447
+ current state:
448
+ ........2344....222..23..............................
449
+
450
+ sage: B.reset()
451
+ sage: B.evolve(carrier_index=[1,2,3])
452
+ Last carrier:
453
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
454
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 4 4
455
+ sage: B
456
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
457
+ initial state:
458
+ 34......224....2223
459
+ evoltuions: [(1, 19), (2, 19), (3, 19)]
460
+ current state:
461
+ ..................................22......223...2222.....
462
+
463
+ sage: B.reset()
464
+ sage: B.evolve(carrier_capacity=[1,2,3], carrier_index=[1,2,3])
465
+ Last carrier:
466
+ 1 1
467
+ 3 4
468
+ Last carrier:
469
+ 1 1 1
470
+ 2 2 3
471
+ 3 3 4
472
+ sage: B
473
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
474
+ initial state:
475
+ 34......224....2223
476
+ evoltuions: [(1, 1), (2, 2), (3, 3)]
477
+ current state:
478
+ .....22.......223....2222..
479
+
480
+ sage: B.reset()
481
+ sage: B.evolve(1, 2, number=3)
482
+ Last carrier:
483
+ 1
484
+ 3
485
+ Last carrier:
486
+ 1
487
+ 4
488
+ Last carrier:
489
+ 1
490
+ 3
491
+ sage: B
492
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
493
+ initial state:
494
+ 34......224....2223
495
+ evoltuions: [(2, 1), (2, 1), (2, 1)]
496
+ current state:
497
+ .24......222.....2222.
498
+ """
499
+ if isinstance(carrier_capacity, (list, tuple)):
500
+ if not isinstance(carrier_index, (list, tuple)):
501
+ carrier_index = [carrier_index] * len(carrier_capacity)
502
+ if len(carrier_index) != len(carrier_capacity):
503
+ raise ValueError("carrier_index and carrier_capacity"
504
+ " must have the same length")
505
+ for i, r in zip(carrier_capacity, carrier_index):
506
+ self.evolve(i, r)
507
+ return
508
+ if isinstance(carrier_index, (list, tuple)):
509
+ # carrier_capacity must be not be a list/tuple if given
510
+ for r in carrier_index:
511
+ self.evolve(carrier_capacity, r)
512
+ return
513
+
514
+ if carrier_capacity is None:
515
+ carrier_capacity = self._nballs
516
+ if carrier_index is None:
517
+ carrier_index = self._vacuum
518
+
519
+ if number is not None:
520
+ for _ in range(number):
521
+ self.evolve(carrier_capacity, carrier_index)
522
+ return
523
+
524
+ passed = False
525
+ K = KirillovReshetikhinTableaux(self._cartan_type, carrier_index, carrier_capacity)
526
+ try:
527
+ # FIXME: the maximal_vector() does not work in type E and F
528
+ empty_carrier = K.maximal_vector()
529
+ except (ValueError, TypeError, AttributeError):
530
+ empty_carrier = K.module_generators[0]
531
+ self._initial_carrier.append(empty_carrier)
532
+ carrier_factor = (carrier_index, carrier_capacity)
533
+ last_final_carrier = empty_carrier
534
+ state = self._states[-1]
535
+ dims = state.parent().dims
536
+ while not passed:
537
+ KRT = TensorProductOfKirillovReshetikhinTableaux(self._cartan_type,
538
+ dims + (carrier_factor,))
539
+ elt = KRT(*(list(state) + [empty_carrier]))
540
+ RC = RiggedConfigurations(self._cartan_type, (carrier_factor,) + dims)
541
+ elt2 = RC(*elt.to_rigged_configuration()).to_tensor_product_of_kirillov_reshetikhin_tableaux()
542
+ # Back to an empty carrier or we are not getting any better
543
+ if elt2[0] == empty_carrier or elt2[0] == last_final_carrier:
544
+ passed = True
545
+ KRT = TensorProductOfKirillovReshetikhinTableaux(self._cartan_type, dims)
546
+ self._states.append(KRT(*elt2[1:]))
547
+ self._evolutions.append(carrier_factor)
548
+ if elt2[0] != empty_carrier:
549
+ print("Last carrier:")
550
+ print(ascii_art(last_final_carrier))
551
+ else:
552
+ # We need to add more vacuum states
553
+ last_final_carrier = elt2[0]
554
+ dims = tuple([(self._vacuum, 1)]*carrier_capacity) + dims
555
+
556
+ def state_evolution(self, num):
557
+ """
558
+ Return a list of the carrier values at state ``num`` evolving to
559
+ the next state.
560
+
561
+ If ``num`` is greater than the number of states, this performs
562
+ the standard evolution `T_k`, where `k` is the number of balls
563
+ in the system.
564
+
565
+ .. SEEALSO::
566
+
567
+ :meth:`print_state_evolution`, :meth:`latex_state_evolution`
568
+
569
+ EXAMPLES::
570
+
571
+ sage: B = SolitonCellularAutomata('1113123', 3)
572
+ sage: B.evolve(3)
573
+ sage: B.state_evolution(0)
574
+ [[[1, 1, 1]],
575
+ [[1, 1, 1]],
576
+ [[1, 1, 1]],
577
+ [[1, 1, 3]],
578
+ [[1, 1, 2]],
579
+ [[1, 2, 3]],
580
+ [[1, 1, 3]],
581
+ [[1, 1, 1]]]
582
+ sage: B.state_evolution(2)
583
+ [[[1, 1, 1, 1, 1, 1, 1]],
584
+ [[1, 1, 1, 1, 1, 1, 1]],
585
+ [[1, 1, 1, 1, 1, 1, 1]],
586
+ [[1, 1, 1, 1, 1, 1, 1]],
587
+ [[1, 1, 1, 1, 1, 1, 1]],
588
+ [[1, 1, 1, 1, 1, 1, 1]],
589
+ [[1, 1, 1, 1, 1, 1, 3]],
590
+ [[1, 1, 1, 1, 1, 3, 3]],
591
+ [[1, 1, 1, 1, 1, 1, 3]],
592
+ [[1, 1, 1, 1, 1, 1, 2]],
593
+ [[1, 1, 1, 1, 1, 1, 1]],
594
+ [[1, 1, 1, 1, 1, 1, 1]],
595
+ [[1, 1, 1, 1, 1, 1, 1]],
596
+ [[1, 1, 1, 1, 1, 1, 1]],
597
+ [[1, 1, 1, 1, 1, 1, 1]]]
598
+ """
599
+ if num + 2 > len(self._states):
600
+ for _ in range(num + 2 - len(self._states)):
601
+ self.evolve()
602
+
603
+ carrier = KirillovReshetikhinTableaux(self._cartan_type, *self._evolutions[num])
604
+ num_factors = len(self._states[num+1])
605
+ vacuum = self._vacuum_elt
606
+ state = [vacuum]*(num_factors - len(self._states[num])) + list(self._states[num])
607
+ final = []
608
+ u = [self._initial_carrier[num]]
609
+ # Assume every element has the same parent
610
+ R = state[0].parent().R_matrix(carrier)
611
+ for elt in reversed(state):
612
+ up, eltp = R(R.domain()(elt, u[0]))
613
+ u.insert(0, up)
614
+ final.insert(0, eltp)
615
+ return u
616
+
617
+ def reset(self):
618
+ r"""
619
+ Reset ``self`` back to the initial state.
620
+
621
+ EXAMPLES::
622
+
623
+ sage: B = SolitonCellularAutomata('34111111224', 4)
624
+ sage: B
625
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
626
+ initial state:
627
+ 34......224
628
+ evoltuions: []
629
+ current state:
630
+ 34......224
631
+ sage: B.evolve()
632
+ sage: B.evolve()
633
+ sage: B.evolve()
634
+ sage: B.evolve()
635
+ sage: B
636
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
637
+ initial state:
638
+ 34......224
639
+ evoltuions: [(1, 11), (1, 11), (1, 11), (1, 11)]
640
+ current state:
641
+ ...34..224............
642
+ sage: B.reset()
643
+ sage: B
644
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
645
+ initial state:
646
+ 34......224
647
+ evoltuions: []
648
+ current state:
649
+ 34......224
650
+ """
651
+ self._states = [self._states[0]]
652
+ self._evolutions = []
653
+ self._initial_carrier = []
654
+
655
+ # Output functions
656
+ # ----------------
657
+
658
+ def _column_repr(self, b, vacuum_letter=None):
659
+ """
660
+ Return a string representation of the column ``b``.
661
+
662
+ EXAMPLES::
663
+
664
+ sage: B = SolitonCellularAutomata([[-2,1],[2,1],[-3,1],[-3,2]], ['D',4,2], 2)
665
+ sage: K = crystals.KirillovReshetikhin(['D',4,2], 2,1, 'KR')
666
+ sage: B._column_repr(K(-2,1))
667
+ -2
668
+ 1
669
+ sage: B._column_repr(K.module_generator())
670
+ 2
671
+ 1
672
+ sage: B._column_repr(K.module_generator(), 'x')
673
+ x
674
+ """
675
+ if vacuum_letter is not None and b == self._vacuum_elt:
676
+ return ascii_art(vacuum_letter)
677
+ if self._vacuum_elt.parent()._tableau_height == 1:
678
+ s = str(b[0])
679
+ return ascii_art(s if s[0] != '-' else '_\n' + s[1:])
680
+ letter_str = [str(letter) for letter in b]
681
+ max_width = max(len(s) for s in letter_str)
682
+ return ascii_art('\n'.join(' '*(max_width-len(s)) + s for s in letter_str))
683
+
684
+ def _repr_state(self, state, vacuum_letter='.'):
685
+ """
686
+ Return a string representation of ``state``.
687
+
688
+ EXAMPLES::
689
+
690
+ sage: B = SolitonCellularAutomata('3411111122411112223', 4)
691
+ sage: B.evolve(number=10)
692
+ sage: print(B._repr_state(B._states[0]))
693
+ 34......224....2223
694
+ sage: print(B._repr_state(B._states[-1], '_'))
695
+ ______2344_______222____23_______________________________
696
+ """
697
+ output = [self._column_repr(b, vacuum_letter) for b in state]
698
+ max_width = max(cell.width() for cell in output)
699
+ return sum((ascii_art(' '*(max_width-b.width())) + b for b in output),
700
+ ascii_art(''))
701
+
702
+ def _repr_(self):
703
+ """
704
+ Return a string representation of ``self``.
705
+
706
+ EXAMPLES::
707
+
708
+ sage: SolitonCellularAutomata('3411111122411112223', 4)
709
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
710
+ initial state:
711
+ 34......224....2223
712
+ evoltuions: []
713
+ current state:
714
+ 34......224....2223
715
+ sage: SolitonCellularAutomata([[4,1],[2,1],[2,1],[3,1],[3,2]], 4, 2)
716
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 2
717
+ initial state:
718
+ 4 33
719
+ 1..12
720
+ evoltuions: []
721
+ current state:
722
+ 4 33
723
+ 1..12
724
+ sage: SolitonCellularAutomata([[4,1],[2,1],[2,1],[3,1],[3,2]], ['C',4,1], 2)
725
+ Soliton cellular automata of type ['C', 4, 1] and vacuum = 2
726
+ initial state:
727
+ 4 33
728
+ 1..12
729
+ evoltuions: []
730
+ current state:
731
+ 4 33
732
+ 1..12
733
+ sage: SolitonCellularAutomata([[4,3],[2,1],[-3,1],[-3,2]], ['B',4,1], 2)
734
+ Soliton cellular automata of type ['B', 4, 1] and vacuum = 2
735
+ initial state:
736
+ 4 -3-3
737
+ 3 . 1 2
738
+ evoltuions: []
739
+ current state:
740
+ 4 -3-3
741
+ 3 . 1 2
742
+ """
743
+ ret = "Soliton cellular automata of type {} and vacuum = {}\n".format(self._cartan_type, self._vacuum)
744
+ ret += " initial state:\n{}\n evoltuions: {}\n current state:\n{}".format(
745
+ ascii_art(' ') + self._repr_state(self._states[0]),
746
+ self._evolutions,
747
+ ascii_art(' ') + self._repr_state(self._states[-1])
748
+ )
749
+ return ret
750
+
751
+ def print_state(self, num=None, vacuum_letter='.', remove_trailing_vacuums=False):
752
+ """
753
+ Print the state ``num``.
754
+
755
+ INPUT:
756
+
757
+ - ``num`` -- (default: the current state) the state to print
758
+ - ``vacuum_letter`` -- (default: ``'.'``) the letter to print
759
+ for the vacuum
760
+ - ``remove_trailing_vacuums`` -- boolean (default: ``False``); if ``True``
761
+ then this does not print the vacuum letters at the right end
762
+ of the state
763
+
764
+ EXAMPLES::
765
+
766
+ sage: B = SolitonCellularAutomata('3411111122411112223', 4)
767
+ sage: B.print_state()
768
+ 34......224....2223
769
+ sage: B.evolve(number=2)
770
+ sage: B.print_state(vacuum_letter=',')
771
+ ,,,,,,,,,,,,,,,34,,,,224,,2223,,,,,,,,
772
+ sage: B.print_state(10, '_')
773
+ ______2344_______222____23_______________________________
774
+ sage: B.print_state(10, '_', True)
775
+ ______2344_______222____23
776
+ """
777
+ if num is None:
778
+ num = len(self._states) - 1
779
+ if num + 1 > len(self._states):
780
+ for _ in range(num + 1 - len(self._states)):
781
+ self.evolve()
782
+ state = self._states[num]
783
+ if remove_trailing_vacuums:
784
+ pos = len(state) - 1
785
+ # The pos goes negative if and only if the state consists
786
+ # entirely of vacuum elements.
787
+ while pos >= 0 and state[pos] == self._vacuum_elt:
788
+ pos -= 1
789
+ state = state[:pos+1]
790
+ print(self._repr_state(state, vacuum_letter))
791
+
792
+ def print_states(self, num=None, vacuum_letter='.'):
793
+ r"""
794
+ Print the first ``num`` states of ``self``.
795
+
796
+ .. NOTE::
797
+
798
+ If the number of states computed for ``self`` is less than
799
+ ``num``, then this evolves the system using the default
800
+ time evolution.
801
+
802
+ INPUT:
803
+
804
+ - ``num`` -- the number of states to print
805
+
806
+ EXAMPLES::
807
+
808
+ sage: B = SolitonCellularAutomata([[2],[-1],[1],[1],[1],[1],[2],[2],[3],
809
+ ....: [-2],[1],[1],[2],[-1],[1],[1],[1],[1],[1],[1],[2],[3],[3],[-3],[-2]],
810
+ ....: ['C',3,1])
811
+ sage: B.print_states(7)
812
+ t: 0 _ _ _ __
813
+ .........................21....2232..21......23332
814
+ t: 1 _ _ _ __
815
+ ......................21...2232...21....23332.....
816
+ t: 2 _ _ _ __
817
+ ...................21..2232....21..23332..........
818
+ t: 3 _ _ _ __
819
+ ...............221..232...2231..332...............
820
+ t: 4 _ _ _ __
821
+ ...........221...232.2231....332..................
822
+ t: 5 _ __ __
823
+ .......221...2321223......332.....................
824
+ t: 6 _ __ __
825
+ ..2221...321..223......332........................
826
+
827
+ sage: B = SolitonCellularAutomata([[2],[1],[1],[1],[3],[-2],[1],[1],
828
+ ....: [1],[2],[2],[-3],[1],[1],[1],[1],[1],[1],[2],[3],[3],[-3]],
829
+ ....: ['B',3,1])
830
+ sage: B.print_states(9, ' ')
831
+ t: 0 _ _ _
832
+ 2 32 223 2333
833
+ t: 1 _ _ _
834
+ 2 32 223 2333
835
+ t: 2 _ _ _
836
+ 2 32 223 2333
837
+ t: 3 _ _ _
838
+ 23 2223 2333
839
+ t: 4 __ _
840
+ 23 213 2333
841
+ t: 5 _ _ _
842
+ 2233 222 333
843
+ t: 6 _ _ _
844
+ 2233 23223 3
845
+ t: 7 _ _ _
846
+ 2233 232 23 3
847
+ t: 8 _ _ _
848
+ 2233 232 23 3
849
+
850
+ sage: B = SolitonCellularAutomata([[2],[-2],[1],[1],[1],[1],[2],[0],[-3],
851
+ ....: [1],[1],[1],[1],[1],[2],[2],[3],[-3],], ['D',4,2])
852
+ sage: B.print_states(10)
853
+ t: 0 _ _ _
854
+ ....................................22....203.....2233
855
+ t: 1 _ _ _
856
+ ..................................22...203....2233....
857
+ t: 2 _ _ _
858
+ ................................22..203...2233........
859
+ t: 3 _ _ _
860
+ ..............................22.203..2233............
861
+ t: 4 _ _ _
862
+ ............................22203.2233................
863
+ t: 5 _ _ _
864
+ ........................220223.233....................
865
+ t: 6 _ _ _
866
+ ....................2202.223.33.......................
867
+ t: 7 _ _ _
868
+ ................2202..223..33.........................
869
+ t: 8 _ _ _
870
+ ............2202...223...33...........................
871
+ t: 9 _ _ _
872
+ ........2202....223....33.............................
873
+
874
+ Example 4.13 from [Yamada2007]_::
875
+
876
+ sage: B = SolitonCellularAutomata([[3],[3],[1],[1],[1],[1],[2],[2],[2]], ['D',4,3])
877
+ sage: B.print_states(15)
878
+ t: 0
879
+ ....................................33....222
880
+ t: 1
881
+ ..................................33...222...
882
+ t: 2
883
+ ................................33..222......
884
+ t: 3
885
+ ..............................33.222.........
886
+ t: 4
887
+ ............................33222............
888
+ t: 5
889
+ ..........................3022...............
890
+ t: 6 _
891
+ ........................332..................
892
+ t: 7 _
893
+ ......................03.....................
894
+ t: 8 _
895
+ ....................3E.......................
896
+ t: 9 _
897
+ .................21..........................
898
+ t: 10
899
+ ..............20E............................
900
+ t: 11 _
901
+ ...........233...............................
902
+ t: 12
903
+ ........2302.................................
904
+ t: 13
905
+ .....23322...................................
906
+ t: 14
907
+ ..233.22.....................................
908
+
909
+ Example 4.14 from [Yamada2007]_::
910
+
911
+ sage: B = SolitonCellularAutomata([[3],[1],[1],[1],[2],[3],[1],[1],[1],[2],[3],[3]], ['D',4,3])
912
+ sage: B.print_states(15)
913
+ t: 0
914
+ ....................................3...23...233
915
+ t: 1
916
+ ...................................3..23..233...
917
+ t: 2
918
+ ..................................3.23.233......
919
+ t: 3
920
+ .................................323233.........
921
+ t: 4
922
+ ................................0033............
923
+ t: 5 _
924
+ ..............................313...............
925
+ t: 6
926
+ ...........................30E.3................
927
+ t: 7 _
928
+ ........................333...3.................
929
+ t: 8
930
+ .....................3302....3..................
931
+ t: 9
932
+ ..................33322.....3...................
933
+ t: 10
934
+ ...............333.22......3....................
935
+ t: 11
936
+ ............333..22.......3.....................
937
+ t: 12
938
+ .........333...22........3......................
939
+ t: 13
940
+ ......333....22.........3.......................
941
+ t: 14
942
+ ...333.....22..........3........................
943
+ """
944
+ if num is None:
945
+ num = len(self._states)
946
+ if num > len(self._states):
947
+ for _ in range(num - len(self._states)):
948
+ self.evolve()
949
+
950
+ vacuum = self._vacuum_elt
951
+ num_factors = len(self._states[num-1])
952
+ for i,state in enumerate(self._states[:num]):
953
+ state = [vacuum]*(num_factors - len(state)) + list(state)
954
+ output = [self._column_repr(b, vacuum_letter) for b in state]
955
+ max_width = max(b.width() for b in output)
956
+ start = ascii_art("t: %s \n" % i)
957
+ start._baseline = -1
958
+ print(start
959
+ + sum((ascii_art(' '*(max_width-b.width())) + b for b in output),
960
+ ascii_art('')))
961
+
962
+ def latex_states(self, num=None, as_array=True, box_width='5pt'):
963
+ r"""
964
+ Return a latex version of the states.
965
+
966
+ INPUT:
967
+
968
+ - ``num`` -- the number of states
969
+ - ``as_array`` -- boolean (default: ``True``); if ``True``, then the
970
+ states are placed inside of an array; if ``False``, then the states
971
+ are given as a word
972
+ - ``box_width`` -- (default: ``'5pt'``) the width of the ``.`` used
973
+ to represent the vacuum state when ``as_array`` is ``True``
974
+
975
+ If ``as_array`` is ``False``, then the vacuum element is printed
976
+ in a gray color. If ``as_array`` is ``True``, then the vacuum
977
+ is given as ``.``
978
+
979
+ Use the ``box_width`` to help create more even spacing when
980
+ a column in the output contains only vacuum elements.
981
+
982
+ EXAMPLES::
983
+
984
+ sage: B = SolitonCellularAutomata('411122', 4)
985
+ sage: B.latex_states(8)
986
+ {\arraycolsep=0.5pt \begin{array}{c|ccccccccccccccccccc}
987
+ t = 0 & \cdots & ... & \makebox[5pt]{.} & 4 & \makebox[5pt]{.}
988
+ & \makebox[5pt]{.} & \makebox[5pt]{.} & 2 & 2 \\
989
+ t = 1 & \cdots & ... & 4 & \makebox[5pt]{.} & \makebox[5pt]{.} & 2 & 2 & ... \\
990
+ t = 2 & \cdots & ... & 4 & \makebox[5pt]{.} & 2 & 2 & ... \\
991
+ t = 3 & \cdots & ... & 4 & 2 & 2 & ... \\
992
+ t = 4 & \cdots & ... & 2 & 4 & 2 & ... \\
993
+ t = 5 & \cdots & ... & 2 & 4 & \makebox[5pt]{.} & 2 & ... \\
994
+ t = 6 & \cdots & ... & 2 & 4 & \makebox[5pt]{.} & \makebox[5pt]{.}
995
+ & 2 & ... \\
996
+ t = 7 & \cdots & \makebox[5pt]{.} & 2 & 4 & \makebox[5pt]{.}
997
+ & \makebox[5pt]{.} & \makebox[5pt]{.} & 2 & ... \\
998
+ \end{array}}
999
+
1000
+ sage: B = SolitonCellularAutomata('511122', 5)
1001
+ sage: B.latex_states(8, as_array=False)
1002
+ {\begin{array}{c|c}
1003
+ t = 0 & \cdots ... {\color{gray} 1} 5 {\color{gray} 1}
1004
+ {\color{gray} 1} {\color{gray} 1} 2 2 \\
1005
+ t = 1 & \cdots ... 5 {\color{gray} 1} {\color{gray} 1} 2 2 ... \\
1006
+ t = 2 & \cdots ... 5 {\color{gray} 1} 2 2 ... \\
1007
+ t = 3 & \cdots ... 5 2 2 ... \\
1008
+ t = 4 & \cdots ... 2 5 2 ... \\
1009
+ t = 5 & \cdots ... 2 5 {\color{gray} 1} 2 ... \\
1010
+ t = 6 & \cdots ... 2 5 {\color{gray} 1} {\color{gray} 1} 2 ... \\
1011
+ t = 7 & \cdots {\color{gray} 1} 2 5 {\color{gray} 1}
1012
+ {\color{gray} 1} {\color{gray} 1} 2 ... \\
1013
+ \end{array}}
1014
+ """
1015
+ from sage.misc.latex import latex, LatexExpr
1016
+ if not as_array:
1017
+ latex.add_package_to_preamble_if_available('xcolor')
1018
+
1019
+ if num is None:
1020
+ num = len(self._states)
1021
+ if num > len(self._states):
1022
+ for _ in range(num - len(self._states)):
1023
+ self.evolve()
1024
+
1025
+ vacuum = self._vacuum_elt
1026
+
1027
+ def compact_repr(b):
1028
+ if as_array and b == vacuum:
1029
+ return "\\makebox[%s]{.}" % box_width
1030
+
1031
+ if b.parent()._tableau_height == 1:
1032
+ temp = latex(b[0])
1033
+ else:
1034
+ temp = "\\begin{array}{@{}c@{}}" # No padding around columns
1035
+ temp += r"\\".join(latex(letter) for letter in reversed(b))
1036
+ temp += "\\end{array}"
1037
+
1038
+ if b == vacuum:
1039
+ return "{\\color{gray} %s}" % temp
1040
+ return temp # "\\makebox[%s]{$%s$}"%(box_width, temp)
1041
+
1042
+ num_factors = len(self._states[num-1])
1043
+ if as_array:
1044
+ ret = "{\\arraycolsep=0.5pt \\begin{array}"
1045
+ ret += "{c|c%s}\n" % ('c'*num_factors)
1046
+ else:
1047
+ ret = "{\\begin{array}"
1048
+ ret += "{c|c}\n"
1049
+ for i,state in enumerate(self._states[:num]):
1050
+ state = [vacuum]*(num_factors-len(state)) + list(state)
1051
+ if as_array:
1052
+ ret += "t = %s & \\cdots & %s \\\\\n" % (i, r" & ".join(compact_repr(b) for b in state))
1053
+ else:
1054
+ ret += "t = %s & \\cdots %s \\\\\n" % (i, r" ".join(compact_repr(b) for b in state))
1055
+ ret += "\\end{array}}\n"
1056
+ return LatexExpr(ret)
1057
+
1058
+ def print_state_evolution(self, num):
1059
+ r"""
1060
+ Print the evolution process of the state ``num``.
1061
+
1062
+ .. SEEALSO::
1063
+
1064
+ :meth:`state_evolution`, :meth:`latex_state_evolution`
1065
+
1066
+ EXAMPLES::
1067
+
1068
+ sage: B = SolitonCellularAutomata('1113123', 3)
1069
+ sage: B.evolve(3)
1070
+ sage: B.evolve(3)
1071
+ sage: B.print_state_evolution(0)
1072
+ 1 1 1 3 1 2 3
1073
+ | | | | | | |
1074
+ 111 --+-- 111 --+-- 111 --+-- 113 --+-- 112 --+-- 123 --+-- 113 --+-- 111
1075
+ | | | | | | |
1076
+ 1 1 3 2 3 1 1
1077
+ sage: B.print_state_evolution(1)
1078
+ 1 1 3 2 3 1 1
1079
+ | | | | | | |
1080
+ 111 --+-- 113 --+-- 133 --+-- 123 --+-- 113 --+-- 111 --+-- 111 --+-- 111
1081
+ | | | | | | |
1082
+ 3 3 2 1 1 1 1
1083
+ """
1084
+ u = self.state_evolution(num) # Also evolves as necessary
1085
+ final = self._states[num+1]
1086
+ vacuum = self._vacuum_elt
1087
+ state = [vacuum]*(len(final) - len(self._states[num])) + list(self._states[num])
1088
+ carrier = KirillovReshetikhinTableaux(self._cartan_type, *self._evolutions[num])
1089
+
1090
+ def simple_repr(x):
1091
+ return ''.join(repr(x).strip('[]').split(', '))
1092
+
1093
+ def carrier_repr(x):
1094
+ if carrier._tableau_height == 1:
1095
+ return sum((ascii_art(repr(b)) if repr(b)[0] != '-'
1096
+ else ascii_art("_" + '\n' + repr(b)[1:])
1097
+ for b in x),
1098
+ ascii_art(''))
1099
+ return ascii_art(''.join(repr(x).strip('[]').split(', ')))
1100
+
1101
+ def cross_repr(i):
1102
+ ret = ascii_art(
1103
+ """
1104
+ {!s:^7}
1105
+ |
1106
+ --+--
1107
+ |
1108
+ {!s:^7}
1109
+ """.format(simple_repr(state[i]), simple_repr(final[i])))
1110
+ ret._baseline = 2
1111
+ return ret
1112
+ art = sum((cross_repr(i)
1113
+ + carrier_repr(u[i+1])
1114
+ for i in range(len(state))), ascii_art(''))
1115
+ print(ascii_art(carrier_repr(u[0])) + art)
1116
+
1117
+ def latex_state_evolution(self, num, scale=1):
1118
+ r"""
1119
+ Return a latex version of the evolution process of
1120
+ the state ``num``.
1121
+
1122
+ .. SEEALSO::
1123
+
1124
+ :meth:`state_evolution`, :meth:`print_state_evolution`
1125
+
1126
+ EXAMPLES::
1127
+
1128
+ sage: B = SolitonCellularAutomata('113123', 3)
1129
+ sage: B.evolve(3)
1130
+ sage: B.latex_state_evolution(0)
1131
+ \begin{tikzpicture}[scale=1]
1132
+ \node (i0) at (0.0,0.9) {$1$};
1133
+ \node (i1) at (2.48,0.9) {$1$};
1134
+ \node (i2) at (4.96,0.9) {$3$};
1135
+ ...
1136
+ \draw[->] (i5) -- (t5);
1137
+ \draw[->] (u6) -- (u5);
1138
+ \end{tikzpicture}
1139
+ sage: B.latex_state_evolution(1)
1140
+ \begin{tikzpicture}[scale=1]
1141
+ ...
1142
+ \end{tikzpicture}
1143
+ """
1144
+ from sage.graphs.graph_latex import setup_latex_preamble
1145
+ from sage.misc.latex import LatexExpr
1146
+ setup_latex_preamble()
1147
+ u = self.state_evolution(num) # Also evolves as necessary
1148
+ final = self._states[num+1]
1149
+ vacuum = self._vacuum_elt
1150
+ initial = [vacuum]*(len(final) - len(self._states[num])) + list(self._states[num])
1151
+ cs = len(u[0]) * 0.08 + 1 # carrier scaling
1152
+
1153
+ def simple_repr(x):
1154
+ return ''.join(repr(x).strip('[]').split(', '))
1155
+ ret = '\\begin{{tikzpicture}}[scale={}]\n'.format(scale)
1156
+ for i,val in enumerate(initial):
1157
+ ret += '\\node (i{}) at ({},0.9) {{${}$}};\n'.format(i, 2*i*cs, simple_repr(val))
1158
+ for i,val in enumerate(final):
1159
+ ret += '\\node (t{}) at ({},-1) {{${}$}};\n'.format(i, 2*i*cs, simple_repr(val))
1160
+ for i,val in enumerate(u):
1161
+ ret += '\\node (u{}) at ({},0) {{${}$}};\n'.format(i, (2*i-1)*cs, simple_repr(val))
1162
+ for i in range(len(initial)):
1163
+ ret += '\\draw[->] (i{}) -- (t{});\n'.format(i, i)
1164
+ ret += '\\draw[->] (u{}) -- (u{});\n'.format(i+1, i)
1165
+ ret += '\\end{tikzpicture}'
1166
+ return LatexExpr(ret)
1167
+
1168
+
1169
+ class PeriodicSolitonCellularAutomata(SolitonCellularAutomata):
1170
+ r"""
1171
+ A periodic soliton cellular automata.
1172
+
1173
+ Fix some `r \in I_0`. A *periodic soliton cellular automata* is a
1174
+ :class:`SolitonCellularAutomata` with a state being a fixed number of
1175
+ tensor factors `p = p_{\ell} \otimes \cdots \otimes p_1 \otimes p_0`
1176
+ and the *time evolution* `T_s` is defined by
1177
+
1178
+ .. MATH::
1179
+
1180
+ R(p \otimes u) = u \otimes T_s(p),
1181
+
1182
+ for some element `u \in B^{r,s}`.
1183
+
1184
+ INPUT:
1185
+
1186
+ - ``initial_state`` -- the list of elements, can also be a string
1187
+ when ``vacuum`` is 1 and ``n`` is `\mathfrak{sl}_n`
1188
+ - ``cartan_type`` -- (default: 2) the value ``n``, for `\mathfrak{sl}_n`,
1189
+ or a Cartan type
1190
+ - ``r`` -- (default: 1) the node index `r`; typically this
1191
+ corresponds to the height of the vacuum element
1192
+
1193
+ EXAMPLES:
1194
+
1195
+ The construction and usage is the same as for
1196
+ :class:`SolitonCellularAutomata`::
1197
+
1198
+ sage: P = PeriodicSolitonCellularAutomata('1123334111241111423111411123112', 4)
1199
+ sage: P.evolve()
1200
+ sage: P
1201
+ Soliton cellular automata of type ['A', 3, 1] and vacuum = 1
1202
+ initial state:
1203
+ ..23334...24....423...4...23..2
1204
+ evoltuions: [(1, 31)]
1205
+ current state:
1206
+ 34......24....243....4.223.233.
1207
+ sage: P.evolve(carrier_capacity=2)
1208
+ sage: P.evolve(carrier_index=2)
1209
+ sage: P.evolve(carrier_index=2, carrier_capacity=3)
1210
+ sage: P.print_states(10)
1211
+ t: 0
1212
+ ..23334...24....423...4...23..2
1213
+ t: 1
1214
+ 34......24....243....4.223.233.
1215
+ t: 2
1216
+ ......24....24.3....4223.2333.4
1217
+ t: 3
1218
+ .....34....34.2..223234.24...3.
1219
+ t: 4
1220
+ ....34...23..242223.4..33....4.
1221
+ t: 5
1222
+ ..34.2223.224.3....4.33.....4..
1223
+ t: 6
1224
+ 34223...24...3....433......4.22
1225
+ t: 7
1226
+ 23....24....3...343....222434..
1227
+ t: 8
1228
+ ....24.....3..34.322244...3..23
1229
+ t: 9
1230
+ ..24.....332442342.......3.23..
1231
+
1232
+ Using `r = 2` in type `A_3^{(1)}`::
1233
+
1234
+ sage: initial = [[2,1],[2,1],[4,1],[2,1],[2,1],[2,1],[3,1],[3,1],[3,2]]
1235
+ sage: P = PeriodicSolitonCellularAutomata(initial, 4, 2)
1236
+ sage: P.print_states(10)
1237
+ t: 0 4 333
1238
+ ..1...112
1239
+ t: 1 4 333
1240
+ .1.112...
1241
+ t: 2 433 3
1242
+ 112.....1
1243
+ t: 3 3 334
1244
+ 2....111.
1245
+ t: 4 334 3
1246
+ ..111...2
1247
+ t: 5 34 33
1248
+ 11.....21
1249
+ t: 6 3334
1250
+ ....1121.
1251
+ t: 7 333 4
1252
+ .112..1..
1253
+ t: 8 3 4 33
1254
+ 2....1.11
1255
+ t: 9 3433
1256
+ ...1112..
1257
+
1258
+ We do some examples in other types::
1259
+
1260
+ sage: initial = [[1],[2],[2],[1],[1],[1],[3],[1],['E'],[1],[1]]
1261
+ sage: P = PeriodicSolitonCellularAutomata(initial, ['D',4,3])
1262
+ sage: P.print_states(10)
1263
+ t: 0
1264
+ .22...3.E..
1265
+ t: 1
1266
+ 2....3.E..2
1267
+ t: 2
1268
+ ....3.E.22.
1269
+ t: 3
1270
+ ...3.E22...
1271
+ t: 4
1272
+ ..32E2.....
1273
+ t: 5
1274
+ .00.2......
1275
+ t: 6 _
1276
+ 22.2.......
1277
+ t: 7
1278
+ 2.2......3E
1279
+ t: 8
1280
+ .2.....30.2
1281
+ t: 9
1282
+ 2....332.2.
1283
+
1284
+ sage: P = PeriodicSolitonCellularAutomata([[3],[2],[1],[1],[-2]], ['C',2,1])
1285
+ sage: P.print_state_evolution(0)
1286
+ 3 2 1 1 -2
1287
+ _ | | | _ | __ | _
1288
+ 11112 --+-- 11112 --+-- 11111 --+-- 11112 --+-- 11122 --+-- 11112
1289
+ | | | | |
1290
+ 2 1 -2 -2 1
1291
+
1292
+ REFERENCES:
1293
+
1294
+ - [KTT2006]_
1295
+ - [KS2006]_
1296
+ - [YT2002]_
1297
+ - [YYT2003]_
1298
+ """
1299
+ def evolve(self, carrier_capacity=None, carrier_index=None, number=None):
1300
+ r"""
1301
+ Evolve ``self``.
1302
+
1303
+ Time evolution `T_s` of a SCA state `p` is determined by
1304
+
1305
+ .. MATH::
1306
+
1307
+ u \otimes T_s(p) = R(p \otimes u),
1308
+
1309
+ where `u` is some element in `B^{r,s}`.
1310
+
1311
+ INPUT:
1312
+
1313
+ - ``carrier_capacity`` -- (default: the number of balls in
1314
+ the system) the size `s` of carrier
1315
+
1316
+ - ``carrier_index`` -- (default: the vacuum index) the index `r`
1317
+ of the carrier
1318
+
1319
+ - ``number`` -- (optional) the number of times to perform
1320
+ the evolutions
1321
+
1322
+ To perform multiple evolutions of the SCA, ``carrier_capacity``
1323
+ and ``carrier_index`` may be lists of the same length.
1324
+
1325
+ .. WARNING::
1326
+
1327
+ Time evolution is only guaranteed to result in a solution
1328
+ when the ``carrier_index`` is the defining `r` of the SCA.
1329
+ If no solution is found, then this will raise an error.
1330
+
1331
+ EXAMPLES::
1332
+
1333
+ sage: P = PeriodicSolitonCellularAutomata('12411133214131221122', 4)
1334
+ sage: P.evolve()
1335
+ sage: P.print_state(0)
1336
+ .24...332.4.3.22..22
1337
+ sage: P.print_state(1)
1338
+ 4...33.2.42322..22..
1339
+ sage: P.evolve(carrier_capacity=2)
1340
+ sage: P.print_state(2)
1341
+ ..33.22.4232..22...4
1342
+ sage: P.evolve(carrier_capacity=[1,3,1,2])
1343
+ sage: P.evolve(1, number=3)
1344
+ sage: P.print_states(10)
1345
+ t: 0
1346
+ .24...332.4.3.22..22
1347
+ t: 1
1348
+ 4...33.2.42322..22..
1349
+ t: 2
1350
+ ..33.22.4232..22...4
1351
+ t: 3
1352
+ .33.22.4232..22...4.
1353
+ t: 4
1354
+ 3222..43.2.22....4.3
1355
+ t: 5
1356
+ 222..43.2.22....4.33
1357
+ t: 6
1358
+ 2...4322.2.....43322
1359
+ t: 7
1360
+ ...4322.2.....433222
1361
+ t: 8
1362
+ ..4322.2.....433222.
1363
+ t: 9
1364
+ .4322.2.....433222..
1365
+
1366
+ sage: P = PeriodicSolitonCellularAutomata('12411132121', 4)
1367
+ sage: P.evolve(carrier_index=2, carrier_capacity=3)
1368
+ sage: P.state_evolution(0)
1369
+ [[[1, 1, 1], [2, 2, 4]],
1370
+ [[1, 1, 2], [2, 2, 4]],
1371
+ [[1, 1, 3], [2, 2, 4]],
1372
+ [[1, 1, 1], [2, 2, 3]],
1373
+ [[1, 1, 1], [2, 2, 3]],
1374
+ [[1, 1, 1], [2, 2, 3]],
1375
+ [[1, 1, 2], [2, 2, 3]],
1376
+ [[1, 1, 1], [2, 2, 2]],
1377
+ [[1, 1, 1], [2, 2, 2]],
1378
+ [[1, 1, 1], [2, 2, 2]],
1379
+ [[1, 1, 1], [2, 2, 4]],
1380
+ [[1, 1, 1], [2, 2, 4]]]
1381
+ """
1382
+ if isinstance(carrier_capacity, (list, tuple)):
1383
+ if not isinstance(carrier_index, (list, tuple)):
1384
+ carrier_index = [carrier_index] * len(carrier_capacity)
1385
+ if len(carrier_index) != len(carrier_capacity):
1386
+ raise ValueError("carrier_index and carrier_capacity"
1387
+ " must have the same length")
1388
+ for i, r in zip(carrier_capacity, carrier_index):
1389
+ self.evolve(i, r)
1390
+ return
1391
+ if isinstance(carrier_index, (list, tuple)):
1392
+ # carrier_capacity must be not be a list/tuple if given
1393
+ for r in carrier_index:
1394
+ self.evolve(carrier_capacity, r)
1395
+ return
1396
+
1397
+ if carrier_capacity is None:
1398
+ carrier_capacity = self._nballs
1399
+ if carrier_index is None:
1400
+ carrier_index = self._vacuum
1401
+
1402
+ if number is not None:
1403
+ for _ in range(number):
1404
+ self.evolve(carrier_capacity, carrier_index)
1405
+ return
1406
+ if carrier_capacity is None:
1407
+ carrier_capacity = self._nballs
1408
+ if carrier_index is None:
1409
+ carrier_index = self._vacuum
1410
+
1411
+ K = KirillovReshetikhinTableaux(self._cartan_type, carrier_index, carrier_capacity)
1412
+ carrier_factor = (carrier_index, carrier_capacity)
1413
+ state = self._states[-1]
1414
+ dims = state.parent().dims
1415
+ for carrier in K:
1416
+ KRT = TensorProductOfKirillovReshetikhinTableaux(self._cartan_type,
1417
+ dims + (carrier_factor,))
1418
+ elt = KRT(*(list(state) + [carrier]))
1419
+ RC = RiggedConfigurations(self._cartan_type, (carrier_factor,) + dims)
1420
+ elt2 = RC(*elt.to_rigged_configuration()).to_tensor_product_of_kirillov_reshetikhin_tableaux()
1421
+ # Back to an empty carrier or we are not getting any better
1422
+ if elt2[0] == carrier:
1423
+ KRT = TensorProductOfKirillovReshetikhinTableaux(self._cartan_type, dims)
1424
+ self._states.append(KRT(*elt2[1:]))
1425
+ self._evolutions.append(carrier_factor)
1426
+ self._initial_carrier.append(carrier)
1427
+ break
1428
+ else:
1429
+ raise ValueError("cannot find solution to time evolution")
1430
+
1431
+ def __eq__(self, other):
1432
+ """
1433
+ Check equality.
1434
+
1435
+ Two periodic SCAs are equal when they have the same initial
1436
+ state and evolutions.
1437
+
1438
+ TESTS::
1439
+
1440
+ sage: P1 = PeriodicSolitonCellularAutomata('34112223', 4)
1441
+ sage: P2 = PeriodicSolitonCellularAutomata('34112223', 4)
1442
+ sage: P1 == P2
1443
+ True
1444
+ sage: P1.evolve()
1445
+ sage: P1 == P2
1446
+ False
1447
+ sage: P2.evolve()
1448
+ sage: P1 == P2
1449
+ True
1450
+ sage: P1.evolve(5)
1451
+ sage: P2.evolve(6)
1452
+ sage: P1 == P2
1453
+ False
1454
+
1455
+ sage: P = PeriodicSolitonCellularAutomata('34112223', 4)
1456
+ sage: B = SolitonCellularAutomata('34112223', 4)
1457
+ sage: P == B
1458
+ False
1459
+ sage: B == P
1460
+ False
1461
+ """
1462
+ return (isinstance(other, PeriodicSolitonCellularAutomata)
1463
+ and SolitonCellularAutomata.__eq__(self, other))