schur-weyl 0.1.0__tar.gz
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.
- schur_weyl-0.1.0/.github/workflows/python-publish.yml +70 -0
- schur_weyl-0.1.0/.gitignore +220 -0
- schur_weyl-0.1.0/LICENSE +21 -0
- schur_weyl-0.1.0/PKG-INFO +95 -0
- schur_weyl-0.1.0/README.md +80 -0
- schur_weyl-0.1.0/TODO.md +3 -0
- schur_weyl-0.1.0/pyproject.toml +25 -0
- schur_weyl-0.1.0/src/schur_weyl/__init__.py +5 -0
- schur_weyl-0.1.0/src/schur_weyl/character.py +82 -0
- schur_weyl-0.1.0/src/schur_weyl/dimensions.py +55 -0
- schur_weyl-0.1.0/src/schur_weyl/isotypic.py +37 -0
- schur_weyl-0.1.0/src/schur_weyl/sw_measure.py +20 -0
- schur_weyl-0.1.0/src/schur_weyl/symmetric_functions.py +64 -0
- schur_weyl-0.1.0/src/schur_weyl/symmetric_group.py +126 -0
- schur_weyl-0.1.0/src/schur_weyl/tableaux.py +168 -0
- schur_weyl-0.1.0/src/schur_weyl/young_diagrams.py +194 -0
- schur_weyl-0.1.0/src/schur_weyl/young_orthonormal.py +147 -0
- schur_weyl-0.1.0/tests/test_character.py +50 -0
- schur_weyl-0.1.0/tests/test_dimensions.py +15 -0
- schur_weyl-0.1.0/tests/test_isotypic.py +59 -0
- schur_weyl-0.1.0/tests/test_sw_measure.py +16 -0
- schur_weyl-0.1.0/tests/test_symmetric_functions.py +22 -0
- schur_weyl-0.1.0/tests/test_symmetric_group.py +18 -0
- schur_weyl-0.1.0/tests/test_tableaux.py +36 -0
- schur_weyl-0.1.0/tests/test_young_diagrams.py +16 -0
- schur_weyl-0.1.0/tests/test_young_orthonormal.py +43 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# This workflow will upload a Python Package to PyPI when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [published]
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
release-build:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.x"
|
|
28
|
+
|
|
29
|
+
- name: Build release distributions
|
|
30
|
+
run: |
|
|
31
|
+
# NOTE: put your own distribution build steps here.
|
|
32
|
+
python -m pip install build
|
|
33
|
+
python -m build
|
|
34
|
+
|
|
35
|
+
- name: Upload distributions
|
|
36
|
+
uses: actions/upload-artifact@v4
|
|
37
|
+
with:
|
|
38
|
+
name: release-dists
|
|
39
|
+
path: dist/
|
|
40
|
+
|
|
41
|
+
pypi-publish:
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
needs:
|
|
44
|
+
- release-build
|
|
45
|
+
permissions:
|
|
46
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
47
|
+
id-token: write
|
|
48
|
+
|
|
49
|
+
# Dedicated environments with protections for publishing are strongly recommended.
|
|
50
|
+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
|
|
51
|
+
environment:
|
|
52
|
+
name: pypi
|
|
53
|
+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
|
|
54
|
+
# url: https://pypi.org/p/YOURPROJECT
|
|
55
|
+
#
|
|
56
|
+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
|
|
57
|
+
# ALTERNATIVE: exactly, uncomment the following line instead:
|
|
58
|
+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
|
|
59
|
+
|
|
60
|
+
steps:
|
|
61
|
+
- name: Retrieve release distributions
|
|
62
|
+
uses: actions/download-artifact@v4
|
|
63
|
+
with:
|
|
64
|
+
name: release-dists
|
|
65
|
+
path: dist/
|
|
66
|
+
|
|
67
|
+
- name: Publish release distributions to PyPI
|
|
68
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
69
|
+
with:
|
|
70
|
+
packages-dir: dist/
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
|
|
220
|
+
.selfDoc/
|
schur_weyl-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anton Van Cleemput
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: schur-weyl
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tools from Schur-Weyl duality
|
|
5
|
+
Project-URL: Homepage, https://github.com/AVlyx/schur-weyl
|
|
6
|
+
Author-email: Anton Van Cleemput <anton@vancleem.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Requires-Dist: numpy>=1.24
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
13
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# schur-weyl
|
|
17
|
+
|
|
18
|
+
Tools from Schur–Weyl duality, built from scratch on top of `numpy` and the Python standard library — no representation-theory or combinatorics dependencies.
|
|
19
|
+
|
|
20
|
+
Schur–Weyl duality decomposes $(\mathbb{C}^d)^{\otimes n}$ under the commuting actions of $S_n$ (permuting tensor factors) and $GL_d$ (acting diagonally) into isotypic blocks indexed by partitions $\lambda \vdash n$ with $\ell(\lambda) \le d$:
|
|
21
|
+
|
|
22
|
+
$$(\mathbb{C}^d)^{\otimes n} \cong \bigoplus_{\lambda} S^\lambda \otimes V_\lambda^d$$
|
|
23
|
+
|
|
24
|
+
This package implements the combinatorics and linear algebra needed to work with that decomposition directly: partitions and Young tableaux, dimension formulas, symmetric-group characters via Murnaghan–Nakayama, Schur polynomials, isotypic projectors on tensor space, the Schur–Weyl measure, and Young's orthogonal form for the irreducible representations of $S_n$.
|
|
25
|
+
|
|
26
|
+
Every module is checked against an exact mathematical identity in the test suite (Burnside's identity, character orthogonality, projector idempotence, unitarity of Young's orthogonal form, the Jucys–Murphy diagonalization, ...) rather than against hand-computed examples alone. See [`.selfDoc/schur_weyl_roadmap.md`](.selfDoc/schur_weyl_roadmap.md) for the full design roadmap and the identities each phase is gated on.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
Requires Python ≥ 3.9.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install schur-weyl
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The package itself only depends on `numpy`. For local development (cloning the repo, running the test suite), install it editable with the `dev` extra instead, which pulls in `pytest` and `ruff`:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install -e ".[dev]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Modules
|
|
43
|
+
|
|
44
|
+
| Module | Contents |
|
|
45
|
+
|---|---|
|
|
46
|
+
| [`young_diagrams`](src/schur_weyl/young_diagrams.py) | Partitions, conjugation, hook lengths, content, dominance order, addable/removable corners |
|
|
47
|
+
| [`dimensions`](src/schur_weyl/dimensions.py) | $f^\lambda$ (Specht module dimension, hook-length formula) and $\dim V_\lambda^d$ (Weyl module dimension, content formula) |
|
|
48
|
+
| [`tableaux`](src/schur_weyl/tableaux.py) | Standard and semistandard Young tableaux, Kostka numbers, reading words |
|
|
49
|
+
| [`symmetric_group`](src/schur_weyl/symmetric_group.py) | Permutations as 0-indexed one-line tuples: composition, inverse, cycle type, conjugacy class sizes |
|
|
50
|
+
| [`character`](src/schur_weyl/character.py) | Irreducible characters $\chi^\lambda(\mu)$ of $S_n$ via the Murnaghan–Nakayama rule; full character tables |
|
|
51
|
+
| [`symmetric_functions`](src/schur_weyl/symmetric_functions.py) | Schur polynomials (Jacobi–Trudi) and power-sum symmetric functions |
|
|
52
|
+
| [`isotypic`](src/schur_weyl/isotypic.py) | Isotypic projectors $P_\lambda$ acting on $(\mathbb{C}^d)^{\otimes n}$, built from class sums of the permutation action |
|
|
53
|
+
| [`sw_measure`](src/schur_weyl/sw_measure.py) | The Schur–Weyl measure $\Pr[\lambda] = f^\lambda\, s_\lambda(\mathrm{spec}\,\rho)$ for i.i.d. copies of a state $\rho$ |
|
|
54
|
+
| [`young_orthonormal`](src/schur_weyl/young_orthonormal.py) | Young's orthogonal form: explicit irrep matrices $\rho^\lambda(\sigma)$ indexed by standard tableaux, and the Jucys–Murphy elements |
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from schur_weyl import (
|
|
60
|
+
partitions, dim_specht, dim_weyl, kostka,
|
|
61
|
+
schur_polynomial, isotypic_proj,
|
|
62
|
+
)
|
|
63
|
+
from schur_weyl.character import character, character_table
|
|
64
|
+
from schur_weyl.sw_measure import schur_weyl_measure
|
|
65
|
+
|
|
66
|
+
# dimension formulas
|
|
67
|
+
dim_specht((2, 1)) # -> 2, the standard rep of S_3
|
|
68
|
+
dim_weyl((2, 1), d=3) # -> 8
|
|
69
|
+
|
|
70
|
+
# characters via Murnaghan-Nakayama
|
|
71
|
+
character((2, 1), (3,)) # -> -1
|
|
72
|
+
|
|
73
|
+
# the Schur-Weyl measure for n i.i.d. copies of a state with given spectrum
|
|
74
|
+
schur_weyl_measure(spectrum=[0.7, 0.3], k=4)
|
|
75
|
+
# -> {(4,): 0.2401, (3, 1): 0.4116, (2, 2): 0.1323, (2, 1, 1): 0.0189, ...}
|
|
76
|
+
|
|
77
|
+
# the isotypic projector on (C^d)^{\otimes n}
|
|
78
|
+
P = isotypic_proj((2, 1), d=2) # np.ndarray, P @ P == P
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Testing
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pytest
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Tests live in [`tests/`](tests) and mirror the module layout; most assert the closed-form identities from the roadmap (e.g. $\sum_\lambda (f^\lambda)^2 = n!$, character-table orthogonality, $P_\lambda^2 = P_\lambda$, $\operatorname{tr}\rho^\lambda(X_k)$ diagonal with content eigenvalues) rather than fixed expected outputs.
|
|
88
|
+
|
|
89
|
+
## Status
|
|
90
|
+
|
|
91
|
+
Implemented through Young's orthogonal form and Jucys–Murphy elements (roadmap phases 0–5, 7–9). Not yet implemented: the generic tensor-space permutation action as a standalone module (phase 6, currently inlined in `isotypic`), and the explicit Schur transform (phase 10). See [`TODO.md`](TODO.md) for near-term items.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# schur-weyl
|
|
2
|
+
|
|
3
|
+
Tools from Schur–Weyl duality, built from scratch on top of `numpy` and the Python standard library — no representation-theory or combinatorics dependencies.
|
|
4
|
+
|
|
5
|
+
Schur–Weyl duality decomposes $(\mathbb{C}^d)^{\otimes n}$ under the commuting actions of $S_n$ (permuting tensor factors) and $GL_d$ (acting diagonally) into isotypic blocks indexed by partitions $\lambda \vdash n$ with $\ell(\lambda) \le d$:
|
|
6
|
+
|
|
7
|
+
$$(\mathbb{C}^d)^{\otimes n} \cong \bigoplus_{\lambda} S^\lambda \otimes V_\lambda^d$$
|
|
8
|
+
|
|
9
|
+
This package implements the combinatorics and linear algebra needed to work with that decomposition directly: partitions and Young tableaux, dimension formulas, symmetric-group characters via Murnaghan–Nakayama, Schur polynomials, isotypic projectors on tensor space, the Schur–Weyl measure, and Young's orthogonal form for the irreducible representations of $S_n$.
|
|
10
|
+
|
|
11
|
+
Every module is checked against an exact mathematical identity in the test suite (Burnside's identity, character orthogonality, projector idempotence, unitarity of Young's orthogonal form, the Jucys–Murphy diagonalization, ...) rather than against hand-computed examples alone. See [`.selfDoc/schur_weyl_roadmap.md`](.selfDoc/schur_weyl_roadmap.md) for the full design roadmap and the identities each phase is gated on.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Requires Python ≥ 3.9.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install schur-weyl
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The package itself only depends on `numpy`. For local development (cloning the repo, running the test suite), install it editable with the `dev` extra instead, which pulls in `pytest` and `ruff`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install -e ".[dev]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Modules
|
|
28
|
+
|
|
29
|
+
| Module | Contents |
|
|
30
|
+
|---|---|
|
|
31
|
+
| [`young_diagrams`](src/schur_weyl/young_diagrams.py) | Partitions, conjugation, hook lengths, content, dominance order, addable/removable corners |
|
|
32
|
+
| [`dimensions`](src/schur_weyl/dimensions.py) | $f^\lambda$ (Specht module dimension, hook-length formula) and $\dim V_\lambda^d$ (Weyl module dimension, content formula) |
|
|
33
|
+
| [`tableaux`](src/schur_weyl/tableaux.py) | Standard and semistandard Young tableaux, Kostka numbers, reading words |
|
|
34
|
+
| [`symmetric_group`](src/schur_weyl/symmetric_group.py) | Permutations as 0-indexed one-line tuples: composition, inverse, cycle type, conjugacy class sizes |
|
|
35
|
+
| [`character`](src/schur_weyl/character.py) | Irreducible characters $\chi^\lambda(\mu)$ of $S_n$ via the Murnaghan–Nakayama rule; full character tables |
|
|
36
|
+
| [`symmetric_functions`](src/schur_weyl/symmetric_functions.py) | Schur polynomials (Jacobi–Trudi) and power-sum symmetric functions |
|
|
37
|
+
| [`isotypic`](src/schur_weyl/isotypic.py) | Isotypic projectors $P_\lambda$ acting on $(\mathbb{C}^d)^{\otimes n}$, built from class sums of the permutation action |
|
|
38
|
+
| [`sw_measure`](src/schur_weyl/sw_measure.py) | The Schur–Weyl measure $\Pr[\lambda] = f^\lambda\, s_\lambda(\mathrm{spec}\,\rho)$ for i.i.d. copies of a state $\rho$ |
|
|
39
|
+
| [`young_orthonormal`](src/schur_weyl/young_orthonormal.py) | Young's orthogonal form: explicit irrep matrices $\rho^\lambda(\sigma)$ indexed by standard tableaux, and the Jucys–Murphy elements |
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from schur_weyl import (
|
|
45
|
+
partitions, dim_specht, dim_weyl, kostka,
|
|
46
|
+
schur_polynomial, isotypic_proj,
|
|
47
|
+
)
|
|
48
|
+
from schur_weyl.character import character, character_table
|
|
49
|
+
from schur_weyl.sw_measure import schur_weyl_measure
|
|
50
|
+
|
|
51
|
+
# dimension formulas
|
|
52
|
+
dim_specht((2, 1)) # -> 2, the standard rep of S_3
|
|
53
|
+
dim_weyl((2, 1), d=3) # -> 8
|
|
54
|
+
|
|
55
|
+
# characters via Murnaghan-Nakayama
|
|
56
|
+
character((2, 1), (3,)) # -> -1
|
|
57
|
+
|
|
58
|
+
# the Schur-Weyl measure for n i.i.d. copies of a state with given spectrum
|
|
59
|
+
schur_weyl_measure(spectrum=[0.7, 0.3], k=4)
|
|
60
|
+
# -> {(4,): 0.2401, (3, 1): 0.4116, (2, 2): 0.1323, (2, 1, 1): 0.0189, ...}
|
|
61
|
+
|
|
62
|
+
# the isotypic projector on (C^d)^{\otimes n}
|
|
63
|
+
P = isotypic_proj((2, 1), d=2) # np.ndarray, P @ P == P
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Testing
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pytest
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Tests live in [`tests/`](tests) and mirror the module layout; most assert the closed-form identities from the roadmap (e.g. $\sum_\lambda (f^\lambda)^2 = n!$, character-table orthogonality, $P_\lambda^2 = P_\lambda$, $\operatorname{tr}\rho^\lambda(X_k)$ diagonal with content eigenvalues) rather than fixed expected outputs.
|
|
73
|
+
|
|
74
|
+
## Status
|
|
75
|
+
|
|
76
|
+
Implemented through Young's orthogonal form and Jucys–Murphy elements (roadmap phases 0–5, 7–9). Not yet implemented: the generic tensor-space permutation action as a standalone module (phase 6, currently inlined in `isotypic`), and the explicit Schur transform (phase 10). See [`TODO.md`](TODO.md) for near-term items.
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT — see [LICENSE](LICENSE).
|
schur_weyl-0.1.0/TODO.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "schur-weyl"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Tools from Schur-Weyl duality"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "Anton Van Cleemput", email = "anton@vancleem.com" }]
|
|
13
|
+
dependencies = ["numpy>=1.24"]
|
|
14
|
+
|
|
15
|
+
[project.optional-dependencies]
|
|
16
|
+
dev = ["pytest", "ruff"]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/AVlyx/schur-weyl"
|
|
20
|
+
|
|
21
|
+
[tool.hatch.build.targets.wheel]
|
|
22
|
+
packages = ["src/schur_weyl"]
|
|
23
|
+
|
|
24
|
+
[tool.pytest.ini_options]
|
|
25
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
from .young_diagrams import partitions, partition_conjugate, hook_lenght, cells, majorizes, addable_corners, removable_corners, is_in_partition
|
|
2
|
+
from .dimensions import dim_specht, dim_weyl
|
|
3
|
+
from .tableaux import standard_young_tableaux, semi_standard_young_tableau_by_content, semi_standard_young_tableau, kostka, reverse_reading_word
|
|
4
|
+
from .symmetric_functions import schur_polynomial, power_sum
|
|
5
|
+
from .isotypic import isotypic_proj
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Characters of the symmetric group via the Murnaghan-Nakayama rule."""
|
|
2
|
+
|
|
3
|
+
# Made by Claude
|
|
4
|
+
|
|
5
|
+
from functools import lru_cache
|
|
6
|
+
from .young_diagrams import partitions
|
|
7
|
+
|
|
8
|
+
# ------------------------------------------------------------- border strips
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def border_strips(lam: tuple[int, ...], k: int):
|
|
12
|
+
"""Yield (new_shape, height) for every border strip of size k removable
|
|
13
|
+
from lam.
|
|
14
|
+
|
|
15
|
+
Uses beta numbers (first-column hook lengths). With L = len(lam), set
|
|
16
|
+
beta_i = lam_i + (L - 1 - i),
|
|
17
|
+
a strictly decreasing sequence of L distinct non-negative integers.
|
|
18
|
+
Removing a border strip of size k is exactly: pick i with
|
|
19
|
+
beta_i - k >= 0 and beta_i - k not already a beta value, then replace
|
|
20
|
+
beta_i by beta_i - k. The height of the strip is the number of beta
|
|
21
|
+
values jumped over.
|
|
22
|
+
"""
|
|
23
|
+
L = len(lam)
|
|
24
|
+
if L == 0:
|
|
25
|
+
return
|
|
26
|
+
beta = [lam[i] + (L - 1 - i) for i in range(L)]
|
|
27
|
+
bset = set(beta)
|
|
28
|
+
for i in range(L):
|
|
29
|
+
target = beta[i] - k
|
|
30
|
+
if target < 0 or target in bset:
|
|
31
|
+
continue
|
|
32
|
+
height = sum(1 for b in beta if target < b < beta[i])
|
|
33
|
+
new_beta = sorted(beta[:i] + [target] + beta[i + 1 :], reverse=True)
|
|
34
|
+
new_lam = [new_beta[j] - (L - 1 - j) for j in range(L)]
|
|
35
|
+
while new_lam and new_lam[-1] == 0:
|
|
36
|
+
new_lam.pop()
|
|
37
|
+
yield tuple(new_lam), height
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# ------------------------------------------------------- Murnaghan-Nakayama
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@lru_cache(maxsize=None)
|
|
44
|
+
def _character(lam: tuple[int, ...], mu: tuple[int, ...]) -> int:
|
|
45
|
+
if not mu:
|
|
46
|
+
return 1 if not lam else 0
|
|
47
|
+
k = mu[0]
|
|
48
|
+
rest = mu[1:]
|
|
49
|
+
total = 0
|
|
50
|
+
for new_lam, height in border_strips(lam, k):
|
|
51
|
+
total += (-1) ** height * _character(new_lam, rest)
|
|
52
|
+
return total
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def character(lam: tuple[int, ...], cycle_type: tuple[int, ...]) -> int:
|
|
56
|
+
"""chi^lam(cycle_type): the irreducible character of S_n indexed by the partition
|
|
57
|
+
lam, evaluated on the conjugacy class of cycle type cycle_type.
|
|
58
|
+
|
|
59
|
+
Examples:
|
|
60
|
+
>>> character((3,), (1, 1, 1)) # trivial rep
|
|
61
|
+
1
|
|
62
|
+
>>> character((1, 1, 1), (2, 1)) # sign rep at a transposition
|
|
63
|
+
-1
|
|
64
|
+
>>> character((2, 1), (1, 1, 1)) # dimension of the standard rep
|
|
65
|
+
2
|
|
66
|
+
>>> character((2, 1), (3,))
|
|
67
|
+
-1
|
|
68
|
+
>>> character((2, 1), (2, 1))
|
|
69
|
+
0
|
|
70
|
+
"""
|
|
71
|
+
cycle_type = tuple(sorted((x for x in cycle_type if x > 0), reverse=True))
|
|
72
|
+
if sum(lam) != sum(cycle_type):
|
|
73
|
+
raise ValueError(f"size mismatch: |{lam}| != |{cycle_type}|")
|
|
74
|
+
return _character(lam, cycle_type)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def character_table(n: int):
|
|
78
|
+
"""(rows, cols, table) with rows/cols the partitions of n in the order
|
|
79
|
+
produced by partitions(n), and table[a][b] = chi^{rows[a]}(cols[b])."""
|
|
80
|
+
ps = list(partitions(n))
|
|
81
|
+
table = [[character(lam, mu) for mu in ps] for lam in ps]
|
|
82
|
+
return ps, ps, table
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from math import factorial
|
|
2
|
+
from .young_diagrams import cells, hook_lenght
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def dim_specht(lam: tuple[int, ...]) -> int:
|
|
6
|
+
"""The dimension of the Specht module S^lam.
|
|
7
|
+
The number of SYT of shape lam.
|
|
8
|
+
f^lam = n! / prod(hooks).
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
lam (tuple[int, ...]): The partition
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
int: $f^\\lambda$
|
|
15
|
+
|
|
16
|
+
Examples:
|
|
17
|
+
>>> dim_specht((2, 1))
|
|
18
|
+
2
|
|
19
|
+
>>> dim_specht((3, 2, 1))
|
|
20
|
+
16
|
|
21
|
+
"""
|
|
22
|
+
n = sum(lam)
|
|
23
|
+
hooks = 1
|
|
24
|
+
for i, j in cells(lam):
|
|
25
|
+
hooks *= hook_lenght(lam, i, j)
|
|
26
|
+
return factorial(n) // hooks
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def dim_weyl(lam: tuple[int, ...], d: int) -> int:
|
|
30
|
+
"""The dimension of the Weyl module V_lam for GL_d.
|
|
31
|
+
The number of SSYT with entries from 1 to d
|
|
32
|
+
|
|
33
|
+
Returns 0 if lam has more than d rows (a cell then has d + content = 0).
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
lam (tuple[int, ...]): The partition
|
|
37
|
+
d (int): The alphabet size
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
int: $dim V_lam^d$
|
|
41
|
+
|
|
42
|
+
Examples:
|
|
43
|
+
>>> dim_weyl((2, 1), 2)
|
|
44
|
+
2
|
|
45
|
+
>>> dim_weyl((2, 1), 3)
|
|
46
|
+
8
|
|
47
|
+
>>> dim_weyl((2,), 3)
|
|
48
|
+
6
|
|
49
|
+
"""
|
|
50
|
+
numerator = 1
|
|
51
|
+
denominator = 1
|
|
52
|
+
for i, j in cells(lam):
|
|
53
|
+
numerator *= d + j - i
|
|
54
|
+
denominator *= hook_lenght(lam, i, j)
|
|
55
|
+
return numerator // denominator
|