bisc_package package
Subpackages
- bisc_package.core package
- Submodules
- bisc_package.core.bisc_algorithm module
- bisc_package.core.mesh_pattern module
MeshPatternMeshPattern.patternMeshPattern.shadingMeshPattern.lengthMeshPattern.__init__()MeshPattern.__str__()MeshPattern.__repr__()MeshPattern.__eq__()MeshPattern.__hash__()MeshPattern.is_classical()MeshPattern.add_shading()MeshPattern.remove_shading()MeshPattern.get_all_regions()MeshPattern.get_unshaded_regions()MeshPattern.is_shading_maximal()MeshPattern.get_classical_pattern()MeshPattern.to_latex()
- bisc_package.core.permutation module
- Module contents
PermutationMeshPatternMeshPattern.patternMeshPattern.shadingMeshPattern.lengthMeshPattern.__eq__()MeshPattern.__hash__()MeshPattern.__init__()MeshPattern.__repr__()MeshPattern.__str__()MeshPattern.add_shading()MeshPattern.get_all_regions()MeshPattern.get_classical_pattern()MeshPattern.get_unshaded_regions()MeshPattern.is_classical()MeshPattern.is_shading_maximal()MeshPattern.remove_shading()MeshPattern.to_latex()
bisc_algorithm()mine_algorithm()gen_algorithm()
- bisc_package.examples package
- Subpackages
- bisc_package.examples.known_classes package
- Submodules
- bisc_package.examples.known_classes.baxter_permutations module
- bisc_package.examples.known_classes.corrected_baxter_test module
- bisc_package.examples.known_classes.smooth_permutations module
- bisc_package.examples.known_classes.stack_sortable module
- bisc_package.examples.known_classes.test_baxter module
- Module contents
- bisc_package.examples.paper_examples package
- bisc_package.examples.known_classes package
- Submodules
- bisc_package.examples.bisc_demo module
- Module contents
- Subpackages
- bisc_package.tests package
- bisc_package.utils package
Submodules
bisc_package.cli module
Command-line interface for the BiSC algorithm package.
This module provides console commands for running examples and demonstrations.
Module contents
BiSC Algorithm Package
Implementation of the BiSC algorithm from “BiSC: An algorithm for discovering generalized permutation patterns” by Henning Ulfarsson.
The BiSC algorithm automatically discovers forbidden patterns in sets of permutations, bridging computer science and mathematics through automated conjecture generation.
- class bisc_package.Permutation(sequence)[source]
Bases:
objectRepresents a permutation in one-line notation.
A permutation is a bijection from {1, 2, …, n} to itself. We represent it as a list where position i contains the value π(i).
- contains_classical_pattern(pattern)[source]
Check if this permutation contains a classical pattern.
- subwords(max_length)[source]
Generate all subwords of length at most max_length.
- Parameters:
max_length (
int) – Maximum length of subwords to generate- Returns:
subword is the subsequence of values
positions is the list of indices where these values occur
- Return type:
List of tuples (subword, positions) where
- class bisc_package.MeshPattern(pattern, shading=None)[source]
Bases:
objectRepresents a mesh pattern (classical pattern + shading).
A mesh pattern consists of: 1. A classical pattern (permutation) 2. A set of shaded regions that forbid elements from appearing
- add_shading(region)[source]
Return a new mesh pattern with an additional shaded region.
- Parameters:
- Return type:
- Returns:
New MeshPattern with the additional shading
- is_shading_maximal(allowed_shadings)[source]
Check if this shading is maximal among allowed shadings.
- bisc_package.bisc_algorithm(permutations, max_pattern_length)[source]
The full BiSC algorithm.
Combines the MINE and GEN algorithms to discover forbidden patterns in a set of permutations.
- Parameters:
permutations (
List[Permutation]) – Input set of permutationsmax_pattern_length (
int) – Upper bound on pattern length to search for
- Return type:
- Returns:
List of conjectured forbidden patterns
Examples
>>> # Stack-sortable permutations >>> stack_sortable = [Permutation([1]), Permutation([1,2]), ...] >>> forbidden = bisc_algorithm(stack_sortable, max_pattern_length=3) >>> # Should find pattern 231 as forbidden
- bisc_package.mine_algorithm(permutations, max_pattern_length)[source]
The MINE algorithm (Algorithm 1 from the paper).
Finds all mesh patterns that are contained in permutations in the input. This is the first step of the BiSC algorithm.
- Parameters:
permutations (
List[Permutation]) – List of input permutationsmax_pattern_length (
int) – Upper bound on pattern length to search for
- Return type:
- Returns:
Dictionary mapping classical patterns to sets of maximal shadings
Note
The output maps pattern tuples to sets of frozensets, where each frozenset represents a maximal shading for that pattern.
- bisc_package.gen_algorithm(S)[source]
The GEN algorithm (Algorithm 2 from the paper).
Generates forbidden patterns from the allowed patterns found by MINE. This is the second step of the BiSC algorithm.
- Parameters:
S (
Dict[Tuple[int,...],Set[FrozenSet]]) – Output from MINE algorithm - patterns with their allowed shadings- Return type:
- Returns:
List of forbidden mesh patterns
Note
This generates minimal forbidden shadings that are not contained in any allowed shading.