holant-tools 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.
@@ -0,0 +1,28 @@
1
+ holant-tools
2
+
3
+ Copyright (c) 2026 Edward Chalk (sapientronic.ai)
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 use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ 1. The above copyright notice and this permission notice shall be included
12
+ in all copies or substantial portions of the Software.
13
+
14
+ 2. Attribution. Any publication, presentation, derivative work, or product
15
+ that uses or builds on this Software must include visible attribution to
16
+ Edward Chalk and sapientronic.ai. The phrase "Built with holant-tools by
17
+ Edward Chalk (sapientronic.ai)" or equivalent is acceptable.
18
+
19
+ 3. The Software is provided "AS IS", without warranty of any kind, express
20
+ or implied, including but not limited to the warranties of merchantability,
21
+ fitness for a particular purpose, and noninfringement. In no event shall
22
+ the authors or copyright holders be liable for any claim, damages, or
23
+ other liability, whether in an action of contract, tort, or otherwise,
24
+ arising from, out of, or in connection with the Software or the use or
25
+ other dealings in the Software.
26
+
27
+ This license is modeled on the MIT License with an explicit attribution
28
+ clause (clause 2).
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: holant-tools
3
+ Version: 0.1.0
4
+ Summary: Decision procedures for matchgate-Holant tractability: polynomial-time SRP solver, Galluccio-Loebl Holant evaluator, hardness-candidate screening.
5
+ Author-email: Edward Chalk <edward.chalk@sapientronic.ai>
6
+ License: holant-tools
7
+
8
+ Copyright (c) 2026 Edward Chalk (sapientronic.ai)
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to use,
12
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
13
+ the Software, and to permit persons to whom the Software is furnished to do
14
+ so, subject to the following conditions:
15
+
16
+ 1. The above copyright notice and this permission notice shall be included
17
+ in all copies or substantial portions of the Software.
18
+
19
+ 2. Attribution. Any publication, presentation, derivative work, or product
20
+ that uses or builds on this Software must include visible attribution to
21
+ Edward Chalk and sapientronic.ai. The phrase "Built with holant-tools by
22
+ Edward Chalk (sapientronic.ai)" or equivalent is acceptable.
23
+
24
+ 3. The Software is provided "AS IS", without warranty of any kind, express
25
+ or implied, including but not limited to the warranties of merchantability,
26
+ fitness for a particular purpose, and noninfringement. In no event shall
27
+ the authors or copyright holders be liable for any claim, damages, or
28
+ other liability, whether in an action of contract, tort, or otherwise,
29
+ arising from, out of, or in connection with the Software or the use or
30
+ other dealings in the Software.
31
+
32
+ This license is modeled on the MIT License with an explicit attribution
33
+ clause (clause 2).
34
+
35
+ Project-URL: Homepage, https://github.com/pcoz/holant-tools
36
+ Project-URL: Repository, https://github.com/pcoz/holant-tools
37
+ Project-URL: Issues, https://github.com/pcoz/holant-tools/issues
38
+ Keywords: holant,matchgate,holographic-algorithm,constraint-counting,tractability,complexity,cai-lu,pfaffian,srp,weighted-model-counting
39
+ Classifier: Development Status :: 3 - Alpha
40
+ Classifier: Intended Audience :: Science/Research
41
+ Classifier: Intended Audience :: Developers
42
+ Classifier: License :: Other/Proprietary License
43
+ Classifier: Operating System :: OS Independent
44
+ Classifier: Programming Language :: Python :: 3
45
+ Classifier: Programming Language :: Python :: 3.9
46
+ Classifier: Programming Language :: Python :: 3.10
47
+ Classifier: Programming Language :: Python :: 3.11
48
+ Classifier: Programming Language :: Python :: 3.12
49
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
50
+ Requires-Python: >=3.9
51
+ Description-Content-Type: text/markdown
52
+ License-File: LICENSE
53
+ Requires-Dist: sympy>=1.10
54
+ Dynamic: license-file
55
+
56
+ # holant-tools
57
+
58
+ **Decision procedures for matchgate-Holant tractability.**
59
+
60
+ `holant-tools` decides, in polynomial time, whether a set of matchgate constraint functions admits a polynomial-time holographic-algorithm route — and if so, gives you the basis on which to construct it. The kernel implementation of a tractability-routing layer that could sit on top of general-purpose constraint solvers.
61
+
62
+ To the author's knowledge, this is the first published runnable implementation of Cai–Lu 2011's polynomial-time Simultaneous Realizability Problem solver — a result that has stood as paper-only since 2011.
63
+
64
+ ## Install
65
+
66
+ ```bash
67
+ pip install holant-tools
68
+ ```
69
+
70
+ Requires Python ≥ 3.9 and `sympy`.
71
+
72
+ ## 30-second example: Cai–Lu §5.1 reproduced
73
+
74
+ The canonical published example is `#_7 Pl-Rtw-Mon-3CNF` — a $\#\mathsf{P}$-complete counting problem that is tractable mod 7. Two signatures: `EQ_2 = [1, 0, 1]` (recognizer, arity 2) and `OR_3 = [0, 1, 1, 1]` (generator, arity 3).
75
+
76
+ ```bash
77
+ $ holant solve examples/01_cai_lu_5_1.json --modulus 7
78
+ SRP: FEASIBLE
79
+ Witness basis: u = 2, v = 3
80
+ Branch combination: [even, even]
81
+ solved over F_7 (tried 1 branch combination(s))
82
+ ```
83
+
84
+ The same problem is infeasible over the algebraic closure of $\mathbf{Q}$ (no rational/algebraic basis works) — the mod-7 specificity is the "$\#_7$" in the problem name, and it falls out of the algorithm.
85
+
86
+ Programmatic API:
87
+
88
+ ```python
89
+ from holant_tools import from_symmetric, srp_solve
90
+
91
+ sigs = [
92
+ from_symmetric([1, 0, 1], name="EQ_2"),
93
+ from_symmetric([0, 1, 1, 1], name="OR_3", kind="generator"),
94
+ ]
95
+ result = srp_solve(sigs, modulus=7)
96
+ print(result.feasible) # True
97
+ print(result.witness) # {U: 2, V: 3}
98
+ ```
99
+
100
+ ## What it does
101
+
102
+ Given a list of matchgate signatures, the tool answers:
103
+
104
+ - Is this set of constraints jointly realizable on some basis? (Cai–Lu's Simultaneous Realizability Problem; polynomial-time decidable per their 2011 Theorem 4.1.)
105
+ - If yes, what is the basis? (Provides the witness.)
106
+ - Over which field — algebraic closure of $\mathbf{Q}$, or a specific finite field $\mathbf{F}_p$?
107
+ - Is this a candidate for $\#\mathsf{P}$-hardness? (Screening: if no realising basis exists across $\overline{\mathbf{Q}}$ + multiple small primes, the matchgate / holographic-algorithm route is unavailable — a necessary condition for hardness in the Cai–Lu–Xia dichotomy framework.)
108
+
109
+ ## CLI
110
+
111
+ ```
112
+ holant signature "[1, 0, 1]" # Individual realizability (Cai–Lu Thm 2.5)
113
+ holant check sigs.json # Necessary-condition SRP check
114
+ holant solve sigs.json [--modulus p] # Full SRP (intersection on M)
115
+ holant hardness sigs.json [--primes ...] # Hardness-candidate screening
116
+ ```
117
+
118
+ JSON input format (`sigs.json`):
119
+
120
+ ```json
121
+ [
122
+ {"values": [1, 0, 1], "kind": "recognizer", "name": "EQ_2"},
123
+ {"values": [0, 1, 1, 1], "kind": "generator", "name": "OR_3"}
124
+ ]
125
+ ```
126
+
127
+ - `values`: signature entries by Hamming weight, length = arity + 1.
128
+ - `kind`: `"recognizer"` or `"generator"`.
129
+ - `name`: optional display string.
130
+
131
+ See `examples/` for four worked walkthroughs (Cai–Lu §5.1, single signature, hardness-candidate short-circuit, arity-4).
132
+
133
+ ## Scope (v0.1)
134
+
135
+ Shipped:
136
+
137
+ - Symmetric matchgate signatures, **any arity**. Cai–Lu Theorem 2.5 (necessary) + Theorem 4.1 (sufficient, polynomial-time SRP).
138
+ - Non-symmetric matchgate signatures, **arity ≤ 4**, both parity branches, with the full Grassmann–Plücker matchgate identities at arity 4.
139
+ - Galluccio–Loebl Holant evaluator for **genus-$g$ matchgate networks** (signed Pfaffian sum over $2^{2g}$ spin structures).
140
+ - Hardness-candidate screening across $\overline{\mathbf{Q}}$ + small finite fields.
141
+
142
+ Not yet shipped (the v0.2+ roadmap):
143
+
144
+ - Non-symmetric arity ≥ 5.
145
+ - Multi-chart coverage of the basis manifold $\mathcal{M}$ (currently a single open chart $u \ne v$).
146
+ - Holant$^*$ / Holant$^c$ variants (auxiliary signatures available).
147
+ - Translation layers from SAT / CSP / MILP common formats.
148
+ - Automatic Kasteleyn-orientation construction from rotation-system input.
149
+
150
+ ## Why is this useful?
151
+
152
+ Where Holant-tractable structure shows up in practice:
153
+
154
+ - **Counting #SAT instances with planar matchgate structure** — preprocessing layer that detects when a problem admits Valiant's holographic-algorithm route.
155
+ - **Classical simulation of matchgate quantum circuits** — Valiant 2002; classical simulability of free-fermion quantum dynamics.
156
+ - **Statistical mechanics on planar / bounded-genus lattices** — dimer counting, Ising and Potts models, free-fermion lattice models.
157
+ - **Counting perfect matchings on planar and bounded-genus graphs** — the FKT theorem and its Galluccio–Loebl extension are the canonical algorithms.
158
+ - **Designing tractable counting CSP variants** — the framework lets you check, ahead of time, whether your designed problem class lies in the polynomial-time matchgate corner.
159
+
160
+ See `holant-tools-applications.md` for the full discussion of where matchgate tractability genuinely applies, where it could apply with further development, and where it honestly doesn't.
161
+
162
+ ## Math
163
+
164
+ `holant-tools-theory.md` contains the theory: matchgate signatures, the Cai–Lu basis manifold $\mathcal{M} = \mathrm{GL}_2/\!\sim$, the parity-pullback construction in a chart of $\mathcal{M}$, the Grassmann–Plücker matchgate identities for arity 4 (both parity branches, the latter via augmented-Pfaffian), and the Galluccio–Loebl Holant formula for genus-$g$ networks.
165
+
166
+ ## Tests
167
+
168
+ ```bash
169
+ git clone https://github.com/pcoz/holant-tools.git
170
+ cd holant-tools
171
+ pip install -e .
172
+ python tests/test_holant_tools.py
173
+ # All v0.1 + v0.2 + v0.3-alpha + v0.3-beta + v0.3-beta-followon + hardness tests pass.
174
+ ```
175
+
176
+ 47 tests across all subsystems.
177
+
178
+ ## License
179
+
180
+ `LICENSE` — modeled on the MIT License with an explicit attribution clause. Use is free; attribution to *Edward Chalk (sapientronic.ai)* is required for publications, presentations, derivative works, and products that build on this software.
181
+
182
+ ## References
183
+
184
+ - [CL11] J.-Y. Cai, P. Lu. *Holographic Algorithms: From Art to Science.* J. Comput. Syst. Sci. **77** (1) (2011) 41–61.
185
+ - [Val08] L. G. Valiant. *Holographic Algorithms.* SIAM J. Comput. **37** (5) (2008) 1565–1594.
186
+ - [GL99] A. Galluccio, M. Loebl. *On the theory of Pfaffian orientations.* J. Algebraic Combin. **9** (1999).
187
+ - [Tes00] G. Tesler. *Matchings in graphs on non-orientable surfaces.* J. Combin. Theory B **78** (2000).
188
+ - [Nor08] S. Norine. *Matching structure and Pfaffian orientations of graphs.* PhD thesis, Georgia Tech, 2005.
@@ -0,0 +1,133 @@
1
+ # holant-tools
2
+
3
+ **Decision procedures for matchgate-Holant tractability.**
4
+
5
+ `holant-tools` decides, in polynomial time, whether a set of matchgate constraint functions admits a polynomial-time holographic-algorithm route — and if so, gives you the basis on which to construct it. The kernel implementation of a tractability-routing layer that could sit on top of general-purpose constraint solvers.
6
+
7
+ To the author's knowledge, this is the first published runnable implementation of Cai–Lu 2011's polynomial-time Simultaneous Realizability Problem solver — a result that has stood as paper-only since 2011.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install holant-tools
13
+ ```
14
+
15
+ Requires Python ≥ 3.9 and `sympy`.
16
+
17
+ ## 30-second example: Cai–Lu §5.1 reproduced
18
+
19
+ The canonical published example is `#_7 Pl-Rtw-Mon-3CNF` — a $\#\mathsf{P}$-complete counting problem that is tractable mod 7. Two signatures: `EQ_2 = [1, 0, 1]` (recognizer, arity 2) and `OR_3 = [0, 1, 1, 1]` (generator, arity 3).
20
+
21
+ ```bash
22
+ $ holant solve examples/01_cai_lu_5_1.json --modulus 7
23
+ SRP: FEASIBLE
24
+ Witness basis: u = 2, v = 3
25
+ Branch combination: [even, even]
26
+ solved over F_7 (tried 1 branch combination(s))
27
+ ```
28
+
29
+ The same problem is infeasible over the algebraic closure of $\mathbf{Q}$ (no rational/algebraic basis works) — the mod-7 specificity is the "$\#_7$" in the problem name, and it falls out of the algorithm.
30
+
31
+ Programmatic API:
32
+
33
+ ```python
34
+ from holant_tools import from_symmetric, srp_solve
35
+
36
+ sigs = [
37
+ from_symmetric([1, 0, 1], name="EQ_2"),
38
+ from_symmetric([0, 1, 1, 1], name="OR_3", kind="generator"),
39
+ ]
40
+ result = srp_solve(sigs, modulus=7)
41
+ print(result.feasible) # True
42
+ print(result.witness) # {U: 2, V: 3}
43
+ ```
44
+
45
+ ## What it does
46
+
47
+ Given a list of matchgate signatures, the tool answers:
48
+
49
+ - Is this set of constraints jointly realizable on some basis? (Cai–Lu's Simultaneous Realizability Problem; polynomial-time decidable per their 2011 Theorem 4.1.)
50
+ - If yes, what is the basis? (Provides the witness.)
51
+ - Over which field — algebraic closure of $\mathbf{Q}$, or a specific finite field $\mathbf{F}_p$?
52
+ - Is this a candidate for $\#\mathsf{P}$-hardness? (Screening: if no realising basis exists across $\overline{\mathbf{Q}}$ + multiple small primes, the matchgate / holographic-algorithm route is unavailable — a necessary condition for hardness in the Cai–Lu–Xia dichotomy framework.)
53
+
54
+ ## CLI
55
+
56
+ ```
57
+ holant signature "[1, 0, 1]" # Individual realizability (Cai–Lu Thm 2.5)
58
+ holant check sigs.json # Necessary-condition SRP check
59
+ holant solve sigs.json [--modulus p] # Full SRP (intersection on M)
60
+ holant hardness sigs.json [--primes ...] # Hardness-candidate screening
61
+ ```
62
+
63
+ JSON input format (`sigs.json`):
64
+
65
+ ```json
66
+ [
67
+ {"values": [1, 0, 1], "kind": "recognizer", "name": "EQ_2"},
68
+ {"values": [0, 1, 1, 1], "kind": "generator", "name": "OR_3"}
69
+ ]
70
+ ```
71
+
72
+ - `values`: signature entries by Hamming weight, length = arity + 1.
73
+ - `kind`: `"recognizer"` or `"generator"`.
74
+ - `name`: optional display string.
75
+
76
+ See `examples/` for four worked walkthroughs (Cai–Lu §5.1, single signature, hardness-candidate short-circuit, arity-4).
77
+
78
+ ## Scope (v0.1)
79
+
80
+ Shipped:
81
+
82
+ - Symmetric matchgate signatures, **any arity**. Cai–Lu Theorem 2.5 (necessary) + Theorem 4.1 (sufficient, polynomial-time SRP).
83
+ - Non-symmetric matchgate signatures, **arity ≤ 4**, both parity branches, with the full Grassmann–Plücker matchgate identities at arity 4.
84
+ - Galluccio–Loebl Holant evaluator for **genus-$g$ matchgate networks** (signed Pfaffian sum over $2^{2g}$ spin structures).
85
+ - Hardness-candidate screening across $\overline{\mathbf{Q}}$ + small finite fields.
86
+
87
+ Not yet shipped (the v0.2+ roadmap):
88
+
89
+ - Non-symmetric arity ≥ 5.
90
+ - Multi-chart coverage of the basis manifold $\mathcal{M}$ (currently a single open chart $u \ne v$).
91
+ - Holant$^*$ / Holant$^c$ variants (auxiliary signatures available).
92
+ - Translation layers from SAT / CSP / MILP common formats.
93
+ - Automatic Kasteleyn-orientation construction from rotation-system input.
94
+
95
+ ## Why is this useful?
96
+
97
+ Where Holant-tractable structure shows up in practice:
98
+
99
+ - **Counting #SAT instances with planar matchgate structure** — preprocessing layer that detects when a problem admits Valiant's holographic-algorithm route.
100
+ - **Classical simulation of matchgate quantum circuits** — Valiant 2002; classical simulability of free-fermion quantum dynamics.
101
+ - **Statistical mechanics on planar / bounded-genus lattices** — dimer counting, Ising and Potts models, free-fermion lattice models.
102
+ - **Counting perfect matchings on planar and bounded-genus graphs** — the FKT theorem and its Galluccio–Loebl extension are the canonical algorithms.
103
+ - **Designing tractable counting CSP variants** — the framework lets you check, ahead of time, whether your designed problem class lies in the polynomial-time matchgate corner.
104
+
105
+ See `holant-tools-applications.md` for the full discussion of where matchgate tractability genuinely applies, where it could apply with further development, and where it honestly doesn't.
106
+
107
+ ## Math
108
+
109
+ `holant-tools-theory.md` contains the theory: matchgate signatures, the Cai–Lu basis manifold $\mathcal{M} = \mathrm{GL}_2/\!\sim$, the parity-pullback construction in a chart of $\mathcal{M}$, the Grassmann–Plücker matchgate identities for arity 4 (both parity branches, the latter via augmented-Pfaffian), and the Galluccio–Loebl Holant formula for genus-$g$ networks.
110
+
111
+ ## Tests
112
+
113
+ ```bash
114
+ git clone https://github.com/pcoz/holant-tools.git
115
+ cd holant-tools
116
+ pip install -e .
117
+ python tests/test_holant_tools.py
118
+ # All v0.1 + v0.2 + v0.3-alpha + v0.3-beta + v0.3-beta-followon + hardness tests pass.
119
+ ```
120
+
121
+ 47 tests across all subsystems.
122
+
123
+ ## License
124
+
125
+ `LICENSE` — modeled on the MIT License with an explicit attribution clause. Use is free; attribution to *Edward Chalk (sapientronic.ai)* is required for publications, presentations, derivative works, and products that build on this software.
126
+
127
+ ## References
128
+
129
+ - [CL11] J.-Y. Cai, P. Lu. *Holographic Algorithms: From Art to Science.* J. Comput. Syst. Sci. **77** (1) (2011) 41–61.
130
+ - [Val08] L. G. Valiant. *Holographic Algorithms.* SIAM J. Comput. **37** (5) (2008) 1565–1594.
131
+ - [GL99] A. Galluccio, M. Loebl. *On the theory of Pfaffian orientations.* J. Algebraic Combin. **9** (1999).
132
+ - [Tes00] G. Tesler. *Matchings in graphs on non-orientable surfaces.* J. Combin. Theory B **78** (2000).
133
+ - [Nor08] S. Norine. *Matching structure and Pfaffian orientations of graphs.* PhD thesis, Georgia Tech, 2005.
@@ -0,0 +1,210 @@
1
+ """holant-tools: decision procedures for matchgate-Holant tractability.
2
+
3
+ This package implements a polynomial-time decision procedure for whether a set
4
+ of matchgate signatures admits a polynomial-time holographic-algorithm route
5
+ (Cai-Lu 2011's Simultaneous Realizability Problem, plus extensions). It is
6
+ designed as the analysis kernel of a tractability-routing layer that could
7
+ sit on top of general-purpose constraint solvers; the kernel itself is the
8
+ v0.1 release.
9
+
10
+ Quick start
11
+ -----------
12
+
13
+ >>> from holant_tools import from_symmetric, srp_solve
14
+ >>> sigs = [from_symmetric([1, 0, 1], "EQ_2"),
15
+ ... from_symmetric([0, 1, 1, 1], "OR_3", kind="generator")]
16
+ >>> srp_solve(sigs, modulus=7)
17
+ SRPResult(feasible=True, witness={u: 2, v: 3}, ...)
18
+
19
+ The above reproduces Cai-Lu 2011 sec 5.1's `#_7 Pl-Rtw-Mon-3CNF` decision:
20
+ SRP is feasible over the finite field F_7 with witness basis (u, v) = (2, 3).
21
+ The mod-7 phenomenon falls out from the algorithm; it is not configured.
22
+
23
+ Public API
24
+ ----------
25
+
26
+ Constructors:
27
+ from_symmetric(values, name="", kind="recognizer")
28
+ from_non_symmetric(values, arity, name="", kind="recognizer")
29
+
30
+ Decision procedures:
31
+ srp_solve(signatures, modulus=None) # full SRP
32
+ hardness_candidate(signatures, primes=...) # screen for hardness candidates
33
+ is_realizable_somewhere(sig) # Cai-Lu Theorem 2.5 (individual)
34
+ classify_form(sig) # Cai-Lu Form 1/2/3 classification
35
+
36
+ Lower-level building blocks:
37
+ realizability_subvariety(sig) # symmetric
38
+ realizability_subvariety_non_symmetric(sig) # 2^n-valued
39
+ intersect_subvarieties(subvarieties, modulus=None)
40
+
41
+ Holant evaluation (genus-g matchgate networks):
42
+ holant_planar(M) # FKT planar Pfaffian
43
+ holant_genus_g(matrices, genus) # Galluccio-Loebl signed sum
44
+
45
+ CLI: `holant solve`, `holant check`, `holant hardness`, `holant signature`.
46
+
47
+ Scope
48
+ -----
49
+
50
+ Shipped in v0.1:
51
+ - Symmetric matchgate signatures of any arity (Cai-Lu Theorem 2.5 + 4.1).
52
+ - Non-symmetric matchgate signatures of arity <= 4, both parity branches,
53
+ with the full Grassmann-Plucker matchgate identities at arity 4.
54
+ - Galluccio-Loebl Holant evaluator for genus-g matchgate networks.
55
+ - Hardness-candidate screening across Q-bar + small finite fields.
56
+ - Single chart of the basis manifold M = GL_2/~.
57
+
58
+ Not yet shipped (v0.2+ roadmap):
59
+ - Non-symmetric arity >= 5 (general Grassmann-Plucker; multiple independent
60
+ matchgate identities per arity).
61
+ - Multi-chart coverage of M (second chart for bases with the first row of
62
+ the basis matrix having a zero entry).
63
+ - Holant* and Holant^c variants (auxiliary signature seeding).
64
+ - Translation layers from SAT / CSP / MILP common formats to Holant
65
+ signatures.
66
+ - Automatic Kasteleyn-orientation construction from rotation-system input.
67
+
68
+ See `paper.md` for the theory and `APPLICATIONS.md` for where Holant
69
+ problems show up in practice.
70
+
71
+ References
72
+ ----------
73
+
74
+ [CL11] J.-Y. Cai, P. Lu. *Holographic Algorithms: From Art to Science.*
75
+ J. Comput. Syst. Sci. 77 (1) (2011) 41-61.
76
+ [Val08] L. G. Valiant. *Holographic Algorithms.* SIAM J. Comput. 37 (5)
77
+ (2008) 1565-1594.
78
+ [GL99] A. Galluccio, M. Loebl. *On the theory of Pfaffian orientations.*
79
+ J. Algebraic Combin. 9 (1999).
80
+ """
81
+
82
+ __version__ = "0.1.0"
83
+
84
+ from .signatures import (
85
+ Signature,
86
+ Recurrence,
87
+ find_recurrence,
88
+ is_realizable_somewhere,
89
+ srp_necessary_check,
90
+ )
91
+ from .realizability import (
92
+ Form,
93
+ FormClassification,
94
+ Subvariety,
95
+ classify_form,
96
+ realizability_subvariety,
97
+ U,
98
+ V,
99
+ )
100
+ from .intersection import (
101
+ IntersectionResult,
102
+ intersect_subvarieties,
103
+ )
104
+ from .srp_solver import (
105
+ SRPResult,
106
+ srp_solve,
107
+ )
108
+ from .holant import (
109
+ pfaffian,
110
+ arf_invariant,
111
+ arf_invariant_genus_1,
112
+ spin_structures_genus,
113
+ holant_genus_g,
114
+ holant_planar,
115
+ )
116
+ from .non_symmetric import (
117
+ NonSymmetricSignature,
118
+ pullback_tau_non_symmetric,
119
+ realizability_subvariety_non_symmetric,
120
+ matchgate_identity_arity_4_even,
121
+ matchgate_identity_arity_4_odd,
122
+ )
123
+ from .hardness import (
124
+ HardnessReport,
125
+ hardness_candidate,
126
+ )
127
+ from . import examples
128
+
129
+
130
+ # ---------------------------------------------------------------------------
131
+ # Ergonomic constructors (the recommended entry points for new users)
132
+ # ---------------------------------------------------------------------------
133
+
134
+ def from_symmetric(values, name="", kind="recognizer"):
135
+ """Construct a symmetric matchgate Signature.
136
+
137
+ Args:
138
+ values: iterable of n+1 field values, indexed by Hamming weight.
139
+ For arity n, supply n+1 entries.
140
+ name: optional display name for the signature.
141
+ kind: "recognizer" (default) or "generator".
142
+
143
+ Example:
144
+ >>> sig = from_symmetric([1, 0, 1], name="EQ_2")
145
+ >>> sig
146
+ Signature([1, 0, 1], recognizer, arity 2, name='EQ_2')
147
+
148
+ Equivalent to `Signature(values=tuple(values), kind=kind, name=name)`.
149
+ """
150
+ return Signature(values=tuple(values), kind=kind, name=name)
151
+
152
+
153
+ def from_non_symmetric(values, arity, name="", kind="recognizer"):
154
+ """Construct a non-symmetric matchgate NonSymmetricSignature.
155
+
156
+ Args:
157
+ values: dict mapping bit-string tuples of length `arity` to field values.
158
+ Missing entries default to 0.
159
+ arity: matchgate arity (number of wires).
160
+ name: optional display name.
161
+ kind: "recognizer" (default) or "generator".
162
+
163
+ Example:
164
+ >>> # Non-symmetric arity-2: tau_{01} = 1, tau_{10} = -1, rest 0.
165
+ >>> sig = from_non_symmetric({(0, 1): 1, (1, 0): -1}, arity=2, name="asym")
166
+ """
167
+ return NonSymmetricSignature(values=dict(values), arity=arity, kind=kind, name=name)
168
+
169
+
170
+ __all__ = [
171
+ "__version__",
172
+ # Ergonomic constructors
173
+ "from_symmetric",
174
+ "from_non_symmetric",
175
+ # Dataclasses + result types
176
+ "Signature",
177
+ "NonSymmetricSignature",
178
+ "Recurrence",
179
+ "Form",
180
+ "FormClassification",
181
+ "Subvariety",
182
+ "IntersectionResult",
183
+ "SRPResult",
184
+ "HardnessReport",
185
+ "U",
186
+ "V",
187
+ # Decision procedures
188
+ "srp_solve",
189
+ "hardness_candidate",
190
+ "is_realizable_somewhere",
191
+ "classify_form",
192
+ "find_recurrence",
193
+ "srp_necessary_check",
194
+ # Lower-level building blocks
195
+ "realizability_subvariety",
196
+ "realizability_subvariety_non_symmetric",
197
+ "intersect_subvarieties",
198
+ "pullback_tau_non_symmetric",
199
+ "matchgate_identity_arity_4_even",
200
+ "matchgate_identity_arity_4_odd",
201
+ # Holant evaluation
202
+ "pfaffian",
203
+ "arf_invariant",
204
+ "arf_invariant_genus_1",
205
+ "spin_structures_genus",
206
+ "holant_genus_g",
207
+ "holant_planar",
208
+ # Examples module
209
+ "examples",
210
+ ]