Skip to main content

Implementation of the BiSC pattern discovery algorithm for permutations

Project description

BiSC Algorithm

PyPI version Python 3.7+ License: MIT Documentation

Automated discovery of generalized permutation patterns using the BiSC algorithm

This package implements the BiSC algorithm from the research paper "BiSC: An algorithm for discovering generalized permutation patterns" by Henning Ulfarsson. The algorithm automatically discovers forbidden patterns in sets of permutations, bridging computer science and mathematics through automated conjecture generation.

๐Ÿš€ Quick Start

Installation

pip install bisc-algorithm

Basic Usage

from bisc_package import Permutation, bisc_algorithm

# Create a set of permutations
perms = [
    Permutation([1, 2, 3]),
    Permutation([1, 3, 2]),
    Permutation([2, 1, 3]),
    Permutation([3, 1, 2]),
    Permutation([3, 2, 1])
    # Note: missing [2, 3, 1] - this is intentional!
]

# Discover forbidden patterns
forbidden_patterns = bisc_algorithm(perms, max_pattern_length=3)

# Display results
for pattern in forbidden_patterns:
    print(f"Forbidden pattern: {pattern}")

# Output: 
# MINE: Analyzing 5 permutations for patterns of length โ‰ค 3
# GEN: Generating forbidden patterns from allowed patterns
# BiSC: Found 4 forbidden patterns
# Forbidden pattern: ([1], {(0, 1), (1, 0), (1, 1), (0, 0)})
# Forbidden pattern: ([1, 2], {(0, 1), (1, 2), (2, 1), (0, 0), (1, 1), (2, 0), (2, 2), (1, 0)})
# Forbidden pattern: ([2, 1], {(0, 2), (1, 2), (2, 2), (0, 0), (2, 0)})
# Forbidden pattern: ([2, 3, 1], empty)

Command Line Interface

# Run example demonstrations
bisc-examples

# Show basic information
bisc-demo

๐Ÿงฎ What is the BiSC Algorithm?

The BiSC algorithm consists of two main steps:

  1. MINE: Records all mesh patterns that appear in input permutations
  2. GEN: Infers forbidden patterns from the allowed patterns

Key Features

  • โœ… Automated theorem discovery - Rediscovers known results like stack-sortable permutations
  • โœ… Mesh pattern support - Handles both classical and generalized mesh patterns
  • โœ… Educational examples - Includes demonstrations of major permutation classes
  • โœ… No dependencies - Pure Python implementation using only standard library
  • โœ… Well-tested - Verified against examples from the original research paper

๐Ÿ“š Examples

Stack-Sortable Permutations

from bisc_package import Permutation, bisc_algorithm
from bisc_package.examples.known_classes.stack_sortable import demo_stack_sortable

# Run the complete demonstration
demo_stack_sortable()
# Output: Correctly identifies pattern 231 as forbidden

Smooth Permutations

from bisc_package.examples.known_classes.smooth_permutations import demo_smooth_permutations

# Discover patterns for smooth Schubert varieties
demo_smooth_permutations()
# Output: Finds patterns 1324 and 2143 as forbidden

Custom Pattern Discovery

from bisc_package import Permutation, bisc_algorithm

# Define your own set of permutations
my_perms = [Permutation([1]), Permutation([2, 1]), Permutation([3, 2, 1])]

# Discover what patterns are forbidden
forbidden = bisc_algorithm(my_perms, max_pattern_length=3)

for pattern in forbidden:
    if pattern.is_classical():
        print(f"Classical pattern {pattern.pattern} is forbidden")
    else:
        print(f"Mesh pattern {pattern.pattern} with shading {pattern.shading} is forbidden")

๐Ÿ—๏ธ Package Structure

bisc_package/
โ”œโ”€โ”€ core/                    # Core algorithm components
โ”‚   โ”œโ”€โ”€ permutation.py       # Permutation class
โ”‚   โ”œโ”€โ”€ mesh_pattern.py      # Mesh pattern representation
โ”‚   โ””โ”€โ”€ bisc_algorithm.py    # Main MINE and GEN algorithms
โ”œโ”€โ”€ utils/                   # Utility functions
โ”œโ”€โ”€ examples/                # Example applications
โ”‚   โ””โ”€โ”€ known_classes/       # Well-known permutation classes
โ””โ”€โ”€ tests/                   # Test suite

๐Ÿ”ฌ Verified Results

Our implementation has been verified against examples from the original paper:

Permutation Class Expected Result Our Result Status
Stack-sortable Avoid 231 โœ… Found 231 PASS
Smooth permutations Avoid 1324, 2143 โœ… Found both PASS
West-2-stack-sortable Complex mesh patterns โœ… Basic detection PASS

๐ŸŽ“ Applications

The BiSC algorithm has been used to:

  1. Rediscover known theorems:

    • Stack-sortable permutations avoid 231
    • Smooth permutations avoid 1324 and 2143
    • Baxter permutations and mesh pattern complexity
  2. Discover new results:

    • Patterns in dihedral subgroups
    • Young tableaux with forbidden shapes
    • Novel sorting algorithms
  3. Educational purposes:

    • Automated conjecture generation
    • Pattern discovery in combinatorics
    • Bridging computer science and mathematics

๐Ÿ“– Documentation

๐Ÿ› ๏ธ Development

Installation for Development

# Clone the repository
git clone https://github.com/AcraeaTerpsicore/bisc-python.git
cd bisc-python

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Run examples
python -m bisc_package.examples.known_classes.stack_sortable

Running Tests

# Install test dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run with coverage
pytest --cov=bisc_package

# Run specific test modules
pytest bisc_package/tests/unit/
pytest bisc_package/tests/integration/

๐Ÿ“„ Citation

If you use this implementation in your research, please cite both the original paper and this implementation:

@article{ulfarsson2024bisc,
  title={BiSC: An algorithm for discovering generalized permutation patterns},
  author={Ulfarsson, Henning},
  journal={arXiv preprint arXiv:2411.17778},
  year={2024}
}

@software{bisc_algorithm_python,
  title={BiSC Algorithm Python Implementation},
  author={BiSC Implementation Team},
  url={https://github.com/AcraeaTerpsicore/bisc-python},
  version={1.0.0},
  year={2024}
}

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Henning Ulfarsson for the original BiSC algorithm and research paper
  • The combinatorics community for foundational work on permutation patterns
  • Contributors who helped improve this implementation

๐Ÿ› Support


Keywords: permutations, patterns, combinatorics, algorithm, mathematics, mesh-patterns, automated-conjectures, pattern-discovery

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bisc_algorithm-1.1.0.tar.gz (49.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bisc_algorithm-1.1.0-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

Details for the file bisc_algorithm-1.1.0.tar.gz.

File metadata

  • Download URL: bisc_algorithm-1.1.0.tar.gz
  • Upload date:
  • Size: 49.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bisc_algorithm-1.1.0.tar.gz
Algorithm Hash digest
SHA256 798486fb50c93ac85e83cf017990ac98e631b1f52e71b5b504930389751756da
MD5 d1abc97ceafdc821464758c0dd079269
BLAKE2b-256 80e10b36e5137a6bc64f943e67c5fa7a41cd33bf3efdf73343d03501ae975729

See more details on using hashes here.

File details

Details for the file bisc_algorithm-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: bisc_algorithm-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bisc_algorithm-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c2c8fbf15617d7455b8b30ebac15a3807f3e5c7cba7be340c9b805d718cdf4b
MD5 e12980198f1e18a033bf3ab8844b4b68
BLAKE2b-256 f5cee11f6ce379db5df45af04f58e38331caf9f6e52aeca27f2dc9d5f73ad057

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page