ecological_sign_rules 0.5.3__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.
Files changed (42) hide show
  1. ecological_sign_rules-0.5.3/CITATION.cff +44 -0
  2. ecological_sign_rules-0.5.3/LICENSE +21 -0
  3. ecological_sign_rules-0.5.3/MANIFEST.in +7 -0
  4. ecological_sign_rules-0.5.3/PKG-INFO +248 -0
  5. ecological_sign_rules-0.5.3/README.md +208 -0
  6. ecological_sign_rules-0.5.3/ecological_sign_rules.egg-info/PKG-INFO +248 -0
  7. ecological_sign_rules-0.5.3/ecological_sign_rules.egg-info/SOURCES.txt +40 -0
  8. ecological_sign_rules-0.5.3/ecological_sign_rules.egg-info/dependency_links.txt +1 -0
  9. ecological_sign_rules-0.5.3/ecological_sign_rules.egg-info/entry_points.txt +2 -0
  10. ecological_sign_rules-0.5.3/ecological_sign_rules.egg-info/requires.txt +14 -0
  11. ecological_sign_rules-0.5.3/ecological_sign_rules.egg-info/top_level.txt +1 -0
  12. ecological_sign_rules-0.5.3/pyproject.toml +67 -0
  13. ecological_sign_rules-0.5.3/setup.cfg +4 -0
  14. ecological_sign_rules-0.5.3/signrules/__init__.py +51 -0
  15. ecological_sign_rules-0.5.3/signrules/__main__.py +6 -0
  16. ecological_sign_rules-0.5.3/signrules/certificate.py +621 -0
  17. ecological_sign_rules-0.5.3/signrules/chirotope.py +127 -0
  18. ecological_sign_rules-0.5.3/signrules/cli.py +586 -0
  19. ecological_sign_rules-0.5.3/signrules/data/__init__.py +56 -0
  20. ecological_sign_rules-0.5.3/signrules/data/n4/census.jsonl +3044 -0
  21. ecological_sign_rules-0.5.3/signrules/data/n5/extension_screen.jsonl +83 -0
  22. ecological_sign_rules-0.5.3/signrules/data/n5/possible.jsonl +59 -0
  23. ecological_sign_rules-0.5.3/signrules/data/n6/extension_screen.jsonl +143 -0
  24. ecological_sign_rules-0.5.3/signrules/data/n6/possible.jsonl +102 -0
  25. ecological_sign_rules-0.5.3/signrules/editor.py +766 -0
  26. ecological_sign_rules-0.5.3/signrules/engine.py +324 -0
  27. ecological_sign_rules-0.5.3/signrules/gvrender.py +396 -0
  28. ecological_sign_rules-0.5.3/signrules/labels.py +294 -0
  29. ecological_sign_rules-0.5.3/signrules/livesearch.py +392 -0
  30. ecological_sign_rules-0.5.3/signrules/network.py +206 -0
  31. ecological_sign_rules-0.5.3/signrules/patterns.py +405 -0
  32. ecological_sign_rules-0.5.3/signrules/plucker_index.py +169 -0
  33. ecological_sign_rules-0.5.3/signrules/possible.py +95 -0
  34. ecological_sign_rules-0.5.3/signrules/replay.py +702 -0
  35. ecological_sign_rules-0.5.3/signrules/report.py +156 -0
  36. ecological_sign_rules-0.5.3/signrules/rules.py +919 -0
  37. ecological_sign_rules-0.5.3/signrules/screen.py +177 -0
  38. ecological_sign_rules-0.5.3/signrules/search.py +469 -0
  39. ecological_sign_rules-0.5.3/signrules/style.py +83 -0
  40. ecological_sign_rules-0.5.3/signrules/symmetry.py +98 -0
  41. ecological_sign_rules-0.5.3/signrules/treeplot.py +267 -0
  42. ecological_sign_rules-0.5.3/signrules/treeview.py +551 -0
@@ -0,0 +1,44 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it together with the two papers below (the algorithm and the arguments it encodes)."
3
+ title: "signrules: sign completion on the ecological Grassmannian"
4
+ type: software
5
+ version: 0.5.3
6
+ date-released: 2026-11-24
7
+ authors:
8
+ - family-names: Scholten
9
+ given-names: Georgy
10
+ email: scholtengeorgy@gmail.com
11
+ repository-code: "https://github.com/gescholt/signrules"
12
+ doi: 10.5281/zenodo.24214426
13
+ license: MIT
14
+ references:
15
+ - type: article
16
+ title: "Strata of ecological coexistence via Grassmannians"
17
+ authors:
18
+ - family-names: Çelik
19
+ given-names: Türkü Özlüm
20
+ - family-names: Haas
21
+ given-names: Pierre A.
22
+ - family-names: Scholten
23
+ given-names: Georgy
24
+ - family-names: Wang
25
+ given-names: Kexin
26
+ - family-names: Zucal
27
+ given-names: Giulio
28
+ journal: "Annals of Combinatorics"
29
+ year: 2026
30
+ doi: "10.1007/s00026-026-00837-7"
31
+ url: "https://arxiv.org/abs/2509.00165"
32
+ - type: article
33
+ title: "Stable coexistence in ecologies and games"
34
+ authors:
35
+ - family-names: Çelik
36
+ given-names: Türkü Özlüm
37
+ - family-names: Isoldi
38
+ given-names: Vincenzo Antonio
39
+ - family-names: Portakal
40
+ given-names: Irem
41
+ - family-names: Zucal
42
+ given-names: Giulio
43
+ year: 2026
44
+ url: "https://arxiv.org/abs/2609.09286"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Georgy Scholten
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,7 @@
1
+ # the source archive on PyPI: the package, its licence and citation; tests, scripts, docs and the
2
+ # experiment records are in the repository and its Zenodo archive
3
+ include LICENSE CITATION.cff README.md
4
+ prune tests
5
+ prune scripts
6
+ prune docs
7
+ prune data
@@ -0,0 +1,248 @@
1
+ Metadata-Version: 2.4
2
+ Name: ecological_sign_rules
3
+ Version: 0.5.3
4
+ Summary: Prove Lotka-Volterra sign patterns impossible, with machine certificates and an independent checker
5
+ Author-email: Georgy Scholten <scholtengeorgy@gmail.com>
6
+ Maintainer-email: Georgy Scholten <scholtengeorgy@gmail.com>
7
+ License-Expression: MIT
8
+ Project-URL: Repository, https://github.com/gescholt/signrules
9
+ Project-URL: Documentation, https://github.com/gescholt/signrules/blob/main/docs/SIGNRULES.md
10
+ Project-URL: Issues, https://github.com/gescholt/signrules/issues
11
+ Project-URL: Changelog, https://github.com/gescholt/signrules/blob/main/CHANGELOG.md
12
+ Project-URL: DOI, https://doi.org/10.5281/zenodo.24214426
13
+ Keywords: Lotka-Volterra,sign pattern,qualitative stability,mathematical ecology,oriented matroid,chirotope,Grassmannian,computer-assisted proof,certificate
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
24
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: numpy>=1.24
29
+ Requires-Dist: matplotlib>=3.7
30
+ Requires-Dist: networkx>=3.0
31
+ Requires-Dist: rich>=13.0
32
+ Requires-Dist: textual>=1.0
33
+ Provides-Extra: live
34
+ Requires-Dist: questionary>=2.0; extra == "live"
35
+ Provides-Extra: html
36
+ Requires-Dist: plotly>=5.0; extra == "html"
37
+ Provides-Extra: all
38
+ Requires-Dist: ecological_sign_rules[html,live]; extra == "all"
39
+ Dynamic: license-file
40
+
41
+ # signrules
42
+
43
+ [![tests](https://github.com/gescholt/signrules/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gescholt/signrules/actions/workflows/ci.yml)
44
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24214426.svg)](https://doi.org/10.5281/zenodo.24214426)
45
+
46
+ `signrules` proves Lotka–Volterra sign patterns **impossible**. Every proof comes with a machine certificate,
47
+ and an independent checker replays it.
48
+
49
+ A Lotka–Volterra community `ẋ = diag(x)(a − Bx)` is described qualitatively by its *sign pattern*: the signs
50
+ of the growth rates `a` and of the interaction matrix `B`. The pattern is *possible* if some magnitudes with
51
+ these signs have a positive equilibrium that is locally asymptotically stable, and *impossible* otherwise.
52
+
53
+ ## Install
54
+
55
+ ```bash
56
+ uv tool install ecological_sign_rules # the signrules command; Python 3.10 or later
57
+ ```
58
+
59
+ The package is `ecological_sign_rules` on [PyPI](https://pypi.org/project/ecological_sign_rules/) and imports
60
+ as `signrules`. Without installing: `uvx --from ecological_sign_rules signrules`. In a project:
61
+ `uv add ecological_sign_rules`. [uv](https://docs.astral.sh/uv/) itself installs with
62
+ `curl -LsSf https://astral.sh/uv/install.sh | sh` or `brew install uv`.
63
+
64
+ ## First run
65
+
66
+ ```bash
67
+ signrules
68
+ ```
69
+
70
+ <img src="https://raw.githubusercontent.com/gescholt/signrules/main/docs/figures/app_A-e.png" width="760" alt="the signrules app: the sign matrix of the pattern A-e, its interaction network, and the verdict IMPOSSIBLE in the status line">
71
+
72
+ This opens an app in the terminal:
73
+
74
+ 1. **Pick a pattern** in the library (↑ ↓, enter), or start from an empty matrix.
75
+ 2. **Edit it**: the arrow keys move over the sign matrix `[diag(a) | B]`, space flips a sign, `<` and `>`
76
+ remove or add a species.
77
+ 3. **Press `r`** to search. A dashboard shows the search live; the verdict comes at the end, with the
78
+ certificate under it for an impossible pattern.
79
+
80
+ `?` lists every key; Esc goes back, `q` quits.
81
+
82
+ The same from the command line:
83
+
84
+ ```bash
85
+ signrules run --preset A-e # a four-species pattern proved impossible: verdict and certificate
86
+ signrules run --a +--- --B "+-++/-+++/+++-/++-+" # your own pattern: the signs of a, then the rows of B
87
+ signrules verify # check the classification on four, five and six species
88
+ ```
89
+
90
+ ## Verdicts and terms
91
+
92
+ A search ends in one of three verdicts:
93
+
94
+ * **Impossible**: no magnitudes with these signs have a stable positive equilibrium. The certificate printed
95
+ with the verdict is the proof, and the independent checker has replayed it.
96
+ * **Not decided by the rules**: some sign tables survive every rule. The pattern may be possible; the rules
97
+ cannot tell.
98
+ * **Undecided**: the search stopped at its node limit (20,000 by default; `--max-nodes 0` lifts it).
99
+
100
+ The words used below:
101
+
102
+ * **sign table**: a sign for every minor of `B` (equivalently, every Plücker coordinate of `[diag(a) | B]`).
103
+ * **killed**: every sign table is ruled out, so the pattern is impossible. **Killed at the root**: ruled out
104
+ by propagation alone, before any branching; the certificate is then a short list of steps.
105
+ * **completion**: a full sign table that no rule rules out.
106
+ * **certificate**: the steps from the pattern to a contradiction, each naming the identity or inequality
107
+ that forces it.
108
+ * **trivial**: some obligate species has only harmful interactions, so no positive equilibrium exists at all.
109
+ * **deletion lemma**: deleting a species from an impossible pattern leaves an impossible or trivial one. So
110
+ every impossible pattern on n species extends one on n − 1 species, and the *extension screen* lists the
111
+ candidates.
112
+ * **minimal impossible**: impossible, with every one-species deletion impossible or trivial.
113
+
114
+ ## Commands
115
+
116
+ | command | what it does |
117
+ |---|---|
118
+ | `run` | complete one pattern with a live dashboard; prints the verdict and, for a kill, the certificate |
119
+ | `tree` | complete one pattern and write an interactive HTML viewer of the search tree |
120
+ | `replay` | kill one pattern at the root and check its certificate with the independent replayer |
121
+ | `edit` | the full-screen app (also plain `signrules`): library, matrix editor, network, rules, search, verdict |
122
+ | `presets` | list the named patterns (the eleven n = 4 patterns, the n = 5, 6 presets) with short ids |
123
+ | `screen` | list the candidates for impossible n-species patterns (deletion lemma) and run the rules on each |
124
+ | `verify` | check the classification on four, five and six species: every pattern killed or certified possible |
125
+
126
+ `signrules <command> --help` gives the options and examples. Signs are written `+-...`, `+,-,...` or
127
+ `1,-1,...`; the rows of `B` are separated by `/`, and its diagonal is `+`. A preset is named by its short id
128
+ (`signrules presets`) or any unambiguous prefix of its name. `--rules` takes `all` (the default), `annals`
129
+ (the rules of the first paper below) or a list such as `R1,R2,R7`. `--plain`, or output to a file, prints the
130
+ verdict only. `--cert DIR` draws the certificate (needs Graphviz). `python -m signrules` is the same command.
131
+
132
+ ## What it proves
133
+
134
+ * **Four species**: each of the 3044 patterns up to relabelling is decided. 715 are killed at the root (11
135
+ of them non-trivial: the eleven candidates of Meng et al.); each of the other 2329 has a *certificate of
136
+ possibility*, a rational matrix whose equilibrium is checked stable in exact arithmetic.
137
+ * **Five and six species**: the deletion lemma, applied to the impossible patterns on one species fewer,
138
+ leaves 83 candidates at n = 5 and 143 at n = 6, and every one is decided: 24 and 41 are killed at the root,
139
+ the other 59 and 102 have certificates of possibility. So exactly 24 five-species and 41 six-species
140
+ patterns are impossible, the minimal impossible patterns.
141
+
142
+ `signrules verify` checks all of this from the data shipped with the package, in about 15 seconds: it
143
+ rebuilds the candidate lists, redoes and replays every kill, and checks every certificate.
144
+ * **Any number of species**: two benefactor-permutation families are impossible (`scripts/families.py`).
145
+
146
+ ## Use from Python
147
+
148
+ ```python
149
+ from signrules import Ecology, complete
150
+
151
+ eco = Ecology.parse("+---", "+-++/-+++/+++-/++-+") # the strings of the command line; lists of ±1 work too
152
+ print(eco) # the sign matrix [diag(a) | B]
153
+ result = complete(eco)
154
+ print(result.verdict, result.summary()) # impossible impossible at the root (R8 real eigenvalue ...)
155
+ ```
156
+
157
+ * For a kill, `replay_kill(eco, result)` re-derives every step with the independent checker, and
158
+ `write_certificate(eco, result, "cert")` draws the certificate (needs Graphviz).
159
+ * For an open pattern, `result.completions` holds the surviving sign tables, and `eco.minor_signs(table)`
160
+ names one as `{minor: sign}`.
161
+ * `signrules.patterns` has the named patterns: `ELEVEN` (four species), `PATTERNS` (five and six),
162
+ `parity_pattern`, `random_pattern`.
163
+ * `signrules.data` has the classification: `census(4)`, and `screen_records(n)`, `root_kills(n)` and
164
+ `possible(n)` for n = 5, 6. `signrules.possible.check_witness` checks a certificate of possibility.
165
+
166
+ The docstring of `complete` lists its options.
167
+
168
+ ## How it works
169
+
170
+ The matrix `[diag(a) | B]` is a point of the Grassmannian `Gr(n, 2n)`, and every Plücker coordinate is a minor
171
+ of `B` up to a known sign. Feasibility and stability become constraints on one set of sign variables. The
172
+ search propagates the 3-term Grassmann–Plücker relations and the rules below to a fixed point, then branches
173
+ on an open sign. A contradiction kills the branch, and the steps that led to it form the certificate. The
174
+ tests check that the rules never reject a genuine feasible, stable system.
175
+
176
+ <img src="https://raw.githubusercontent.com/gescholt/signrules/main/docs/figures/algorithm.png" width="520" alt="one run of the search: initial signs, propagation to a fixed point, then a contradiction, a completion or a branch">
177
+
178
+ | rule | what it says | source |
179
+ |---|---|---|
180
+ | `R1` | stability: `det B > 0` and positive coefficients of the characteristic polynomial | [1] |
181
+ | `R2n` | Cramer's rule on the full system | [1] |
182
+ | `R2` | Cramer's rule on every subsystem | [2] |
183
+ | `R3` | balanced patterns: the principal-minor signs of an M-matrix | [2], Theorems 3.1–3.2 |
184
+ | `R5` | Laplace expansion of every minor along a row or a column | [2] |
185
+ | `R7` | tope rule, the oriented-matroid Farkas lemma; it contains `R2` | new |
186
+ | `R8` | a real positive eigenvalue for benefactor-permutation patterns | new |
187
+
188
+ The two new rules will appear in a paper in preparation. Two rules from [2], `R4` and `R6`, are subsumed by
189
+ these and not run. [docs/SIGNRULES.md](https://github.com/gescholt/signrules/blob/main/docs/SIGNRULES.md)
190
+ gives the full account: the dictionary between minors and Plücker coordinates, each rule with its proof,
191
+ certificates and replay, the search, and the screens.
192
+
193
+ ## Conventions
194
+
195
+ Species are numbered from 0 here and from 1 in the papers. `b_ii > 0`. `B[i, j] < 0`: species `j` benefits
196
+ species `i` (food, a mutualist); `B[i, j] > 0`: `i` loses to `j` (competition, predation). `a_i > 0`: species
197
+ `i` grows alone (free); `a_i < 0`: it does not (obligate). In `[diag(a) | B]` the columns `0..n-1` carry
198
+ `diag(a)` and `n..2n-1` carry `B`, so `p_0367` is the Plücker coordinate on columns 0, 3, 6, 7. In the
199
+ network drawings, a dashed arrow i → j means that i benefits from j, a red line joins two species that each
200
+ lose to the other, and free species are pink, obligate ones blue.
201
+
202
+ ## Reproducing the papers
203
+
204
+ The package does not need the `scripts/` folder; the scripts reproduce the numbers of the papers from a clone
205
+ of the repository. Their records are in `data/`.
206
+
207
+ | result | command |
208
+ |---|---|
209
+ | the eleven four-species kills; with `--rules R1,R2n`, the completion counts of [1] (S-d, S-e, A-a, A-c: 64, 64, 1996, 1528) | `uv run python scripts/impossible_eleven.py` |
210
+ | the extension screens: 83 candidates at n = 5, 143 at n = 6 | `signrules screen 5 --out n5.jsonl`, `signrules screen 6 --out n6.jsonl` |
211
+ | every root kill replays, and flipping any single step makes the replay fail | `uv run python scripts/replay_certificates.py 6 --tamper` (and 4, 5) |
212
+ | the exhaustive five-species screen of all 248,436 non-trivial patterns up to relabelling: 21 kills under R1–R6, three more by R8 | `uv run python scripts/screen_all.py --rules R1,R2,R3,R4,R5,R6` (100 CPU-minutes) |
213
+ | the benefactor-permutation families | `uv run python scripts/families.py` |
214
+ | what each rule adds on the minimal impossible patterns | `uv run python scripts/rule_ladder.py 4 5 6 --out ladder.jsonl` |
215
+ | R4 and R6 are subsumed by the other rules | `uv run python scripts/rule_ablation.py 3 4 --census`, `uv run python scripts/r4_subsumption.py 3 4 --rules R1,R7 --others` |
216
+
217
+ ## Development
218
+
219
+ ```bash
220
+ git clone https://github.com/gescholt/signrules.git && cd signrules
221
+ uv sync --all-extras # the environment from uv.lock, with the extras and pytest
222
+ uv run pytest -q # about a minute
223
+ ```
224
+
225
+ The extras are `live` (questionary: menus for `signrules run` without a pattern) and `html` (plotly, for
226
+ `save_search_tree_html`). Graphviz (`apt install graphviz`, `brew install graphviz`) is needed only to draw
227
+ certificates and trees.
228
+
229
+ ## Papers
230
+
231
+ The package extends the sign-completion algorithm of [1] with the arguments of [2], read as propagation rules:
232
+
233
+ * [1] T. Ö. Çelik, P. A. Haas, G. Scholten, K. Wang, G. Zucal, *Strata of ecological coexistence via
234
+ Grassmannians*, Ann. Comb. (2026), [doi:10.1007/s00026-026-00837-7](https://doi.org/10.1007/s00026-026-00837-7),
235
+ [arXiv:2509.00165](https://arxiv.org/abs/2509.00165).
236
+ * [2] T. Ö. Çelik, V. A. Isoldi, I. Portakal, G. Zucal, *Stable coexistence in ecologies and games* (2026),
237
+ [arXiv:2609.09286](https://arxiv.org/abs/2609.09286).
238
+
239
+ The four-species patterns come from Y. Meng, S. Horvát, C. D. Modes, P. A. Haas, *Impossible ecologies:
240
+ interaction networks and stability of coexistence in ecological communities*, Cell Systems 16 (2025) 101297,
241
+ [doi:10.1016/j.cels.2025.101297](https://doi.org/10.1016/j.cels.2025.101297).
242
+
243
+ ## Citation and licence
244
+
245
+ Every release is archived on Zenodo: [doi:10.5281/zenodo.24214426](https://doi.org/10.5281/zenodo.24214426)
246
+ (all versions). To cite, see [CITATION.cff](https://github.com/gescholt/signrules/blob/main/CITATION.cff).
247
+ Changes are listed in [CHANGELOG.md](https://github.com/gescholt/signrules/blob/main/CHANGELOG.md). MIT
248
+ licence. Questions and bug reports: [open an issue](https://github.com/gescholt/signrules/issues).
@@ -0,0 +1,208 @@
1
+ # signrules
2
+
3
+ [![tests](https://github.com/gescholt/signrules/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gescholt/signrules/actions/workflows/ci.yml)
4
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24214426.svg)](https://doi.org/10.5281/zenodo.24214426)
5
+
6
+ `signrules` proves Lotka–Volterra sign patterns **impossible**. Every proof comes with a machine certificate,
7
+ and an independent checker replays it.
8
+
9
+ A Lotka–Volterra community `ẋ = diag(x)(a − Bx)` is described qualitatively by its *sign pattern*: the signs
10
+ of the growth rates `a` and of the interaction matrix `B`. The pattern is *possible* if some magnitudes with
11
+ these signs have a positive equilibrium that is locally asymptotically stable, and *impossible* otherwise.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ uv tool install ecological_sign_rules # the signrules command; Python 3.10 or later
17
+ ```
18
+
19
+ The package is `ecological_sign_rules` on [PyPI](https://pypi.org/project/ecological_sign_rules/) and imports
20
+ as `signrules`. Without installing: `uvx --from ecological_sign_rules signrules`. In a project:
21
+ `uv add ecological_sign_rules`. [uv](https://docs.astral.sh/uv/) itself installs with
22
+ `curl -LsSf https://astral.sh/uv/install.sh | sh` or `brew install uv`.
23
+
24
+ ## First run
25
+
26
+ ```bash
27
+ signrules
28
+ ```
29
+
30
+ <img src="https://raw.githubusercontent.com/gescholt/signrules/main/docs/figures/app_A-e.png" width="760" alt="the signrules app: the sign matrix of the pattern A-e, its interaction network, and the verdict IMPOSSIBLE in the status line">
31
+
32
+ This opens an app in the terminal:
33
+
34
+ 1. **Pick a pattern** in the library (↑ ↓, enter), or start from an empty matrix.
35
+ 2. **Edit it**: the arrow keys move over the sign matrix `[diag(a) | B]`, space flips a sign, `<` and `>`
36
+ remove or add a species.
37
+ 3. **Press `r`** to search. A dashboard shows the search live; the verdict comes at the end, with the
38
+ certificate under it for an impossible pattern.
39
+
40
+ `?` lists every key; Esc goes back, `q` quits.
41
+
42
+ The same from the command line:
43
+
44
+ ```bash
45
+ signrules run --preset A-e # a four-species pattern proved impossible: verdict and certificate
46
+ signrules run --a +--- --B "+-++/-+++/+++-/++-+" # your own pattern: the signs of a, then the rows of B
47
+ signrules verify # check the classification on four, five and six species
48
+ ```
49
+
50
+ ## Verdicts and terms
51
+
52
+ A search ends in one of three verdicts:
53
+
54
+ * **Impossible**: no magnitudes with these signs have a stable positive equilibrium. The certificate printed
55
+ with the verdict is the proof, and the independent checker has replayed it.
56
+ * **Not decided by the rules**: some sign tables survive every rule. The pattern may be possible; the rules
57
+ cannot tell.
58
+ * **Undecided**: the search stopped at its node limit (20,000 by default; `--max-nodes 0` lifts it).
59
+
60
+ The words used below:
61
+
62
+ * **sign table**: a sign for every minor of `B` (equivalently, every Plücker coordinate of `[diag(a) | B]`).
63
+ * **killed**: every sign table is ruled out, so the pattern is impossible. **Killed at the root**: ruled out
64
+ by propagation alone, before any branching; the certificate is then a short list of steps.
65
+ * **completion**: a full sign table that no rule rules out.
66
+ * **certificate**: the steps from the pattern to a contradiction, each naming the identity or inequality
67
+ that forces it.
68
+ * **trivial**: some obligate species has only harmful interactions, so no positive equilibrium exists at all.
69
+ * **deletion lemma**: deleting a species from an impossible pattern leaves an impossible or trivial one. So
70
+ every impossible pattern on n species extends one on n − 1 species, and the *extension screen* lists the
71
+ candidates.
72
+ * **minimal impossible**: impossible, with every one-species deletion impossible or trivial.
73
+
74
+ ## Commands
75
+
76
+ | command | what it does |
77
+ |---|---|
78
+ | `run` | complete one pattern with a live dashboard; prints the verdict and, for a kill, the certificate |
79
+ | `tree` | complete one pattern and write an interactive HTML viewer of the search tree |
80
+ | `replay` | kill one pattern at the root and check its certificate with the independent replayer |
81
+ | `edit` | the full-screen app (also plain `signrules`): library, matrix editor, network, rules, search, verdict |
82
+ | `presets` | list the named patterns (the eleven n = 4 patterns, the n = 5, 6 presets) with short ids |
83
+ | `screen` | list the candidates for impossible n-species patterns (deletion lemma) and run the rules on each |
84
+ | `verify` | check the classification on four, five and six species: every pattern killed or certified possible |
85
+
86
+ `signrules <command> --help` gives the options and examples. Signs are written `+-...`, `+,-,...` or
87
+ `1,-1,...`; the rows of `B` are separated by `/`, and its diagonal is `+`. A preset is named by its short id
88
+ (`signrules presets`) or any unambiguous prefix of its name. `--rules` takes `all` (the default), `annals`
89
+ (the rules of the first paper below) or a list such as `R1,R2,R7`. `--plain`, or output to a file, prints the
90
+ verdict only. `--cert DIR` draws the certificate (needs Graphviz). `python -m signrules` is the same command.
91
+
92
+ ## What it proves
93
+
94
+ * **Four species**: each of the 3044 patterns up to relabelling is decided. 715 are killed at the root (11
95
+ of them non-trivial: the eleven candidates of Meng et al.); each of the other 2329 has a *certificate of
96
+ possibility*, a rational matrix whose equilibrium is checked stable in exact arithmetic.
97
+ * **Five and six species**: the deletion lemma, applied to the impossible patterns on one species fewer,
98
+ leaves 83 candidates at n = 5 and 143 at n = 6, and every one is decided: 24 and 41 are killed at the root,
99
+ the other 59 and 102 have certificates of possibility. So exactly 24 five-species and 41 six-species
100
+ patterns are impossible, the minimal impossible patterns.
101
+
102
+ `signrules verify` checks all of this from the data shipped with the package, in about 15 seconds: it
103
+ rebuilds the candidate lists, redoes and replays every kill, and checks every certificate.
104
+ * **Any number of species**: two benefactor-permutation families are impossible (`scripts/families.py`).
105
+
106
+ ## Use from Python
107
+
108
+ ```python
109
+ from signrules import Ecology, complete
110
+
111
+ eco = Ecology.parse("+---", "+-++/-+++/+++-/++-+") # the strings of the command line; lists of ±1 work too
112
+ print(eco) # the sign matrix [diag(a) | B]
113
+ result = complete(eco)
114
+ print(result.verdict, result.summary()) # impossible impossible at the root (R8 real eigenvalue ...)
115
+ ```
116
+
117
+ * For a kill, `replay_kill(eco, result)` re-derives every step with the independent checker, and
118
+ `write_certificate(eco, result, "cert")` draws the certificate (needs Graphviz).
119
+ * For an open pattern, `result.completions` holds the surviving sign tables, and `eco.minor_signs(table)`
120
+ names one as `{minor: sign}`.
121
+ * `signrules.patterns` has the named patterns: `ELEVEN` (four species), `PATTERNS` (five and six),
122
+ `parity_pattern`, `random_pattern`.
123
+ * `signrules.data` has the classification: `census(4)`, and `screen_records(n)`, `root_kills(n)` and
124
+ `possible(n)` for n = 5, 6. `signrules.possible.check_witness` checks a certificate of possibility.
125
+
126
+ The docstring of `complete` lists its options.
127
+
128
+ ## How it works
129
+
130
+ The matrix `[diag(a) | B]` is a point of the Grassmannian `Gr(n, 2n)`, and every Plücker coordinate is a minor
131
+ of `B` up to a known sign. Feasibility and stability become constraints on one set of sign variables. The
132
+ search propagates the 3-term Grassmann–Plücker relations and the rules below to a fixed point, then branches
133
+ on an open sign. A contradiction kills the branch, and the steps that led to it form the certificate. The
134
+ tests check that the rules never reject a genuine feasible, stable system.
135
+
136
+ <img src="https://raw.githubusercontent.com/gescholt/signrules/main/docs/figures/algorithm.png" width="520" alt="one run of the search: initial signs, propagation to a fixed point, then a contradiction, a completion or a branch">
137
+
138
+ | rule | what it says | source |
139
+ |---|---|---|
140
+ | `R1` | stability: `det B > 0` and positive coefficients of the characteristic polynomial | [1] |
141
+ | `R2n` | Cramer's rule on the full system | [1] |
142
+ | `R2` | Cramer's rule on every subsystem | [2] |
143
+ | `R3` | balanced patterns: the principal-minor signs of an M-matrix | [2], Theorems 3.1–3.2 |
144
+ | `R5` | Laplace expansion of every minor along a row or a column | [2] |
145
+ | `R7` | tope rule, the oriented-matroid Farkas lemma; it contains `R2` | new |
146
+ | `R8` | a real positive eigenvalue for benefactor-permutation patterns | new |
147
+
148
+ The two new rules will appear in a paper in preparation. Two rules from [2], `R4` and `R6`, are subsumed by
149
+ these and not run. [docs/SIGNRULES.md](https://github.com/gescholt/signrules/blob/main/docs/SIGNRULES.md)
150
+ gives the full account: the dictionary between minors and Plücker coordinates, each rule with its proof,
151
+ certificates and replay, the search, and the screens.
152
+
153
+ ## Conventions
154
+
155
+ Species are numbered from 0 here and from 1 in the papers. `b_ii > 0`. `B[i, j] < 0`: species `j` benefits
156
+ species `i` (food, a mutualist); `B[i, j] > 0`: `i` loses to `j` (competition, predation). `a_i > 0`: species
157
+ `i` grows alone (free); `a_i < 0`: it does not (obligate). In `[diag(a) | B]` the columns `0..n-1` carry
158
+ `diag(a)` and `n..2n-1` carry `B`, so `p_0367` is the Plücker coordinate on columns 0, 3, 6, 7. In the
159
+ network drawings, a dashed arrow i → j means that i benefits from j, a red line joins two species that each
160
+ lose to the other, and free species are pink, obligate ones blue.
161
+
162
+ ## Reproducing the papers
163
+
164
+ The package does not need the `scripts/` folder; the scripts reproduce the numbers of the papers from a clone
165
+ of the repository. Their records are in `data/`.
166
+
167
+ | result | command |
168
+ |---|---|
169
+ | the eleven four-species kills; with `--rules R1,R2n`, the completion counts of [1] (S-d, S-e, A-a, A-c: 64, 64, 1996, 1528) | `uv run python scripts/impossible_eleven.py` |
170
+ | the extension screens: 83 candidates at n = 5, 143 at n = 6 | `signrules screen 5 --out n5.jsonl`, `signrules screen 6 --out n6.jsonl` |
171
+ | every root kill replays, and flipping any single step makes the replay fail | `uv run python scripts/replay_certificates.py 6 --tamper` (and 4, 5) |
172
+ | the exhaustive five-species screen of all 248,436 non-trivial patterns up to relabelling: 21 kills under R1–R6, three more by R8 | `uv run python scripts/screen_all.py --rules R1,R2,R3,R4,R5,R6` (100 CPU-minutes) |
173
+ | the benefactor-permutation families | `uv run python scripts/families.py` |
174
+ | what each rule adds on the minimal impossible patterns | `uv run python scripts/rule_ladder.py 4 5 6 --out ladder.jsonl` |
175
+ | R4 and R6 are subsumed by the other rules | `uv run python scripts/rule_ablation.py 3 4 --census`, `uv run python scripts/r4_subsumption.py 3 4 --rules R1,R7 --others` |
176
+
177
+ ## Development
178
+
179
+ ```bash
180
+ git clone https://github.com/gescholt/signrules.git && cd signrules
181
+ uv sync --all-extras # the environment from uv.lock, with the extras and pytest
182
+ uv run pytest -q # about a minute
183
+ ```
184
+
185
+ The extras are `live` (questionary: menus for `signrules run` without a pattern) and `html` (plotly, for
186
+ `save_search_tree_html`). Graphviz (`apt install graphviz`, `brew install graphviz`) is needed only to draw
187
+ certificates and trees.
188
+
189
+ ## Papers
190
+
191
+ The package extends the sign-completion algorithm of [1] with the arguments of [2], read as propagation rules:
192
+
193
+ * [1] T. Ö. Çelik, P. A. Haas, G. Scholten, K. Wang, G. Zucal, *Strata of ecological coexistence via
194
+ Grassmannians*, Ann. Comb. (2026), [doi:10.1007/s00026-026-00837-7](https://doi.org/10.1007/s00026-026-00837-7),
195
+ [arXiv:2509.00165](https://arxiv.org/abs/2509.00165).
196
+ * [2] T. Ö. Çelik, V. A. Isoldi, I. Portakal, G. Zucal, *Stable coexistence in ecologies and games* (2026),
197
+ [arXiv:2609.09286](https://arxiv.org/abs/2609.09286).
198
+
199
+ The four-species patterns come from Y. Meng, S. Horvát, C. D. Modes, P. A. Haas, *Impossible ecologies:
200
+ interaction networks and stability of coexistence in ecological communities*, Cell Systems 16 (2025) 101297,
201
+ [doi:10.1016/j.cels.2025.101297](https://doi.org/10.1016/j.cels.2025.101297).
202
+
203
+ ## Citation and licence
204
+
205
+ Every release is archived on Zenodo: [doi:10.5281/zenodo.24214426](https://doi.org/10.5281/zenodo.24214426)
206
+ (all versions). To cite, see [CITATION.cff](https://github.com/gescholt/signrules/blob/main/CITATION.cff).
207
+ Changes are listed in [CHANGELOG.md](https://github.com/gescholt/signrules/blob/main/CHANGELOG.md). MIT
208
+ licence. Questions and bug reports: [open an issue](https://github.com/gescholt/signrules/issues).