bisc_package.core package
Submodules
bisc_package.core.bisc_algorithm module
Main BiSC algorithm implementation.
This module contains the core MINE and GEN algorithms, as well as the main BiSC algorithm that combines them.
- bisc_package.core.bisc_algorithm.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.core.bisc_algorithm.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.
- bisc_package.core.bisc_algorithm.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.core.bisc_algorithm.bisc_with_pruning(permutations, max_pattern_length)[source]
BiSC algorithm with additional pruning step.
This version includes post-processing to remove redundant patterns.
- Parameters:
permutations (
List[Permutation]) – Input set of permutationsmax_pattern_length (
int) – Upper bound on pattern length to search for
- Return type:
- Returns:
List of minimal forbidden patterns
bisc_package.core.mesh_pattern module
Mesh pattern class for the BiSC algorithm.
This module provides the MeshPattern class for representing classical patterns with shaded regions.
- class bisc_package.core.mesh_pattern.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
- remove_shading(region)[source]
Return a new mesh pattern with a shaded region removed.
- Parameters:
- Return type:
- Returns:
New MeshPattern without the specified shading
bisc_package.core.permutation module
Permutation class for the BiSC algorithm.
This module provides the core Permutation class with methods for subword enumeration and pattern analysis.
- class bisc_package.core.permutation.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).
- 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
- contains_classical_pattern(pattern)[source]
Check if this permutation contains a classical pattern.
Module contents
Core BiSC algorithm components.
- class bisc_package.core.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.core.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.core.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.core.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.core.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.