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.
- passagemath_combinat/__init__.py +3 -0
- passagemath_combinat-10.6.42.dist-info/METADATA +160 -0
- passagemath_combinat-10.6.42.dist-info/RECORD +400 -0
- passagemath_combinat-10.6.42.dist-info/WHEEL +5 -0
- passagemath_combinat-10.6.42.dist-info/top_level.txt +3 -0
- passagemath_combinat.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- passagemath_combinat.libs/libsymmetrica-81fe8739.so.3.0.0 +0 -0
- sage/algebras/affine_nil_temperley_lieb.py +263 -0
- sage/algebras/all.py +24 -0
- sage/algebras/all__sagemath_combinat.py +35 -0
- sage/algebras/askey_wilson.py +935 -0
- sage/algebras/associated_graded.py +345 -0
- sage/algebras/cellular_basis.py +350 -0
- sage/algebras/cluster_algebra.py +2766 -0
- sage/algebras/down_up_algebra.py +860 -0
- sage/algebras/free_algebra.py +1698 -0
- sage/algebras/free_algebra_element.py +345 -0
- sage/algebras/free_algebra_quotient.py +405 -0
- sage/algebras/free_algebra_quotient_element.py +295 -0
- sage/algebras/free_zinbiel_algebra.py +885 -0
- sage/algebras/hall_algebra.py +783 -0
- sage/algebras/hecke_algebras/all.py +4 -0
- sage/algebras/hecke_algebras/ariki_koike_algebra.py +1796 -0
- sage/algebras/hecke_algebras/ariki_koike_specht_modules.py +475 -0
- sage/algebras/hecke_algebras/cubic_hecke_algebra.py +3520 -0
- sage/algebras/hecke_algebras/cubic_hecke_base_ring.py +1473 -0
- sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py +1079 -0
- sage/algebras/iwahori_hecke_algebra.py +3095 -0
- sage/algebras/jordan_algebra.py +1773 -0
- sage/algebras/lie_conformal_algebras/abelian_lie_conformal_algebra.py +113 -0
- sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py +156 -0
- sage/algebras/lie_conformal_algebras/all.py +18 -0
- sage/algebras/lie_conformal_algebras/bosonic_ghosts_lie_conformal_algebra.py +134 -0
- sage/algebras/lie_conformal_algebras/examples.py +43 -0
- sage/algebras/lie_conformal_algebras/fermionic_ghosts_lie_conformal_algebra.py +131 -0
- sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py +139 -0
- sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py +174 -0
- sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py +167 -0
- sage/algebras/lie_conformal_algebras/freely_generated_lie_conformal_algebra.py +107 -0
- sage/algebras/lie_conformal_algebras/graded_lie_conformal_algebra.py +135 -0
- sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py +353 -0
- sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py +236 -0
- sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_basis.py +78 -0
- sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py +328 -0
- sage/algebras/lie_conformal_algebras/n2_lie_conformal_algebra.py +117 -0
- sage/algebras/lie_conformal_algebras/neveu_schwarz_lie_conformal_algebra.py +86 -0
- sage/algebras/lie_conformal_algebras/virasoro_lie_conformal_algebra.py +82 -0
- sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py +205 -0
- sage/algebras/nil_coxeter_algebra.py +191 -0
- sage/algebras/q_commuting_polynomials.py +673 -0
- sage/algebras/q_system.py +608 -0
- sage/algebras/quantum_clifford.py +959 -0
- sage/algebras/quantum_groups/ace_quantum_onsager.py +693 -0
- sage/algebras/quantum_groups/all.py +9 -0
- sage/algebras/quantum_groups/fock_space.py +2219 -0
- sage/algebras/quantum_groups/q_numbers.py +207 -0
- sage/algebras/quantum_groups/quantum_group_gap.py +2695 -0
- sage/algebras/quantum_groups/representations.py +591 -0
- sage/algebras/quantum_matrix_coordinate_algebra.py +1006 -0
- sage/algebras/quantum_oscillator.py +623 -0
- sage/algebras/quaternion_algebra.py +20 -0
- sage/algebras/quaternion_algebra_element.py +55 -0
- sage/algebras/rational_cherednik_algebra.py +525 -0
- sage/algebras/schur_algebra.py +670 -0
- sage/algebras/shuffle_algebra.py +1011 -0
- sage/algebras/splitting_algebra.py +779 -0
- sage/algebras/tensor_algebra.py +709 -0
- sage/algebras/yangian.py +1082 -0
- sage/algebras/yokonuma_hecke_algebra.py +1018 -0
- sage/all__sagemath_combinat.py +35 -0
- sage/combinat/SJT.py +255 -0
- sage/combinat/affine_permutation.py +2405 -0
- sage/combinat/algebraic_combinatorics.py +55 -0
- sage/combinat/all.py +53 -0
- sage/combinat/all__sagemath_combinat.py +195 -0
- sage/combinat/alternating_sign_matrix.py +2063 -0
- sage/combinat/baxter_permutations.py +346 -0
- sage/combinat/bijectionist.py +3220 -0
- sage/combinat/binary_recurrence_sequences.py +1180 -0
- sage/combinat/blob_algebra.py +685 -0
- sage/combinat/catalog_partitions.py +27 -0
- sage/combinat/chas/all.py +23 -0
- sage/combinat/chas/fsym.py +1180 -0
- sage/combinat/chas/wqsym.py +2601 -0
- sage/combinat/cluster_complex.py +326 -0
- sage/combinat/colored_permutations.py +2039 -0
- sage/combinat/colored_permutations_representations.py +964 -0
- sage/combinat/composition_signed.py +142 -0
- sage/combinat/composition_tableau.py +855 -0
- sage/combinat/constellation.py +1729 -0
- sage/combinat/core.py +751 -0
- sage/combinat/counting.py +12 -0
- sage/combinat/crystals/affine.py +742 -0
- sage/combinat/crystals/affine_factorization.py +518 -0
- sage/combinat/crystals/affinization.py +331 -0
- sage/combinat/crystals/alcove_path.py +2013 -0
- sage/combinat/crystals/all.py +22 -0
- sage/combinat/crystals/bkk_crystals.py +141 -0
- sage/combinat/crystals/catalog.py +115 -0
- sage/combinat/crystals/catalog_elementary_crystals.py +18 -0
- sage/combinat/crystals/catalog_infinity_crystals.py +33 -0
- sage/combinat/crystals/catalog_kirillov_reshetikhin.py +18 -0
- sage/combinat/crystals/crystals.py +257 -0
- sage/combinat/crystals/direct_sum.py +260 -0
- sage/combinat/crystals/elementary_crystals.py +1251 -0
- sage/combinat/crystals/fast_crystals.py +441 -0
- sage/combinat/crystals/fully_commutative_stable_grothendieck.py +1205 -0
- sage/combinat/crystals/generalized_young_walls.py +1076 -0
- sage/combinat/crystals/highest_weight_crystals.py +436 -0
- sage/combinat/crystals/induced_structure.py +695 -0
- sage/combinat/crystals/infinity_crystals.py +730 -0
- sage/combinat/crystals/kac_modules.py +863 -0
- sage/combinat/crystals/kirillov_reshetikhin.py +4196 -0
- sage/combinat/crystals/kyoto_path_model.py +497 -0
- sage/combinat/crystals/letters.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/crystals/letters.pxd +79 -0
- sage/combinat/crystals/letters.pyx +3056 -0
- sage/combinat/crystals/littelmann_path.py +1518 -0
- sage/combinat/crystals/monomial_crystals.py +1262 -0
- sage/combinat/crystals/multisegments.py +462 -0
- sage/combinat/crystals/mv_polytopes.py +467 -0
- sage/combinat/crystals/pbw_crystal.py +511 -0
- sage/combinat/crystals/pbw_datum.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/crystals/pbw_datum.pxd +4 -0
- sage/combinat/crystals/pbw_datum.pyx +487 -0
- sage/combinat/crystals/polyhedral_realization.py +372 -0
- sage/combinat/crystals/spins.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/crystals/spins.pxd +21 -0
- sage/combinat/crystals/spins.pyx +756 -0
- sage/combinat/crystals/star_crystal.py +290 -0
- sage/combinat/crystals/subcrystal.py +464 -0
- sage/combinat/crystals/tensor_product.py +1177 -0
- sage/combinat/crystals/tensor_product_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/crystals/tensor_product_element.pxd +35 -0
- sage/combinat/crystals/tensor_product_element.pyx +1870 -0
- sage/combinat/crystals/virtual_crystal.py +420 -0
- sage/combinat/cyclic_sieving_phenomenon.py +204 -0
- sage/combinat/debruijn_sequence.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/debruijn_sequence.pyx +355 -0
- sage/combinat/decorated_permutation.py +270 -0
- sage/combinat/degree_sequences.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/degree_sequences.pyx +588 -0
- sage/combinat/derangements.py +527 -0
- sage/combinat/descent_algebra.py +1008 -0
- sage/combinat/diagram.py +1551 -0
- sage/combinat/diagram_algebras.py +5886 -0
- sage/combinat/dyck_word.py +4349 -0
- sage/combinat/e_one_star.py +1623 -0
- sage/combinat/enumerated_sets.py +123 -0
- sage/combinat/expnums.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/expnums.pyx +148 -0
- sage/combinat/fast_vector_partitions.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/fast_vector_partitions.pyx +346 -0
- sage/combinat/fqsym.py +1977 -0
- sage/combinat/free_dendriform_algebra.py +954 -0
- sage/combinat/free_prelie_algebra.py +1141 -0
- sage/combinat/fully_commutative_elements.py +1077 -0
- sage/combinat/fully_packed_loop.py +1523 -0
- sage/combinat/gelfand_tsetlin_patterns.py +1409 -0
- sage/combinat/gray_codes.py +311 -0
- sage/combinat/grossman_larson_algebras.py +667 -0
- sage/combinat/growth.py +4352 -0
- sage/combinat/hall_polynomial.py +188 -0
- sage/combinat/hillman_grassl.py +866 -0
- sage/combinat/integer_matrices.py +329 -0
- sage/combinat/integer_vectors_mod_permgroup.py +1238 -0
- sage/combinat/k_tableau.py +4564 -0
- sage/combinat/kazhdan_lusztig.py +215 -0
- sage/combinat/key_polynomial.py +885 -0
- sage/combinat/knutson_tao_puzzles.py +2286 -0
- sage/combinat/lr_tableau.py +311 -0
- sage/combinat/matrices/all.py +24 -0
- sage/combinat/matrices/hadamard_matrix.py +3790 -0
- sage/combinat/matrices/latin.py +2912 -0
- sage/combinat/misc.py +401 -0
- sage/combinat/multiset_partition_into_sets_ordered.py +3541 -0
- sage/combinat/ncsf_qsym/all.py +21 -0
- sage/combinat/ncsf_qsym/combinatorics.py +317 -0
- sage/combinat/ncsf_qsym/generic_basis_code.py +1427 -0
- sage/combinat/ncsf_qsym/ncsf.py +5637 -0
- sage/combinat/ncsf_qsym/qsym.py +4053 -0
- sage/combinat/ncsf_qsym/tutorial.py +447 -0
- sage/combinat/ncsym/all.py +21 -0
- sage/combinat/ncsym/bases.py +855 -0
- sage/combinat/ncsym/dual.py +593 -0
- sage/combinat/ncsym/ncsym.py +2076 -0
- sage/combinat/necklace.py +551 -0
- sage/combinat/non_decreasing_parking_function.py +634 -0
- sage/combinat/nu_dyck_word.py +1474 -0
- sage/combinat/output.py +861 -0
- sage/combinat/parallelogram_polyomino.py +4326 -0
- sage/combinat/parking_functions.py +1602 -0
- sage/combinat/partition_algebra.py +1998 -0
- sage/combinat/partition_kleshchev.py +1982 -0
- sage/combinat/partition_shifting_algebras.py +584 -0
- sage/combinat/partition_tuple.py +3114 -0
- sage/combinat/path_tableaux/all.py +13 -0
- sage/combinat/path_tableaux/catalog.py +29 -0
- sage/combinat/path_tableaux/dyck_path.py +380 -0
- sage/combinat/path_tableaux/frieze.py +476 -0
- sage/combinat/path_tableaux/path_tableau.py +728 -0
- sage/combinat/path_tableaux/semistandard.py +510 -0
- sage/combinat/perfect_matching.py +779 -0
- sage/combinat/plane_partition.py +3300 -0
- sage/combinat/q_bernoulli.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/q_bernoulli.pyx +128 -0
- sage/combinat/quickref.py +81 -0
- sage/combinat/recognizable_series.py +2051 -0
- sage/combinat/regular_sequence.py +4316 -0
- sage/combinat/regular_sequence_bounded.py +543 -0
- sage/combinat/restricted_growth.py +81 -0
- sage/combinat/ribbon.py +20 -0
- sage/combinat/ribbon_shaped_tableau.py +489 -0
- sage/combinat/ribbon_tableau.py +1180 -0
- sage/combinat/rigged_configurations/all.py +46 -0
- sage/combinat/rigged_configurations/bij_abstract_class.py +548 -0
- sage/combinat/rigged_configurations/bij_infinity.py +370 -0
- sage/combinat/rigged_configurations/bij_type_A.py +163 -0
- sage/combinat/rigged_configurations/bij_type_A2_dual.py +338 -0
- sage/combinat/rigged_configurations/bij_type_A2_even.py +218 -0
- sage/combinat/rigged_configurations/bij_type_A2_odd.py +199 -0
- sage/combinat/rigged_configurations/bij_type_B.py +900 -0
- sage/combinat/rigged_configurations/bij_type_C.py +267 -0
- sage/combinat/rigged_configurations/bij_type_D.py +771 -0
- sage/combinat/rigged_configurations/bij_type_D_tri.py +392 -0
- sage/combinat/rigged_configurations/bij_type_D_twisted.py +576 -0
- sage/combinat/rigged_configurations/bij_type_E67.py +402 -0
- sage/combinat/rigged_configurations/bijection.py +143 -0
- sage/combinat/rigged_configurations/kleber_tree.py +1475 -0
- sage/combinat/rigged_configurations/kr_tableaux.py +1898 -0
- sage/combinat/rigged_configurations/rc_crystal.py +461 -0
- sage/combinat/rigged_configurations/rc_infinity.py +540 -0
- sage/combinat/rigged_configurations/rigged_configuration_element.py +2403 -0
- sage/combinat/rigged_configurations/rigged_configurations.py +1918 -0
- sage/combinat/rigged_configurations/rigged_partition.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/rigged_configurations/rigged_partition.pxd +15 -0
- sage/combinat/rigged_configurations/rigged_partition.pyx +680 -0
- sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py +499 -0
- sage/combinat/rigged_configurations/tensor_product_kr_tableaux_element.py +428 -0
- sage/combinat/rsk.py +3438 -0
- sage/combinat/schubert_polynomial.py +508 -0
- sage/combinat/set_partition.py +3318 -0
- sage/combinat/set_partition_iterator.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/set_partition_iterator.pyx +136 -0
- sage/combinat/set_partition_ordered.py +1590 -0
- sage/combinat/sf/abreu_nigro.py +346 -0
- sage/combinat/sf/all.py +52 -0
- sage/combinat/sf/character.py +576 -0
- sage/combinat/sf/classical.py +319 -0
- sage/combinat/sf/dual.py +996 -0
- sage/combinat/sf/elementary.py +549 -0
- sage/combinat/sf/hall_littlewood.py +1028 -0
- sage/combinat/sf/hecke.py +336 -0
- sage/combinat/sf/homogeneous.py +464 -0
- sage/combinat/sf/jack.py +1428 -0
- sage/combinat/sf/k_dual.py +1458 -0
- sage/combinat/sf/kfpoly.py +447 -0
- sage/combinat/sf/llt.py +789 -0
- sage/combinat/sf/macdonald.py +2019 -0
- sage/combinat/sf/monomial.py +525 -0
- sage/combinat/sf/multiplicative.py +113 -0
- sage/combinat/sf/new_kschur.py +1786 -0
- sage/combinat/sf/ns_macdonald.py +964 -0
- sage/combinat/sf/orthogonal.py +246 -0
- sage/combinat/sf/orthotriang.py +355 -0
- sage/combinat/sf/powersum.py +963 -0
- sage/combinat/sf/schur.py +880 -0
- sage/combinat/sf/sf.py +1653 -0
- sage/combinat/sf/sfa.py +7053 -0
- sage/combinat/sf/symplectic.py +253 -0
- sage/combinat/sf/witt.py +721 -0
- sage/combinat/shifted_primed_tableau.py +2735 -0
- sage/combinat/shuffle.py +830 -0
- sage/combinat/sidon_sets.py +146 -0
- sage/combinat/similarity_class_type.py +1721 -0
- sage/combinat/sine_gordon.py +618 -0
- sage/combinat/six_vertex_model.py +784 -0
- sage/combinat/skew_partition.py +2053 -0
- sage/combinat/skew_tableau.py +2989 -0
- sage/combinat/sloane_functions.py +8935 -0
- sage/combinat/specht_module.py +1403 -0
- sage/combinat/species/all.py +48 -0
- sage/combinat/species/characteristic_species.py +321 -0
- sage/combinat/species/composition_species.py +273 -0
- sage/combinat/species/cycle_species.py +284 -0
- sage/combinat/species/empty_species.py +155 -0
- sage/combinat/species/functorial_composition_species.py +148 -0
- sage/combinat/species/generating_series.py +673 -0
- sage/combinat/species/library.py +148 -0
- sage/combinat/species/linear_order_species.py +169 -0
- sage/combinat/species/misc.py +83 -0
- sage/combinat/species/partition_species.py +290 -0
- sage/combinat/species/permutation_species.py +268 -0
- sage/combinat/species/product_species.py +423 -0
- sage/combinat/species/recursive_species.py +476 -0
- sage/combinat/species/set_species.py +192 -0
- sage/combinat/species/species.py +820 -0
- sage/combinat/species/structure.py +539 -0
- sage/combinat/species/subset_species.py +243 -0
- sage/combinat/species/sum_species.py +225 -0
- sage/combinat/subword.py +564 -0
- sage/combinat/subword_complex.py +2122 -0
- sage/combinat/subword_complex_c.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/subword_complex_c.pyx +119 -0
- sage/combinat/super_tableau.py +821 -0
- sage/combinat/superpartition.py +1154 -0
- sage/combinat/symmetric_group_algebra.py +3774 -0
- sage/combinat/symmetric_group_representations.py +1830 -0
- sage/combinat/t_sequences.py +877 -0
- sage/combinat/tableau.py +9506 -0
- sage/combinat/tableau_residues.py +860 -0
- sage/combinat/tableau_tuple.py +5353 -0
- sage/combinat/tiling.py +2432 -0
- sage/combinat/triangles_FHM.py +777 -0
- sage/combinat/tutorial.py +1857 -0
- sage/combinat/vector_partition.py +337 -0
- sage/combinat/words/abstract_word.py +1722 -0
- sage/combinat/words/all.py +59 -0
- sage/combinat/words/alphabet.py +268 -0
- sage/combinat/words/finite_word.py +7201 -0
- sage/combinat/words/infinite_word.py +113 -0
- sage/combinat/words/lyndon_word.py +652 -0
- sage/combinat/words/morphic.py +351 -0
- sage/combinat/words/morphism.py +3878 -0
- sage/combinat/words/paths.py +2932 -0
- sage/combinat/words/shuffle_product.py +278 -0
- sage/combinat/words/suffix_trees.py +1873 -0
- sage/combinat/words/word.py +769 -0
- sage/combinat/words/word_char.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/words/word_char.pyx +847 -0
- sage/combinat/words/word_datatypes.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/words/word_datatypes.pxd +4 -0
- sage/combinat/words/word_datatypes.pyx +1067 -0
- sage/combinat/words/word_generators.py +2026 -0
- sage/combinat/words/word_infinite_datatypes.py +1218 -0
- sage/combinat/words/word_options.py +99 -0
- sage/combinat/words/words.py +2396 -0
- sage/data_structures/all__sagemath_combinat.py +1 -0
- sage/databases/all__sagemath_combinat.py +13 -0
- sage/databases/findstat.py +4897 -0
- sage/databases/oeis.py +2058 -0
- sage/databases/sloane.py +393 -0
- sage/dynamics/all__sagemath_combinat.py +14 -0
- sage/dynamics/cellular_automata/all.py +7 -0
- sage/dynamics/cellular_automata/catalog.py +34 -0
- sage/dynamics/cellular_automata/elementary.py +612 -0
- sage/dynamics/cellular_automata/glca.py +477 -0
- sage/dynamics/cellular_automata/solitons.py +1463 -0
- sage/dynamics/finite_dynamical_system.py +1249 -0
- sage/dynamics/finite_dynamical_system_catalog.py +382 -0
- sage/games/all.py +7 -0
- sage/games/hexad.py +704 -0
- sage/games/quantumino.py +591 -0
- sage/games/sudoku.py +889 -0
- sage/games/sudoku_backtrack.cpython-314-x86_64-linux-musl.so +0 -0
- sage/games/sudoku_backtrack.pyx +189 -0
- sage/groups/all__sagemath_combinat.py +1 -0
- sage/groups/indexed_free_group.py +489 -0
- sage/libs/all__sagemath_combinat.py +6 -0
- sage/libs/lrcalc/__init__.py +1 -0
- sage/libs/lrcalc/lrcalc.py +525 -0
- sage/libs/symmetrica/__init__.py +7 -0
- sage/libs/symmetrica/all.py +101 -0
- sage/libs/symmetrica/kostka.pxi +168 -0
- sage/libs/symmetrica/part.pxi +193 -0
- sage/libs/symmetrica/plet.pxi +42 -0
- sage/libs/symmetrica/sab.pxi +196 -0
- sage/libs/symmetrica/sb.pxi +332 -0
- sage/libs/symmetrica/sc.pxi +192 -0
- sage/libs/symmetrica/schur.pxi +956 -0
- sage/libs/symmetrica/symmetrica.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/symmetrica/symmetrica.pxi +1172 -0
- sage/libs/symmetrica/symmetrica.pyx +39 -0
- sage/monoids/all.py +13 -0
- sage/monoids/automatic_semigroup.py +1054 -0
- sage/monoids/free_abelian_monoid.py +315 -0
- sage/monoids/free_abelian_monoid_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/monoids/free_abelian_monoid_element.pxd +16 -0
- sage/monoids/free_abelian_monoid_element.pyx +397 -0
- sage/monoids/free_monoid.py +335 -0
- sage/monoids/free_monoid_element.py +431 -0
- sage/monoids/hecke_monoid.py +65 -0
- sage/monoids/string_monoid.py +817 -0
- sage/monoids/string_monoid_element.py +547 -0
- sage/monoids/string_ops.py +143 -0
- sage/monoids/trace_monoid.py +972 -0
- sage/rings/all__sagemath_combinat.py +2 -0
- sage/sat/all.py +4 -0
- sage/sat/boolean_polynomials.py +405 -0
- sage/sat/converters/__init__.py +6 -0
- sage/sat/converters/anf2cnf.py +14 -0
- sage/sat/converters/polybori.py +611 -0
- sage/sat/solvers/__init__.py +5 -0
- sage/sat/solvers/cryptominisat.py +287 -0
- sage/sat/solvers/dimacs.py +783 -0
- sage/sat/solvers/picosat.py +228 -0
- sage/sat/solvers/sat_lp.py +156 -0
- sage/sat/solvers/satsolver.cpython-314-x86_64-linux-musl.so +0 -0
- sage/sat/solvers/satsolver.pxd +3 -0
- sage/sat/solvers/satsolver.pyx +405 -0
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-combinat
|
|
2
|
+
"""
|
|
3
|
+
Elementary Cellular Automata
|
|
4
|
+
|
|
5
|
+
AUTHORS:
|
|
6
|
+
|
|
7
|
+
- Travis Scrimshaw (2018-07-07): Initial version
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
#*****************************************************************************
|
|
11
|
+
# Copyright (C) 2018 Travis Scrimshaw <tcscrims at gmail.com>
|
|
12
|
+
#
|
|
13
|
+
# This program is free software: you can redistribute it and/or modify
|
|
14
|
+
# it under the terms of the GNU General Public License as published by
|
|
15
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
16
|
+
# (at your option) any later version.
|
|
17
|
+
# http://www.gnu.org/licenses/
|
|
18
|
+
#*****************************************************************************
|
|
19
|
+
|
|
20
|
+
from sage.structure.sage_object import SageObject
|
|
21
|
+
from sage.typeset.ascii_art import AsciiArt
|
|
22
|
+
from sage.typeset.unicode_art import UnicodeArt
|
|
23
|
+
from sage.rings.integer_ring import ZZ
|
|
24
|
+
from sage.misc.lazy_import import lazy_import
|
|
25
|
+
from sage.misc.constant_function import ConstantFunction
|
|
26
|
+
|
|
27
|
+
lazy_import("sage.matrix.constructor", "matrix")
|
|
28
|
+
lazy_import("sage.plot.matrix_plot", "matrix_plot")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ElementaryCellularAutomata(SageObject):
|
|
32
|
+
r"""
|
|
33
|
+
Elementary cellular automata.
|
|
34
|
+
|
|
35
|
+
An *elementary cellular automaton* is a 1-dimensional cellular
|
|
36
|
+
deterministic automaton with two possible values: `X := \{0,1\}`.
|
|
37
|
+
A *state* is therefore a sequence `s \in X^n`, and the *evolution*
|
|
38
|
+
of a state `s \to s'` is given for `s'_i` by looking at the values
|
|
39
|
+
at positions `s_{i-1}, s_i, s_{i+1}` and is determined by the
|
|
40
|
+
*rule* `0 \leq r \leq 255` as follows. Consider the binary
|
|
41
|
+
representation `r = b_7 b_6 b_5 b_4 b_3 b_2 b_1 b_0`. Then, we
|
|
42
|
+
define `s'_i = b_j`, where `j = s_{i-1} s_i s_{i+1}` is the
|
|
43
|
+
corresponding binary representation. In other words, the value
|
|
44
|
+
`s'_i` is given according to the following table:
|
|
45
|
+
|
|
46
|
+
.. MATH::
|
|
47
|
+
|
|
48
|
+
\begin{array}{cccccccc}
|
|
49
|
+
111 & 110 & 101 & 100 & 011 & 010 & 001 & 000 \\
|
|
50
|
+
b_7 & b_6 & b_5 & b_4 & b_3 & b_2 & b_1 & b_0
|
|
51
|
+
\end{array}
|
|
52
|
+
|
|
53
|
+
We consider the boundary values of `s_0 = s_{n+1} = 0`.
|
|
54
|
+
|
|
55
|
+
INPUT:
|
|
56
|
+
|
|
57
|
+
- ``rule`` -- integer between 0 and 255
|
|
58
|
+
- ``width`` -- (optional) the width of the ECA
|
|
59
|
+
- ``initial_state`` -- (optional) the initial state given
|
|
60
|
+
as a list of ``0`` and ``1``
|
|
61
|
+
- ``boundary`` -- (default: ``(0, 0)``) a tuple of the left and right
|
|
62
|
+
boundary conditions respectively or ``None`` for periodic boundary
|
|
63
|
+
conditions
|
|
64
|
+
|
|
65
|
+
Either ``width`` or ``initial_state`` must be given. If ``width``
|
|
66
|
+
is less than the length of ``initial_state``, then ``initial_state``
|
|
67
|
+
has ``0`` prepended so the resulting list has length ``width``.
|
|
68
|
+
If only ``width`` is given, then the initial state is constructed
|
|
69
|
+
randomly.
|
|
70
|
+
|
|
71
|
+
The boundary conditions can either be ``0``, ``1``, or a function that
|
|
72
|
+
takes an integer ``n`` corresponding to the state and outputs either
|
|
73
|
+
``0`` or ``1``.
|
|
74
|
+
|
|
75
|
+
EXAMPLES:
|
|
76
|
+
|
|
77
|
+
We construct an example with rule `r = 90` using `n = 20`. The
|
|
78
|
+
initial state consists of a single `1` in the rightmost entry::
|
|
79
|
+
|
|
80
|
+
sage: ECA = cellular_automata.Elementary(90, width=20, initial_state=[1])
|
|
81
|
+
sage: ECA.evolve(20)
|
|
82
|
+
sage: ascii_art(ECA)
|
|
83
|
+
X
|
|
84
|
+
X
|
|
85
|
+
X X
|
|
86
|
+
X
|
|
87
|
+
X X
|
|
88
|
+
X X
|
|
89
|
+
X X X X
|
|
90
|
+
X
|
|
91
|
+
X X
|
|
92
|
+
X X
|
|
93
|
+
X X X X
|
|
94
|
+
X X
|
|
95
|
+
X X X X
|
|
96
|
+
X X X X
|
|
97
|
+
X X X X X X X X
|
|
98
|
+
X
|
|
99
|
+
X X
|
|
100
|
+
X X
|
|
101
|
+
X X X X
|
|
102
|
+
X X
|
|
103
|
+
X X X
|
|
104
|
+
|
|
105
|
+
We now construct it with different boundary conditions. The first is
|
|
106
|
+
with the left boundary being `1` (instead of `0`)::
|
|
107
|
+
|
|
108
|
+
sage: ECA = cellular_automata.Elementary(90, width=20, initial_state=[1], boundary=(1,0))
|
|
109
|
+
sage: ECA.evolve(20)
|
|
110
|
+
sage: ascii_art(ECA)
|
|
111
|
+
X
|
|
112
|
+
X X
|
|
113
|
+
XX X X
|
|
114
|
+
XX X
|
|
115
|
+
XXX X X
|
|
116
|
+
X XX X X
|
|
117
|
+
XXX X X X X
|
|
118
|
+
X XX XX X
|
|
119
|
+
X XX XXX X X
|
|
120
|
+
X XX X XX X X
|
|
121
|
+
X XX XX X X X
|
|
122
|
+
X XXX XXXXX X
|
|
123
|
+
X X X X XX X X
|
|
124
|
+
X X XXXX X X
|
|
125
|
+
XX X X X X X X
|
|
126
|
+
XX X XX XX XX
|
|
127
|
+
XXXX XX XX XXX
|
|
128
|
+
X XXXXX XX X XX
|
|
129
|
+
XXX X XX XXX
|
|
130
|
+
XXX XX X XXX XX XX
|
|
131
|
+
X XX XXX X XX XXX
|
|
132
|
+
|
|
133
|
+
Now we consider the right boundary as being `1` on every third value::
|
|
134
|
+
|
|
135
|
+
sage: def rbdry(n): return 1 if n % 3 == 0 else 0
|
|
136
|
+
sage: ECA = cellular_automata.Elementary(90, width=20, initial_state=[1], boundary=(0,rbdry))
|
|
137
|
+
sage: ECA.evolve(20)
|
|
138
|
+
sage: ascii_art(ECA)
|
|
139
|
+
X
|
|
140
|
+
X
|
|
141
|
+
X X
|
|
142
|
+
X X
|
|
143
|
+
X XX
|
|
144
|
+
X XXX
|
|
145
|
+
X XXX
|
|
146
|
+
X X XX
|
|
147
|
+
X XX XXX
|
|
148
|
+
X XXXXX
|
|
149
|
+
X XXX XX
|
|
150
|
+
X X XX XXXX
|
|
151
|
+
X XX XX X
|
|
152
|
+
X XXXXXX X
|
|
153
|
+
X XXX XXX X
|
|
154
|
+
X X XX XX X
|
|
155
|
+
X XX XXXXXX X
|
|
156
|
+
X XXXXX XXX X
|
|
157
|
+
X XXX XX XX X
|
|
158
|
+
X X XX XXXXXXX X
|
|
159
|
+
XX XX X XXX X
|
|
160
|
+
|
|
161
|
+
Lastly we consider it with periodic boundary condition::
|
|
162
|
+
|
|
163
|
+
sage: ECA = cellular_automata.Elementary(90, width=20, initial_state=[1], boundary=None)
|
|
164
|
+
sage: ECA.evolve(20)
|
|
165
|
+
sage: ascii_art(ECA)
|
|
166
|
+
X
|
|
167
|
+
X X
|
|
168
|
+
X X
|
|
169
|
+
X X X X
|
|
170
|
+
X X
|
|
171
|
+
X X X X
|
|
172
|
+
X X X X
|
|
173
|
+
X X X X X X X X
|
|
174
|
+
X X
|
|
175
|
+
X X X X
|
|
176
|
+
X X
|
|
177
|
+
X X X X
|
|
178
|
+
X X X X
|
|
179
|
+
X X X X X X X X
|
|
180
|
+
X X
|
|
181
|
+
X X X X
|
|
182
|
+
X X
|
|
183
|
+
X X X X
|
|
184
|
+
X X X X
|
|
185
|
+
X X X X X X X X
|
|
186
|
+
X X
|
|
187
|
+
|
|
188
|
+
We show the local evolution rules for rule `110`::
|
|
189
|
+
|
|
190
|
+
sage: for t in cartesian_product([[0,1],[0,1],[0,1]]):
|
|
191
|
+
....: ECA = cellular_automata.Elementary(110, list(t))
|
|
192
|
+
....: ECA.print_states(2)
|
|
193
|
+
....: print('#')
|
|
194
|
+
<BLANKLINE>
|
|
195
|
+
<BLANKLINE>
|
|
196
|
+
#
|
|
197
|
+
X
|
|
198
|
+
XX
|
|
199
|
+
#
|
|
200
|
+
X
|
|
201
|
+
XX
|
|
202
|
+
#
|
|
203
|
+
XX
|
|
204
|
+
XXX
|
|
205
|
+
#
|
|
206
|
+
X
|
|
207
|
+
X
|
|
208
|
+
#
|
|
209
|
+
X X
|
|
210
|
+
XXX
|
|
211
|
+
#
|
|
212
|
+
XX
|
|
213
|
+
XX
|
|
214
|
+
#
|
|
215
|
+
XXX
|
|
216
|
+
X X
|
|
217
|
+
#
|
|
218
|
+
|
|
219
|
+
We construct an elementary cellular automaton with a random initial
|
|
220
|
+
state with `n = 15` and see the state after `50` evolutions::
|
|
221
|
+
|
|
222
|
+
sage: ECA = cellular_automata.Elementary(26, width=25)
|
|
223
|
+
sage: ECA.print_state(50) # random
|
|
224
|
+
X X X X X X
|
|
225
|
+
|
|
226
|
+
We construct and plot a larger example with rule `60`::
|
|
227
|
+
|
|
228
|
+
sage: ECA = cellular_automata.Elementary(60, width=200)
|
|
229
|
+
sage: ECA.evolve(200)
|
|
230
|
+
sage: ECA.plot() # needs sage.plot
|
|
231
|
+
Graphics object consisting of 1 graphics primitive
|
|
232
|
+
|
|
233
|
+
.. PLOT::
|
|
234
|
+
|
|
235
|
+
ECA = cellular_automata.Elementary(60, width=200)
|
|
236
|
+
ECA.evolve(200)
|
|
237
|
+
P = ECA.plot()
|
|
238
|
+
sphinx_plot(P)
|
|
239
|
+
|
|
240
|
+
With periodic boundary condition for rule `90`::
|
|
241
|
+
|
|
242
|
+
sage: ECA = cellular_automata.Elementary(90, initial_state=[1]+[0]*254+[1], boundary=None)
|
|
243
|
+
sage: ECA.evolve(256)
|
|
244
|
+
sage: ECA.plot() # needs sage.plot
|
|
245
|
+
Graphics object consisting of 1 graphics primitive
|
|
246
|
+
|
|
247
|
+
.. PLOT::
|
|
248
|
+
|
|
249
|
+
ECA = cellular_automata.Elementary(90, initial_state=[1]+[0]*254+[1], boundary=None)
|
|
250
|
+
ECA.evolve(256)
|
|
251
|
+
P = ECA.plot()
|
|
252
|
+
sphinx_plot(P)
|
|
253
|
+
|
|
254
|
+
REFERENCES:
|
|
255
|
+
|
|
256
|
+
:wikipedia:`Elementary_cellular_automaton`
|
|
257
|
+
"""
|
|
258
|
+
def __init__(self, rule, width=None, initial_state=None, boundary=(0, 0)):
|
|
259
|
+
"""
|
|
260
|
+
Initialize ``self``.
|
|
261
|
+
|
|
262
|
+
EXAMPLES::
|
|
263
|
+
|
|
264
|
+
sage: ECA = cellular_automata.Elementary(110, width=300)
|
|
265
|
+
sage: TestSuite(ECA).run()
|
|
266
|
+
"""
|
|
267
|
+
if rule not in ZZ or rule < 0 or rule > 255:
|
|
268
|
+
raise ValueError("invalid rule")
|
|
269
|
+
self._rule = ZZ(rule).binary()
|
|
270
|
+
# We reverse the rule to make it easier to work with
|
|
271
|
+
self._rule = [ZZ(x) for x in reversed('0'*(8-len(self._rule)) + self._rule)]
|
|
272
|
+
if isinstance(width, list):
|
|
273
|
+
initial_state = width
|
|
274
|
+
width = len(initial_state)
|
|
275
|
+
if initial_state is None:
|
|
276
|
+
self._width = width
|
|
277
|
+
initial_state = [ZZ.random_element(0,2) for d in range(width)]
|
|
278
|
+
else:
|
|
279
|
+
if not all(d in [0,1] for d in initial_state):
|
|
280
|
+
raise ValueError("invalid initial state")
|
|
281
|
+
initial_state = list(initial_state) # make sure it is a list and a copy
|
|
282
|
+
if width is None:
|
|
283
|
+
self._width = len(initial_state)
|
|
284
|
+
elif width >= len(initial_state):
|
|
285
|
+
self._width = width
|
|
286
|
+
initial_state = ([0]*(width - len(initial_state))
|
|
287
|
+
+ initial_state)
|
|
288
|
+
else:
|
|
289
|
+
raise ValueError("the width must be at least the length of"
|
|
290
|
+
" the initial state")
|
|
291
|
+
self._states = [initial_state]
|
|
292
|
+
if boundary is not None:
|
|
293
|
+
self._bdry = tuple(boundary)
|
|
294
|
+
self._lbdry = ConstantFunction(boundary[0]) if boundary[0] in [0,1] else boundary[0]
|
|
295
|
+
self._rbdry = ConstantFunction(boundary[1]) if boundary[1] in [0,1] else boundary[1]
|
|
296
|
+
else:
|
|
297
|
+
self._bdry = boundary
|
|
298
|
+
|
|
299
|
+
def __eq__(self, other):
|
|
300
|
+
"""
|
|
301
|
+
Check equality.
|
|
302
|
+
|
|
303
|
+
Two ECAs are equal when they have the same rule, width,
|
|
304
|
+
initial state, and boundary conditions.
|
|
305
|
+
|
|
306
|
+
TESTS::
|
|
307
|
+
|
|
308
|
+
sage: ECA1 = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,0,1])
|
|
309
|
+
sage: ECA2 = cellular_automata.Elementary(101, [1,0,0,1,1,0,0,1,0,1])
|
|
310
|
+
sage: ECA3 = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,1,0])
|
|
311
|
+
sage: ECA4 = cellular_automata.Elementary(110, [0,1,0,0,1,1,0,0,1,0,1])
|
|
312
|
+
sage: ECA5 = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,0,1])
|
|
313
|
+
sage: ECA6 = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,0,1], boundary=(1, 1))
|
|
314
|
+
sage: ECA1 == ECA5
|
|
315
|
+
True
|
|
316
|
+
sage: ECA1 == ECA2
|
|
317
|
+
False
|
|
318
|
+
sage: ECA1 == ECA3
|
|
319
|
+
False
|
|
320
|
+
sage: ECA1 == ECA4
|
|
321
|
+
False
|
|
322
|
+
sage: ECA1 == ECA6
|
|
323
|
+
False
|
|
324
|
+
"""
|
|
325
|
+
return (isinstance(other, ElementaryCellularAutomata)
|
|
326
|
+
and self._rule == other._rule
|
|
327
|
+
and self._width == other._width
|
|
328
|
+
and self._states[0] == other._states[0]
|
|
329
|
+
and self._bdry == other._bdry)
|
|
330
|
+
|
|
331
|
+
def __ne__(self, other):
|
|
332
|
+
"""
|
|
333
|
+
Check non equality.
|
|
334
|
+
|
|
335
|
+
TESTS::
|
|
336
|
+
|
|
337
|
+
sage: ECA1 = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,0,1])
|
|
338
|
+
sage: ECA2 = cellular_automata.Elementary(101, [1,0,0,1,1,0,0,1,0,1])
|
|
339
|
+
sage: ECA3 = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,1,0])
|
|
340
|
+
sage: ECA4 = cellular_automata.Elementary(110, [0,1,0,0,1,1,0,0,1,0,1])
|
|
341
|
+
sage: ECA5 = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,0,1])
|
|
342
|
+
sage: ECA6 = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,0,1], boundary=(1, 1))
|
|
343
|
+
sage: ECA1 != ECA2
|
|
344
|
+
True
|
|
345
|
+
sage: ECA1 != ECA3
|
|
346
|
+
True
|
|
347
|
+
sage: ECA1 != ECA4
|
|
348
|
+
True
|
|
349
|
+
sage: ECA1 != ECA5
|
|
350
|
+
False
|
|
351
|
+
sage: ECA1 != ECA6
|
|
352
|
+
True
|
|
353
|
+
"""
|
|
354
|
+
return not (self == other)
|
|
355
|
+
|
|
356
|
+
# Evolution functions
|
|
357
|
+
# -------------------
|
|
358
|
+
|
|
359
|
+
def evolve(self, number=None):
|
|
360
|
+
r"""
|
|
361
|
+
Evolve ``self``.
|
|
362
|
+
|
|
363
|
+
INPUT:
|
|
364
|
+
|
|
365
|
+
- ``number`` -- (optional) the number of times to perform
|
|
366
|
+
the evolution
|
|
367
|
+
|
|
368
|
+
EXAMPLES::
|
|
369
|
+
|
|
370
|
+
sage: ECA = cellular_automata.Elementary(110, [1,0,0,1,1,0,0,1,0,1])
|
|
371
|
+
sage: ascii_art(ECA)
|
|
372
|
+
X XX X X
|
|
373
|
+
sage: ECA.evolve()
|
|
374
|
+
sage: ascii_art(ECA)
|
|
375
|
+
X XX X X
|
|
376
|
+
X XXX XXXX
|
|
377
|
+
sage: ECA.evolve(10)
|
|
378
|
+
sage: ascii_art(ECA)
|
|
379
|
+
X XX X X
|
|
380
|
+
X XXX XXXX
|
|
381
|
+
XXX XXX X
|
|
382
|
+
X XXX X XX
|
|
383
|
+
XXX XXXXXX
|
|
384
|
+
X XXX X
|
|
385
|
+
XXX X XX
|
|
386
|
+
X XXX XXX
|
|
387
|
+
XXX X XX X
|
|
388
|
+
X XXXXXXXX
|
|
389
|
+
XXX X
|
|
390
|
+
X X XX
|
|
391
|
+
"""
|
|
392
|
+
if number is not None:
|
|
393
|
+
for _ in range(number):
|
|
394
|
+
self.evolve()
|
|
395
|
+
return
|
|
396
|
+
|
|
397
|
+
prev_state = self._states[-1]
|
|
398
|
+
next_state = [None] * self._width
|
|
399
|
+
|
|
400
|
+
def to_int(triple):
|
|
401
|
+
return ZZ(list(reversed(triple)), base=2)
|
|
402
|
+
if self._bdry is None:
|
|
403
|
+
next_state[0] = self._rule[to_int([prev_state[-1]] + prev_state[:2])]
|
|
404
|
+
next_state[-1] = self._rule[to_int(prev_state[-2:] + [prev_state[0]])]
|
|
405
|
+
else:
|
|
406
|
+
n = len(self._states)
|
|
407
|
+
next_state[0] = self._rule[to_int([self._lbdry(n)] + prev_state[:2])]
|
|
408
|
+
next_state[-1] = self._rule[to_int(prev_state[-2:] + [self._rbdry(n)])]
|
|
409
|
+
|
|
410
|
+
for i in range(1, self._width-1):
|
|
411
|
+
next_state[i] = self._rule[to_int(prev_state[i-1:i+2])]
|
|
412
|
+
self._states.append(next_state)
|
|
413
|
+
|
|
414
|
+
# Output functions
|
|
415
|
+
# ----------------
|
|
416
|
+
|
|
417
|
+
def _repr_(self):
|
|
418
|
+
"""
|
|
419
|
+
Return a string representation of ``self``.
|
|
420
|
+
|
|
421
|
+
EXAMPLES::
|
|
422
|
+
|
|
423
|
+
sage: ECA = cellular_automata.Elementary(123, width=10, initial_state=[1])
|
|
424
|
+
sage: ECA
|
|
425
|
+
Elementary cellular automata with rule 123 and initial state
|
|
426
|
+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
|
|
427
|
+
"""
|
|
428
|
+
return "Elementary cellular automata with rule {} and initial state {}".format(
|
|
429
|
+
ZZ(self._rule, base=2), self._states[0])
|
|
430
|
+
|
|
431
|
+
def print_state(self, number=None):
|
|
432
|
+
r"""
|
|
433
|
+
Print the state ``number``.
|
|
434
|
+
|
|
435
|
+
INPUT:
|
|
436
|
+
|
|
437
|
+
- ``number`` -- (default: the current state) the state to print
|
|
438
|
+
|
|
439
|
+
EXAMPLES::
|
|
440
|
+
|
|
441
|
+
sage: ECA = cellular_automata.Elementary(110, width=10,
|
|
442
|
+
....: initial_state=[1,0,0,1,1,0,1])
|
|
443
|
+
sage: ECA.print_state(15)
|
|
444
|
+
X X XXXXX
|
|
445
|
+
sage: ECA.print_state(10)
|
|
446
|
+
X X XX
|
|
447
|
+
sage: ECA.print_state(20)
|
|
448
|
+
X XXX
|
|
449
|
+
sage: for i in range(11):
|
|
450
|
+
....: ECA.print_state(i)
|
|
451
|
+
X XX X
|
|
452
|
+
XX XXXXX
|
|
453
|
+
XXXXX X
|
|
454
|
+
XX X XX
|
|
455
|
+
XX XX XXX
|
|
456
|
+
XX XXXXX X
|
|
457
|
+
XXXX XXX
|
|
458
|
+
X X XX X
|
|
459
|
+
X XX XXXXX
|
|
460
|
+
XXXXXX X
|
|
461
|
+
X X XX
|
|
462
|
+
"""
|
|
463
|
+
if number is None:
|
|
464
|
+
number = len(self._states) - 1
|
|
465
|
+
if number + 1 > len(self._states):
|
|
466
|
+
for dummy in range(number + 1 - len(self._states)):
|
|
467
|
+
self.evolve()
|
|
468
|
+
|
|
469
|
+
state = self._states[number]
|
|
470
|
+
print(''.join('X' if x else ' ' for x in state))
|
|
471
|
+
|
|
472
|
+
def print_states(self, number=None):
|
|
473
|
+
r"""
|
|
474
|
+
Print the first ``num`` states of ``self``.
|
|
475
|
+
|
|
476
|
+
.. NOTE::
|
|
477
|
+
|
|
478
|
+
If the number of states computed for ``self`` is less than
|
|
479
|
+
``num``, then this evolves the system using the default
|
|
480
|
+
time evolution.
|
|
481
|
+
|
|
482
|
+
INPUT:
|
|
483
|
+
|
|
484
|
+
- ``number`` -- the number of states to print
|
|
485
|
+
|
|
486
|
+
EXAMPLES::
|
|
487
|
+
|
|
488
|
+
sage: ECA = cellular_automata.Elementary(110, width=10,
|
|
489
|
+
....: initial_state=[1,0,0,1,1,0,1])
|
|
490
|
+
sage: ECA.print_states(10)
|
|
491
|
+
X XX X
|
|
492
|
+
XX XXXXX
|
|
493
|
+
XXXXX X
|
|
494
|
+
XX X XX
|
|
495
|
+
XX XX XXX
|
|
496
|
+
XX XXXXX X
|
|
497
|
+
XXXX XXX
|
|
498
|
+
X X XX X
|
|
499
|
+
X XX XXXXX
|
|
500
|
+
XXXXXX X
|
|
501
|
+
"""
|
|
502
|
+
for i in range(number):
|
|
503
|
+
self.print_state(i)
|
|
504
|
+
|
|
505
|
+
def _ascii_art_(self):
|
|
506
|
+
r"""
|
|
507
|
+
Return an ascii art representation of ``self``.
|
|
508
|
+
|
|
509
|
+
EXAMPLES::
|
|
510
|
+
|
|
511
|
+
sage: ECA = cellular_automata.Elementary(22, width=30, initial_state=[1])
|
|
512
|
+
sage: ECA.evolve(30)
|
|
513
|
+
sage: ascii_art(ECA)
|
|
514
|
+
X
|
|
515
|
+
XX
|
|
516
|
+
X
|
|
517
|
+
XXX
|
|
518
|
+
X X
|
|
519
|
+
XXX XX
|
|
520
|
+
X
|
|
521
|
+
XXX
|
|
522
|
+
X X
|
|
523
|
+
XXX XXX
|
|
524
|
+
X X
|
|
525
|
+
XXX XXX
|
|
526
|
+
X X X X
|
|
527
|
+
XXX XXX XXX XX
|
|
528
|
+
X
|
|
529
|
+
XXX
|
|
530
|
+
X X
|
|
531
|
+
XXX XXX
|
|
532
|
+
X X
|
|
533
|
+
XXX XXX
|
|
534
|
+
X X X X
|
|
535
|
+
XXX XXX XXX XXX
|
|
536
|
+
X X
|
|
537
|
+
XXX XXX
|
|
538
|
+
X X X X
|
|
539
|
+
XXX XXX XXX XXX
|
|
540
|
+
X X X X
|
|
541
|
+
XXX XXX XXX XXX
|
|
542
|
+
X X X X X X X X
|
|
543
|
+
XXX XXX XXX XXX XXX XXX XXX XX
|
|
544
|
+
"""
|
|
545
|
+
return AsciiArt([''.join('X' if x else ' ' for x in state)
|
|
546
|
+
for state in self._states])
|
|
547
|
+
|
|
548
|
+
def _unicode_art_(self):
|
|
549
|
+
r"""
|
|
550
|
+
Return a unicode art representation of ``self``.
|
|
551
|
+
|
|
552
|
+
EXAMPLES::
|
|
553
|
+
|
|
554
|
+
sage: ECA = cellular_automata.Elementary(22, width=30, initial_state=[1])
|
|
555
|
+
sage: ECA.evolve(30)
|
|
556
|
+
sage: unicode_art(ECA)
|
|
557
|
+
█
|
|
558
|
+
██
|
|
559
|
+
█
|
|
560
|
+
███
|
|
561
|
+
█ █
|
|
562
|
+
███ ██
|
|
563
|
+
█
|
|
564
|
+
███
|
|
565
|
+
█ █
|
|
566
|
+
███ ███
|
|
567
|
+
█ █
|
|
568
|
+
███ ███
|
|
569
|
+
█ █ █ █
|
|
570
|
+
███ ███ ███ ██
|
|
571
|
+
█
|
|
572
|
+
███
|
|
573
|
+
█ █
|
|
574
|
+
███ ███
|
|
575
|
+
█ █
|
|
576
|
+
███ ███
|
|
577
|
+
█ █ █ █
|
|
578
|
+
███ ███ ███ ███
|
|
579
|
+
█ █
|
|
580
|
+
███ ███
|
|
581
|
+
█ █ █ █
|
|
582
|
+
███ ███ ███ ███
|
|
583
|
+
█ █ █ █
|
|
584
|
+
███ ███ ███ ███
|
|
585
|
+
█ █ █ █ █ █ █ █
|
|
586
|
+
███ ███ ███ ███ ███ ███ ███ ██
|
|
587
|
+
"""
|
|
588
|
+
return UnicodeArt([''.join('█' if x else ' ' for x in state)
|
|
589
|
+
for state in self._states])
|
|
590
|
+
|
|
591
|
+
def plot(self, number=None):
|
|
592
|
+
r"""
|
|
593
|
+
Return a plot of ``self``.
|
|
594
|
+
|
|
595
|
+
INPUT:
|
|
596
|
+
|
|
597
|
+
- ``number`` -- the number of states to plot
|
|
598
|
+
|
|
599
|
+
EXAMPLES::
|
|
600
|
+
|
|
601
|
+
sage: ECA = cellular_automata.Elementary(110, width=256)
|
|
602
|
+
sage: ECA.evolve(256)
|
|
603
|
+
sage: ECA.plot() # needs sage.plot
|
|
604
|
+
Graphics object consisting of 1 graphics primitive
|
|
605
|
+
"""
|
|
606
|
+
if number is None:
|
|
607
|
+
number = len(self._states)
|
|
608
|
+
if number > len(self._states):
|
|
609
|
+
for dummy in range(number - len(self._states)):
|
|
610
|
+
self.evolve()
|
|
611
|
+
M = matrix(self._states[:number])
|
|
612
|
+
return matrix_plot(M)
|