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,817 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-combinat
|
|
2
|
+
r"""
|
|
3
|
+
Free String Monoids
|
|
4
|
+
|
|
5
|
+
AUTHORS:
|
|
6
|
+
|
|
7
|
+
- David Kohel <kohel@maths.usyd.edu.au>, 2007-01
|
|
8
|
+
|
|
9
|
+
Sage supports a wide range of specific free string monoids.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# ****************************************************************************
|
|
13
|
+
# Copyright (C) 2007 David Kohel <kohel@maths.usyd.edu.au>
|
|
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
|
+
|
|
23
|
+
from .free_monoid import FreeMonoid
|
|
24
|
+
from .string_monoid_element import StringMonoidElement
|
|
25
|
+
from .string_ops import strip_encoding
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class StringMonoid_class(FreeMonoid):
|
|
29
|
+
r"""
|
|
30
|
+
A free string monoid on `n` generators.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, n, alphabet=()):
|
|
34
|
+
r"""
|
|
35
|
+
Create free binary string monoid on `n` generators.
|
|
36
|
+
|
|
37
|
+
INPUT:
|
|
38
|
+
|
|
39
|
+
- ``n`` -- integer
|
|
40
|
+
|
|
41
|
+
- ``alphabet`` -- string or tuple whose characters or elements denote
|
|
42
|
+
the generators
|
|
43
|
+
|
|
44
|
+
EXAMPLES::
|
|
45
|
+
|
|
46
|
+
sage: S = BinaryStrings(); S
|
|
47
|
+
Free binary string monoid
|
|
48
|
+
sage: x = S.gens()
|
|
49
|
+
sage: x[0]*x[1]**5 * (x[0]*x[1])
|
|
50
|
+
01111101
|
|
51
|
+
"""
|
|
52
|
+
# Names must be alphabetical -- omitted since printing is
|
|
53
|
+
# defined locally.
|
|
54
|
+
# FreeMonoid.__init__(self, n, names = alphabet)
|
|
55
|
+
FreeMonoid.__init__(self, n)
|
|
56
|
+
self._alphabet = alphabet
|
|
57
|
+
|
|
58
|
+
def __contains__(self, x):
|
|
59
|
+
return isinstance(x, StringMonoidElement) and x.parent() == self
|
|
60
|
+
|
|
61
|
+
def alphabet(self):
|
|
62
|
+
return tuple(self._alphabet)
|
|
63
|
+
|
|
64
|
+
def one(self):
|
|
65
|
+
r"""
|
|
66
|
+
Return the identity element of ``self``.
|
|
67
|
+
|
|
68
|
+
EXAMPLES::
|
|
69
|
+
|
|
70
|
+
sage: b = BinaryStrings(); b
|
|
71
|
+
Free binary string monoid
|
|
72
|
+
sage: b.one() * b('1011')
|
|
73
|
+
1011
|
|
74
|
+
sage: b.one() * b('110') == b('110')
|
|
75
|
+
True
|
|
76
|
+
sage: b('10101') * b.one() == b('101011')
|
|
77
|
+
False
|
|
78
|
+
"""
|
|
79
|
+
return StringMonoidElement(self, '')
|
|
80
|
+
|
|
81
|
+
def gen(self, i=0):
|
|
82
|
+
r"""
|
|
83
|
+
The `i`-th generator of the monoid.
|
|
84
|
+
|
|
85
|
+
INPUT:
|
|
86
|
+
|
|
87
|
+
- ``i`` -- integer (default: 0)
|
|
88
|
+
|
|
89
|
+
EXAMPLES::
|
|
90
|
+
|
|
91
|
+
sage: S = BinaryStrings()
|
|
92
|
+
sage: S.gen(0)
|
|
93
|
+
0
|
|
94
|
+
sage: S.gen(1)
|
|
95
|
+
1
|
|
96
|
+
sage: S.gen(2)
|
|
97
|
+
Traceback (most recent call last):
|
|
98
|
+
...
|
|
99
|
+
IndexError: Argument i (= 2) must be between 0 and 1.
|
|
100
|
+
sage: S = HexadecimalStrings()
|
|
101
|
+
sage: S.gen(0)
|
|
102
|
+
0
|
|
103
|
+
sage: S.gen(12)
|
|
104
|
+
c
|
|
105
|
+
sage: S.gen(16)
|
|
106
|
+
Traceback (most recent call last):
|
|
107
|
+
...
|
|
108
|
+
IndexError: Argument i (= 16) must be between 0 and 15.
|
|
109
|
+
"""
|
|
110
|
+
n = self.ngens()
|
|
111
|
+
if i < 0 or not i < n:
|
|
112
|
+
raise IndexError(
|
|
113
|
+
f"Argument i (= {i}) must be between 0 and {n-1}.")
|
|
114
|
+
return StringMonoidElement(self, [int(i)])
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# ****************************************************************************
|
|
118
|
+
# Specific global string monoids
|
|
119
|
+
# ****************************************************************************
|
|
120
|
+
|
|
121
|
+
class BinaryStringMonoid(StringMonoid_class):
|
|
122
|
+
r"""
|
|
123
|
+
The free binary string monoid on generators `\{ 0, 1 \}`.
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
def __init__(self):
|
|
127
|
+
r"""
|
|
128
|
+
Create free binary string monoid on generators `\{ 0, 1 \}`.
|
|
129
|
+
|
|
130
|
+
EXAMPLES::
|
|
131
|
+
|
|
132
|
+
sage: S = BinaryStrings(); S
|
|
133
|
+
Free binary string monoid
|
|
134
|
+
sage: x = S.gens()
|
|
135
|
+
sage: x[0]*x[1]**5 * (x[0]*x[1])
|
|
136
|
+
01111101
|
|
137
|
+
|
|
138
|
+
sage: u = S('')
|
|
139
|
+
sage: u
|
|
140
|
+
|
|
141
|
+
sage: x = S('0')
|
|
142
|
+
sage: x
|
|
143
|
+
0
|
|
144
|
+
sage: y = S('1')
|
|
145
|
+
sage: y
|
|
146
|
+
1
|
|
147
|
+
sage: z = S('01110')
|
|
148
|
+
sage: z
|
|
149
|
+
01110
|
|
150
|
+
sage: x*y^3*x == z
|
|
151
|
+
True
|
|
152
|
+
sage: u*x == x*u
|
|
153
|
+
True
|
|
154
|
+
|
|
155
|
+
TESTS::
|
|
156
|
+
|
|
157
|
+
sage: BinaryStrings() == BinaryStrings()
|
|
158
|
+
True
|
|
159
|
+
sage: BinaryStrings() is BinaryStrings()
|
|
160
|
+
True
|
|
161
|
+
"""
|
|
162
|
+
StringMonoid_class.__init__(self, 2, ['0', '1'])
|
|
163
|
+
|
|
164
|
+
def __repr__(self):
|
|
165
|
+
return "Free binary string monoid"
|
|
166
|
+
|
|
167
|
+
def __call__(self, x, check=True):
|
|
168
|
+
r"""
|
|
169
|
+
Return ``x`` coerced into this free monoid.
|
|
170
|
+
|
|
171
|
+
One can create a free binary string monoid element from a
|
|
172
|
+
Python string of 0s and 1s or list of integers.
|
|
173
|
+
|
|
174
|
+
NOTE: Due to the ambiguity of the second generator '1' with
|
|
175
|
+
the identity element '' of the monoid, the syntax S(1) is not
|
|
176
|
+
permissible.
|
|
177
|
+
|
|
178
|
+
EXAMPLES::
|
|
179
|
+
|
|
180
|
+
sage: S = BinaryStrings()
|
|
181
|
+
sage: S('101')
|
|
182
|
+
101
|
|
183
|
+
sage: S.gen(0)
|
|
184
|
+
0
|
|
185
|
+
sage: S.gen(1)
|
|
186
|
+
1
|
|
187
|
+
"""
|
|
188
|
+
# There should really some careful type checking here...
|
|
189
|
+
if isinstance(x, StringMonoidElement) and x.parent() == self:
|
|
190
|
+
return x
|
|
191
|
+
elif isinstance(x, list):
|
|
192
|
+
return StringMonoidElement(self, x, check)
|
|
193
|
+
elif isinstance(x, str):
|
|
194
|
+
return StringMonoidElement(self, x, check)
|
|
195
|
+
else:
|
|
196
|
+
raise TypeError("Argument x (= %s) is of the wrong type." % x)
|
|
197
|
+
|
|
198
|
+
def encoding(self, S, padic=False):
|
|
199
|
+
r"""
|
|
200
|
+
The binary encoding of the string ``S``, as a binary string element.
|
|
201
|
+
|
|
202
|
+
The default is to keep the standard ASCII byte encoding, e.g.
|
|
203
|
+
|
|
204
|
+
::
|
|
205
|
+
|
|
206
|
+
A = 65 -> 01000001
|
|
207
|
+
B = 66 -> 01000010
|
|
208
|
+
.
|
|
209
|
+
.
|
|
210
|
+
.
|
|
211
|
+
Z = 90 -> 01001110
|
|
212
|
+
|
|
213
|
+
rather than a 2-adic representation 65 -> 10000010.
|
|
214
|
+
|
|
215
|
+
Set ``padic=True`` to reverse the bit string.
|
|
216
|
+
|
|
217
|
+
EXAMPLES::
|
|
218
|
+
|
|
219
|
+
sage: S = BinaryStrings()
|
|
220
|
+
sage: S.encoding('A')
|
|
221
|
+
01000001
|
|
222
|
+
sage: S.encoding('A',padic=True)
|
|
223
|
+
10000010
|
|
224
|
+
sage: S.encoding(' ',padic=True)
|
|
225
|
+
00000100
|
|
226
|
+
"""
|
|
227
|
+
bit_string = []
|
|
228
|
+
for i in range(len(S)):
|
|
229
|
+
n = ord(S[i])
|
|
230
|
+
bits = []
|
|
231
|
+
for i in range(8):
|
|
232
|
+
bits.append(n % 2)
|
|
233
|
+
n = n >> 1
|
|
234
|
+
if not padic:
|
|
235
|
+
bits.reverse()
|
|
236
|
+
bit_string.extend(bits)
|
|
237
|
+
return self(bit_string)
|
|
238
|
+
|
|
239
|
+
# def ngens(self):
|
|
240
|
+
# r"""
|
|
241
|
+
# Return the number of generators of this free binary string monoid.
|
|
242
|
+
# There are only 2 elements in the binary number system. Hence, this
|
|
243
|
+
# is the number of generators.
|
|
244
|
+
|
|
245
|
+
# EXAMPLES::
|
|
246
|
+
|
|
247
|
+
# sage: S = BinaryStrings()
|
|
248
|
+
# sage: S.ngens()
|
|
249
|
+
# 2
|
|
250
|
+
# """
|
|
251
|
+
# return 2
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
BinaryStrings = BinaryStringMonoid
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class OctalStringMonoid(StringMonoid_class):
|
|
258
|
+
r"""
|
|
259
|
+
The free octal string monoid on generators `\{ 0, 1, \dots, 7 \}`.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
def __init__(self):
|
|
263
|
+
r"""
|
|
264
|
+
Create free octal string monoid on generators `\{ 0, 1, \dots, 7 \}`.
|
|
265
|
+
|
|
266
|
+
EXAMPLES::
|
|
267
|
+
|
|
268
|
+
sage: S = OctalStrings(); S
|
|
269
|
+
Free octal string monoid
|
|
270
|
+
sage: x = S.gens()
|
|
271
|
+
sage: (x[0]*x[7])**3 * (x[0]*x[1]*x[6]*x[5])**2
|
|
272
|
+
07070701650165
|
|
273
|
+
sage: S([ i for i in range(8) ])
|
|
274
|
+
01234567
|
|
275
|
+
sage: x[0]
|
|
276
|
+
0
|
|
277
|
+
sage: x[7]
|
|
278
|
+
7
|
|
279
|
+
sage: x[0] * x[3]^3 * x[5]^4 * x[6]
|
|
280
|
+
033355556
|
|
281
|
+
"""
|
|
282
|
+
StringMonoid_class.__init__(self, 8, [str(i) for i in range(8)])
|
|
283
|
+
|
|
284
|
+
def __repr__(self):
|
|
285
|
+
return "Free octal string monoid"
|
|
286
|
+
|
|
287
|
+
def __call__(self, x, check=True):
|
|
288
|
+
r"""
|
|
289
|
+
Return ``x`` coerced into this free monoid.
|
|
290
|
+
|
|
291
|
+
One can create a free octal string monoid element from a
|
|
292
|
+
Python string of 0s to 7s or list of integers.
|
|
293
|
+
|
|
294
|
+
EXAMPLES::
|
|
295
|
+
|
|
296
|
+
sage: S = OctalStrings()
|
|
297
|
+
sage: S('07070701650165')
|
|
298
|
+
07070701650165
|
|
299
|
+
sage: S.gen(0)
|
|
300
|
+
0
|
|
301
|
+
sage: S.gen(1)
|
|
302
|
+
1
|
|
303
|
+
sage: S([ i for i in range(8) ])
|
|
304
|
+
01234567
|
|
305
|
+
"""
|
|
306
|
+
# There should really some careful type checking here...
|
|
307
|
+
if isinstance(x, StringMonoidElement) and x.parent() == self:
|
|
308
|
+
return x
|
|
309
|
+
elif isinstance(x, list):
|
|
310
|
+
return StringMonoidElement(self, x, check)
|
|
311
|
+
elif isinstance(x, str):
|
|
312
|
+
return StringMonoidElement(self, x, check)
|
|
313
|
+
else:
|
|
314
|
+
raise TypeError("Argument x (= %s) is of the wrong type." % x)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
OctalStrings = OctalStringMonoid
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
class HexadecimalStringMonoid(StringMonoid_class):
|
|
321
|
+
r"""
|
|
322
|
+
The free hexadecimal string monoid on generators
|
|
323
|
+
`\{ 0, 1, \dots, 9, a, b, c, d, e, f \}`.
|
|
324
|
+
"""
|
|
325
|
+
|
|
326
|
+
def __init__(self):
|
|
327
|
+
r"""
|
|
328
|
+
Create free hexadecimal string monoid on generators
|
|
329
|
+
`\{ 0, 1, \dots, 9, a, b, c, d, e, f \}`.
|
|
330
|
+
|
|
331
|
+
EXAMPLES::
|
|
332
|
+
|
|
333
|
+
sage: S = HexadecimalStrings(); S
|
|
334
|
+
Free hexadecimal string monoid
|
|
335
|
+
sage: x = S.gens()
|
|
336
|
+
sage: (x[0]*x[10])**3 * (x[0]*x[1]*x[9]*x[15])**2
|
|
337
|
+
0a0a0a019f019f
|
|
338
|
+
sage: S([ i for i in range(16) ])
|
|
339
|
+
0123456789abcdef
|
|
340
|
+
|
|
341
|
+
sage: x = S.gen(0)
|
|
342
|
+
sage: y = S.gen(10)
|
|
343
|
+
sage: z = S.gen(15)
|
|
344
|
+
sage: z
|
|
345
|
+
f
|
|
346
|
+
sage: x*y^3*z
|
|
347
|
+
0aaaf
|
|
348
|
+
"""
|
|
349
|
+
alph = '0123456789abcdef'
|
|
350
|
+
StringMonoid_class.__init__(self, 16, [alph[i] for i in range(16)])
|
|
351
|
+
|
|
352
|
+
def __repr__(self):
|
|
353
|
+
return "Free hexadecimal string monoid"
|
|
354
|
+
|
|
355
|
+
def __call__(self, x, check=True):
|
|
356
|
+
r"""
|
|
357
|
+
Return ``x`` coerced into this free monoid.
|
|
358
|
+
|
|
359
|
+
One can create a free hexadecimal string monoid element from a
|
|
360
|
+
Python string of a list of integers in `\{ 0, \dots, 15 \}`.
|
|
361
|
+
|
|
362
|
+
EXAMPLES::
|
|
363
|
+
|
|
364
|
+
sage: S = HexadecimalStrings()
|
|
365
|
+
sage: S('0a0a0a019f019f')
|
|
366
|
+
0a0a0a019f019f
|
|
367
|
+
sage: S.gen(0)
|
|
368
|
+
0
|
|
369
|
+
sage: S.gen(1)
|
|
370
|
+
1
|
|
371
|
+
sage: S([ i for i in range(16) ])
|
|
372
|
+
0123456789abcdef
|
|
373
|
+
"""
|
|
374
|
+
# There should really some careful type checking here...
|
|
375
|
+
if isinstance(x, StringMonoidElement) and x.parent() == self:
|
|
376
|
+
return x
|
|
377
|
+
elif isinstance(x, list):
|
|
378
|
+
return StringMonoidElement(self, x, check)
|
|
379
|
+
elif isinstance(x, str):
|
|
380
|
+
return StringMonoidElement(self, x, check)
|
|
381
|
+
else:
|
|
382
|
+
raise TypeError("Argument x (= %s) is of the wrong type." % x)
|
|
383
|
+
|
|
384
|
+
def encoding(self, S, padic=False):
|
|
385
|
+
r"""
|
|
386
|
+
The encoding of the string ``S`` as a hexadecimal string element.
|
|
387
|
+
|
|
388
|
+
The default is to keep the standard right-to-left byte encoding, e.g.
|
|
389
|
+
|
|
390
|
+
::
|
|
391
|
+
|
|
392
|
+
A = '\x41' -> 41
|
|
393
|
+
B = '\x42' -> 42
|
|
394
|
+
.
|
|
395
|
+
.
|
|
396
|
+
.
|
|
397
|
+
Z = '\x5a' -> 5a
|
|
398
|
+
|
|
399
|
+
rather than a left-to-right representation A = 65 -> 14.
|
|
400
|
+
Although standard (e.g., in the Python constructor '\xhh'),
|
|
401
|
+
this can be confusing when the string reads left-to-right.
|
|
402
|
+
|
|
403
|
+
Set ``padic=True`` to reverse the character encoding.
|
|
404
|
+
|
|
405
|
+
EXAMPLES::
|
|
406
|
+
|
|
407
|
+
sage: S = HexadecimalStrings()
|
|
408
|
+
sage: S.encoding('A')
|
|
409
|
+
41
|
|
410
|
+
sage: S.encoding('A',padic=True)
|
|
411
|
+
14
|
|
412
|
+
sage: S.encoding(' ',padic=False)
|
|
413
|
+
20
|
|
414
|
+
sage: S.encoding(' ',padic=True)
|
|
415
|
+
02
|
|
416
|
+
"""
|
|
417
|
+
hex_string = []
|
|
418
|
+
for i in range(len(S)):
|
|
419
|
+
n = ord(S[i])
|
|
420
|
+
n0 = n % 16
|
|
421
|
+
n1 = n // 16
|
|
422
|
+
if not padic:
|
|
423
|
+
hex_chars = [n1, n0]
|
|
424
|
+
else:
|
|
425
|
+
hex_chars = [n0, n1]
|
|
426
|
+
hex_string.extend(hex_chars)
|
|
427
|
+
return self(hex_string)
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
HexadecimalStrings = HexadecimalStringMonoid
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
class Radix64StringMonoid(StringMonoid_class):
|
|
434
|
+
r"""
|
|
435
|
+
The free radix 64 string monoid on 64 generators.
|
|
436
|
+
"""
|
|
437
|
+
|
|
438
|
+
def __init__(self):
|
|
439
|
+
r"""
|
|
440
|
+
Create free radix 64 string monoid on 64 generators.
|
|
441
|
+
|
|
442
|
+
EXAMPLES::
|
|
443
|
+
|
|
444
|
+
sage: S = Radix64Strings(); S
|
|
445
|
+
Free radix 64 string monoid
|
|
446
|
+
sage: x = S.gens()
|
|
447
|
+
sage: (x[50]*x[10])**3 * (x[60]*x[1]*x[19]*x[35])**2
|
|
448
|
+
yKyKyK8BTj8BTj
|
|
449
|
+
sage: S([ i for i in range(64) ])
|
|
450
|
+
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
|
|
451
|
+
sage: x[0]
|
|
452
|
+
A
|
|
453
|
+
sage: x[62]
|
|
454
|
+
+
|
|
455
|
+
sage: x[63]
|
|
456
|
+
/
|
|
457
|
+
"""
|
|
458
|
+
alph = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
459
|
+
StringMonoid_class.__init__(self, 64, [alph[i] for i in range(64)])
|
|
460
|
+
|
|
461
|
+
def __repr__(self):
|
|
462
|
+
return "Free radix 64 string monoid"
|
|
463
|
+
|
|
464
|
+
def __call__(self, x, check=True):
|
|
465
|
+
r"""
|
|
466
|
+
Return ``x`` coerced into this free monoid.
|
|
467
|
+
|
|
468
|
+
One can create a free radix 64 string monoid element from a
|
|
469
|
+
Python string or a list of integers in `0, \dots, 63`, as for
|
|
470
|
+
generic ``FreeMonoids``.
|
|
471
|
+
|
|
472
|
+
EXAMPLES::
|
|
473
|
+
|
|
474
|
+
sage: S = Radix64Strings()
|
|
475
|
+
sage: S.gen(0)
|
|
476
|
+
A
|
|
477
|
+
sage: S.gen(1)
|
|
478
|
+
B
|
|
479
|
+
sage: S.gen(62)
|
|
480
|
+
+
|
|
481
|
+
sage: S.gen(63)
|
|
482
|
+
/
|
|
483
|
+
sage: S([ i for i in range(64) ])
|
|
484
|
+
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
|
|
485
|
+
"""
|
|
486
|
+
# There should really some careful type checking here...
|
|
487
|
+
if isinstance(x, StringMonoidElement) and x.parent() == self:
|
|
488
|
+
return x
|
|
489
|
+
elif isinstance(x, list):
|
|
490
|
+
return StringMonoidElement(self, x, check)
|
|
491
|
+
elif isinstance(x, str):
|
|
492
|
+
return StringMonoidElement(self, x, check)
|
|
493
|
+
else:
|
|
494
|
+
raise TypeError("Argument x (= %s) is of the wrong type." % x)
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
Radix64Strings = Radix64StringMonoid
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
class AlphabeticStringMonoid(StringMonoid_class):
|
|
501
|
+
"""
|
|
502
|
+
The free alphabetic string monoid on generators A-Z.
|
|
503
|
+
|
|
504
|
+
EXAMPLES::
|
|
505
|
+
|
|
506
|
+
sage: # needs sage.rings.real_mpfr
|
|
507
|
+
sage: S = AlphabeticStrings(); S
|
|
508
|
+
Free alphabetic string monoid on A-Z
|
|
509
|
+
sage: S.gen(0)
|
|
510
|
+
A
|
|
511
|
+
sage: S.gen(25)
|
|
512
|
+
Z
|
|
513
|
+
sage: S([ i for i in range(26) ])
|
|
514
|
+
ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
515
|
+
"""
|
|
516
|
+
|
|
517
|
+
def __init__(self):
|
|
518
|
+
r"""
|
|
519
|
+
Create free alphabetic string monoid on generators A-Z.
|
|
520
|
+
|
|
521
|
+
EXAMPLES::
|
|
522
|
+
|
|
523
|
+
sage: # needs sage.rings.real_mpfr
|
|
524
|
+
sage: S = AlphabeticStrings(); S
|
|
525
|
+
Free alphabetic string monoid on A-Z
|
|
526
|
+
sage: S.gen(0)
|
|
527
|
+
A
|
|
528
|
+
sage: S.gen(25)
|
|
529
|
+
Z
|
|
530
|
+
sage: S([ i for i in range(26) ])
|
|
531
|
+
ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
532
|
+
"""
|
|
533
|
+
from sage.rings.real_mpfr import RealField
|
|
534
|
+
RR = RealField()
|
|
535
|
+
# The characteristic frequency probability distribution of
|
|
536
|
+
# Robert Edward Lewand.
|
|
537
|
+
self._characteristic_frequency_lewand = {
|
|
538
|
+
"A": RR(0.08167), "B": RR(0.01492),
|
|
539
|
+
"C": RR(0.02782), "D": RR(0.04253),
|
|
540
|
+
"E": RR(0.12702), "F": RR(0.02228),
|
|
541
|
+
"G": RR(0.02015), "H": RR(0.06094),
|
|
542
|
+
"I": RR(0.06966), "J": RR(0.00153),
|
|
543
|
+
"K": RR(0.00772), "L": RR(0.04025),
|
|
544
|
+
"M": RR(0.02406), "N": RR(0.06749),
|
|
545
|
+
"O": RR(0.07507), "P": RR(0.01929),
|
|
546
|
+
"Q": RR(0.00095), "R": RR(0.05987),
|
|
547
|
+
"S": RR(0.06327), "T": RR(0.09056),
|
|
548
|
+
"U": RR(0.02758), "V": RR(0.00978),
|
|
549
|
+
"W": RR(0.02360), "X": RR(0.00150),
|
|
550
|
+
"Y": RR(0.01974), "Z": RR(0.00074)}
|
|
551
|
+
# The characteristic frequency probability distribution of
|
|
552
|
+
# H. Beker and F. Piper.
|
|
553
|
+
self._characteristic_frequency_beker_piper = {
|
|
554
|
+
"A": RR(0.082), "B": RR(0.015),
|
|
555
|
+
"C": RR(0.028), "D": RR(0.043),
|
|
556
|
+
"E": RR(0.127), "F": RR(0.022),
|
|
557
|
+
"G": RR(0.020), "H": RR(0.061),
|
|
558
|
+
"I": RR(0.070), "J": RR(0.002),
|
|
559
|
+
"K": RR(0.008), "L": RR(0.040),
|
|
560
|
+
"M": RR(0.024), "N": RR(0.067),
|
|
561
|
+
"O": RR(0.075), "P": RR(0.019),
|
|
562
|
+
"Q": RR(0.001), "R": RR(0.060),
|
|
563
|
+
"S": RR(0.063), "T": RR(0.091),
|
|
564
|
+
"U": RR(0.028), "V": RR(0.010),
|
|
565
|
+
"W": RR(0.023), "X": RR(0.001),
|
|
566
|
+
"Y": RR(0.020), "Z": RR(0.001)}
|
|
567
|
+
alph = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
568
|
+
StringMonoid_class.__init__(self, 26, [alph[i] for i in range(26)])
|
|
569
|
+
|
|
570
|
+
def __repr__(self):
|
|
571
|
+
return "Free alphabetic string monoid on A-Z"
|
|
572
|
+
|
|
573
|
+
def __call__(self, x, check=True):
|
|
574
|
+
r"""
|
|
575
|
+
Return ``x`` coerced into this free monoid.
|
|
576
|
+
|
|
577
|
+
One can create a free alphabetic string monoid element from a
|
|
578
|
+
Python string, or a list of integers in `0, \dots,25`.
|
|
579
|
+
|
|
580
|
+
EXAMPLES::
|
|
581
|
+
|
|
582
|
+
sage: # needs sage.rings.real_mpfr
|
|
583
|
+
sage: S = AlphabeticStrings()
|
|
584
|
+
sage: S.gen(0)
|
|
585
|
+
A
|
|
586
|
+
sage: S.gen(1)
|
|
587
|
+
B
|
|
588
|
+
sage: S.gen(25)
|
|
589
|
+
Z
|
|
590
|
+
sage: S([ i for i in range(26) ])
|
|
591
|
+
ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
592
|
+
"""
|
|
593
|
+
# There should really some careful type checking here...
|
|
594
|
+
if isinstance(x, StringMonoidElement) and x.parent() == self:
|
|
595
|
+
return x
|
|
596
|
+
elif isinstance(x, list):
|
|
597
|
+
return StringMonoidElement(self, x, check)
|
|
598
|
+
elif isinstance(x, str):
|
|
599
|
+
return StringMonoidElement(self, x, check)
|
|
600
|
+
else:
|
|
601
|
+
raise TypeError("Argument x (= %s) is of the wrong type." % x)
|
|
602
|
+
|
|
603
|
+
def characteristic_frequency(self, table_name='beker_piper'):
|
|
604
|
+
r"""
|
|
605
|
+
Return a table of the characteristic frequency probability
|
|
606
|
+
distribution of the English alphabet. In written English, various
|
|
607
|
+
letters of the English alphabet occur more frequently than others.
|
|
608
|
+
For example, the letter "E" appears more often than other
|
|
609
|
+
vowels such as "A", "I", "O", and "U". In long works of written
|
|
610
|
+
English such as books, the probability of a letter occurring tends
|
|
611
|
+
to stabilize around a value. We call this value the characteristic
|
|
612
|
+
frequency probability of the letter under consideration. When this
|
|
613
|
+
probability is considered for each letter of the English alphabet,
|
|
614
|
+
the resulting probabilities for all letters of this alphabet is
|
|
615
|
+
referred to as the characteristic frequency probability distribution.
|
|
616
|
+
Various studies report slightly different values for the
|
|
617
|
+
characteristic frequency probability of an English letter. For
|
|
618
|
+
instance, [Lew2000]_ reports that "E" has a characteristic
|
|
619
|
+
frequency probability of 0.12702, while [BP1982]_ reports this
|
|
620
|
+
value as 0.127. The concepts of characteristic frequency probability
|
|
621
|
+
and characteristic frequency probability distribution can also be
|
|
622
|
+
applied to non-empty alphabets other than the English alphabet.
|
|
623
|
+
|
|
624
|
+
The output of this method is different from that of the method
|
|
625
|
+
:func:`frequency_distribution()
|
|
626
|
+
<sage.monoids.string_monoid_element.StringMonoidElement.frequency_distribution>`.
|
|
627
|
+
One can think of the characteristic frequency probability of an
|
|
628
|
+
element in an alphabet `A` as the expected probability of that element
|
|
629
|
+
occurring. Let `S` be a string encoded using elements of `A`. The
|
|
630
|
+
frequency probability distribution corresponding to `S` provides us
|
|
631
|
+
with the frequency probability of each element of `A` as observed
|
|
632
|
+
occurring in `S`. Thus one distribution provides expected
|
|
633
|
+
probabilities, while the other provides observed probabilities.
|
|
634
|
+
|
|
635
|
+
INPUT:
|
|
636
|
+
|
|
637
|
+
- ``table_name`` -- (default: ``'beker_piper'``) the table of
|
|
638
|
+
characteristic frequency probability distribution to use. The
|
|
639
|
+
following tables are supported:
|
|
640
|
+
|
|
641
|
+
- ``'beker_piper'`` -- the table of characteristic frequency
|
|
642
|
+
probability distribution by Beker and Piper [BP1982]_. This is
|
|
643
|
+
the default table to use.
|
|
644
|
+
|
|
645
|
+
- ``'lewand'`` -- the table of characteristic frequency
|
|
646
|
+
probability distribution by Lewand as described on page 36
|
|
647
|
+
of [Lew2000]_.
|
|
648
|
+
|
|
649
|
+
OUTPUT:
|
|
650
|
+
|
|
651
|
+
- A table of the characteristic frequency probability distribution
|
|
652
|
+
of the English alphabet. This is a dictionary of letter/probability
|
|
653
|
+
pairs.
|
|
654
|
+
|
|
655
|
+
EXAMPLES:
|
|
656
|
+
|
|
657
|
+
The characteristic frequency probability distribution table of
|
|
658
|
+
Beker and Piper [BP1982]_::
|
|
659
|
+
|
|
660
|
+
sage: # needs sage.rings.real_mpfr
|
|
661
|
+
sage: A = AlphabeticStrings()
|
|
662
|
+
sage: table = A.characteristic_frequency(table_name='beker_piper')
|
|
663
|
+
sage: sorted(table.items())
|
|
664
|
+
<BLANKLINE>
|
|
665
|
+
[('A', 0.0820000000000000),
|
|
666
|
+
('B', 0.0150000000000000),
|
|
667
|
+
('C', 0.0280000000000000),
|
|
668
|
+
('D', 0.0430000000000000),
|
|
669
|
+
('E', 0.127000000000000),
|
|
670
|
+
('F', 0.0220000000000000),
|
|
671
|
+
('G', 0.0200000000000000),
|
|
672
|
+
('H', 0.0610000000000000),
|
|
673
|
+
('I', 0.0700000000000000),
|
|
674
|
+
('J', 0.00200000000000000),
|
|
675
|
+
('K', 0.00800000000000000),
|
|
676
|
+
('L', 0.0400000000000000),
|
|
677
|
+
('M', 0.0240000000000000),
|
|
678
|
+
('N', 0.0670000000000000),
|
|
679
|
+
('O', 0.0750000000000000),
|
|
680
|
+
('P', 0.0190000000000000),
|
|
681
|
+
('Q', 0.00100000000000000),
|
|
682
|
+
('R', 0.0600000000000000),
|
|
683
|
+
('S', 0.0630000000000000),
|
|
684
|
+
('T', 0.0910000000000000),
|
|
685
|
+
('U', 0.0280000000000000),
|
|
686
|
+
('V', 0.0100000000000000),
|
|
687
|
+
('W', 0.0230000000000000),
|
|
688
|
+
('X', 0.00100000000000000),
|
|
689
|
+
('Y', 0.0200000000000000),
|
|
690
|
+
('Z', 0.00100000000000000)]
|
|
691
|
+
|
|
692
|
+
The characteristic frequency probability distribution table
|
|
693
|
+
of Lewand [Lew2000]_::
|
|
694
|
+
|
|
695
|
+
sage: # needs sage.rings.real_mpfr
|
|
696
|
+
sage: table = A.characteristic_frequency(table_name='lewand')
|
|
697
|
+
sage: sorted(table.items())
|
|
698
|
+
<BLANKLINE>
|
|
699
|
+
[('A', 0.0816700000000000),
|
|
700
|
+
('B', 0.0149200000000000),
|
|
701
|
+
('C', 0.0278200000000000),
|
|
702
|
+
('D', 0.0425300000000000),
|
|
703
|
+
('E', 0.127020000000000),
|
|
704
|
+
('F', 0.0222800000000000),
|
|
705
|
+
('G', 0.0201500000000000),
|
|
706
|
+
('H', 0.0609400000000000),
|
|
707
|
+
('I', 0.0696600000000000),
|
|
708
|
+
('J', 0.00153000000000000),
|
|
709
|
+
('K', 0.00772000000000000),
|
|
710
|
+
('L', 0.0402500000000000),
|
|
711
|
+
('M', 0.0240600000000000),
|
|
712
|
+
('N', 0.0674900000000000),
|
|
713
|
+
('O', 0.0750700000000000),
|
|
714
|
+
('P', 0.0192900000000000),
|
|
715
|
+
('Q', 0.000950000000000000),
|
|
716
|
+
('R', 0.0598700000000000),
|
|
717
|
+
('S', 0.0632700000000000),
|
|
718
|
+
('T', 0.0905600000000000),
|
|
719
|
+
('U', 0.0275800000000000),
|
|
720
|
+
('V', 0.00978000000000000),
|
|
721
|
+
('W', 0.0236000000000000),
|
|
722
|
+
('X', 0.00150000000000000),
|
|
723
|
+
('Y', 0.0197400000000000),
|
|
724
|
+
('Z', 0.000740000000000000)]
|
|
725
|
+
|
|
726
|
+
Illustrating the difference between :func:`characteristic_frequency`
|
|
727
|
+
and :func:`frequency_distribution() <sage.monoids.string_monoid_element.StringMonoidElement.frequency_distribution>`::
|
|
728
|
+
|
|
729
|
+
sage: # needs sage.rings.real_mpfr
|
|
730
|
+
sage: A = AlphabeticStrings()
|
|
731
|
+
sage: M = A.encoding("abcd")
|
|
732
|
+
sage: FD = M.frequency_distribution().function()
|
|
733
|
+
sage: sorted(FD.items())
|
|
734
|
+
<BLANKLINE>
|
|
735
|
+
[(A, 0.250000000000000),
|
|
736
|
+
(B, 0.250000000000000),
|
|
737
|
+
(C, 0.250000000000000),
|
|
738
|
+
(D, 0.250000000000000)]
|
|
739
|
+
sage: CF = A.characteristic_frequency()
|
|
740
|
+
sage: sorted(CF.items())
|
|
741
|
+
<BLANKLINE>
|
|
742
|
+
[('A', 0.0820000000000000),
|
|
743
|
+
('B', 0.0150000000000000),
|
|
744
|
+
('C', 0.0280000000000000),
|
|
745
|
+
('D', 0.0430000000000000),
|
|
746
|
+
('E', 0.127000000000000),
|
|
747
|
+
('F', 0.0220000000000000),
|
|
748
|
+
('G', 0.0200000000000000),
|
|
749
|
+
('H', 0.0610000000000000),
|
|
750
|
+
('I', 0.0700000000000000),
|
|
751
|
+
('J', 0.00200000000000000),
|
|
752
|
+
('K', 0.00800000000000000),
|
|
753
|
+
('L', 0.0400000000000000),
|
|
754
|
+
('M', 0.0240000000000000),
|
|
755
|
+
('N', 0.0670000000000000),
|
|
756
|
+
('O', 0.0750000000000000),
|
|
757
|
+
('P', 0.0190000000000000),
|
|
758
|
+
('Q', 0.00100000000000000),
|
|
759
|
+
('R', 0.0600000000000000),
|
|
760
|
+
('S', 0.0630000000000000),
|
|
761
|
+
('T', 0.0910000000000000),
|
|
762
|
+
('U', 0.0280000000000000),
|
|
763
|
+
('V', 0.0100000000000000),
|
|
764
|
+
('W', 0.0230000000000000),
|
|
765
|
+
('X', 0.00100000000000000),
|
|
766
|
+
('Y', 0.0200000000000000),
|
|
767
|
+
('Z', 0.00100000000000000)]
|
|
768
|
+
|
|
769
|
+
TESTS:
|
|
770
|
+
|
|
771
|
+
The table name must be either "beker_piper" or "lewand"::
|
|
772
|
+
|
|
773
|
+
sage: # needs sage.rings.real_mpfr
|
|
774
|
+
sage: table = A.characteristic_frequency(table_name="")
|
|
775
|
+
Traceback (most recent call last):
|
|
776
|
+
...
|
|
777
|
+
ValueError: Table name must be either 'beker_piper' or 'lewand'.
|
|
778
|
+
sage: table = A.characteristic_frequency(table_name='none')
|
|
779
|
+
Traceback (most recent call last):
|
|
780
|
+
...
|
|
781
|
+
ValueError: Table name must be either 'beker_piper' or 'lewand'.
|
|
782
|
+
"""
|
|
783
|
+
supported_tables = ["beker_piper", "lewand"]
|
|
784
|
+
if table_name not in supported_tables:
|
|
785
|
+
raise ValueError(
|
|
786
|
+
"Table name must be either 'beker_piper' or 'lewand'.")
|
|
787
|
+
from copy import copy
|
|
788
|
+
if table_name == "beker_piper":
|
|
789
|
+
return copy(self._characteristic_frequency_beker_piper)
|
|
790
|
+
if table_name == "lewand":
|
|
791
|
+
return copy(self._characteristic_frequency_lewand)
|
|
792
|
+
|
|
793
|
+
def encoding(self, S):
|
|
794
|
+
r"""
|
|
795
|
+
The encoding of the string ``S`` in the alphabetic string monoid,
|
|
796
|
+
obtained by the monoid homomorphism
|
|
797
|
+
|
|
798
|
+
::
|
|
799
|
+
|
|
800
|
+
A -> A, ..., Z -> Z, a -> A, ..., z -> Z
|
|
801
|
+
|
|
802
|
+
and stripping away all other characters. It should be noted that
|
|
803
|
+
this is a non-injective monoid homomorphism.
|
|
804
|
+
|
|
805
|
+
EXAMPLES::
|
|
806
|
+
|
|
807
|
+
sage: # needs sage.rings.real_mpfr
|
|
808
|
+
sage: S = AlphabeticStrings()
|
|
809
|
+
sage: s = S.encoding("The cat in the hat."); s
|
|
810
|
+
THECATINTHEHAT
|
|
811
|
+
sage: s.decoding()
|
|
812
|
+
'THECATINTHEHAT'
|
|
813
|
+
"""
|
|
814
|
+
return self(strip_encoding(S))
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
AlphabeticStrings = AlphabeticStringMonoid
|