ArchytasZX 0.9.1__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.
- archytaszx-0.9.1/ArchytasZX.egg-info/PKG-INFO +362 -0
- archytaszx-0.9.1/ArchytasZX.egg-info/SOURCES.txt +74 -0
- archytaszx-0.9.1/ArchytasZX.egg-info/dependency_links.txt +1 -0
- archytaszx-0.9.1/ArchytasZX.egg-info/requires.txt +7 -0
- archytaszx-0.9.1/ArchytasZX.egg-info/top_level.txt +1 -0
- archytaszx-0.9.1/LICENSE +190 -0
- archytaszx-0.9.1/PKG-INFO +362 -0
- archytaszx-0.9.1/README.md +333 -0
- archytaszx-0.9.1/archytaszx/__init__.py +14 -0
- archytaszx-0.9.1/archytaszx/algebra/__init__.py +14 -0
- archytaszx-0.9.1/archytaszx/algebra/dimension.py +590 -0
- archytaszx-0.9.1/archytaszx/algebra/phase.py +493 -0
- archytaszx-0.9.1/archytaszx/algebra/scalar.py +698 -0
- archytaszx-0.9.1/archytaszx/diagram/__init__.py +14 -0
- archytaszx-0.9.1/archytaszx/diagram/bangbox.py +1086 -0
- archytaszx-0.9.1/archytaszx/diagram/generators.py +255 -0
- archytaszx-0.9.1/archytaszx/diagram/graph.py +668 -0
- archytaszx-0.9.1/archytaszx/diagram/scalable.py +14 -0
- archytaszx-0.9.1/archytaszx/diagram/validate.py +927 -0
- archytaszx-0.9.1/archytaszx/repl/__init__.py +14 -0
- archytaszx-0.9.1/archytaszx/repl/commands.py +15 -0
- archytaszx-0.9.1/archytaszx/repl/parser.py +295 -0
- archytaszx-0.9.1/archytaszx/repl/printer.py +15 -0
- archytaszx-0.9.1/archytaszx/repl/shell.py +15 -0
- archytaszx-0.9.1/archytaszx/rewrite/__init__.py +14 -0
- archytaszx-0.9.1/archytaszx/rewrite/cache.py +14 -0
- archytaszx-0.9.1/archytaszx/rewrite/egraph.py +14 -0
- archytaszx-0.9.1/archytaszx/rewrite/engine.py +596 -0
- archytaszx-0.9.1/archytaszx/rewrite/match.py +1501 -0
- archytaszx-0.9.1/archytaszx/rewrite/normal_form.py +14 -0
- archytaszx-0.9.1/archytaszx/rewrite/rule.py +461 -0
- archytaszx-0.9.1/archytaszx/rewrite/rules_library.py +498 -0
- archytaszx-0.9.1/archytaszx/rewrite/tactics.py +14 -0
- archytaszx-0.9.1/archytaszx/semantics/__init__.py +14 -0
- archytaszx-0.9.1/archytaszx/semantics/certificate.py +776 -0
- archytaszx-0.9.1/archytaszx/semantics/check.py +436 -0
- archytaszx-0.9.1/archytaszx/semantics/contract_numeric.py +293 -0
- archytaszx-0.9.1/archytaszx/semantics/contract_symbolic.py +391 -0
- archytaszx-0.9.1/archytaszx/semantics/denote.py +271 -0
- archytaszx-0.9.1/archytaszx/semantics/induction.py +1012 -0
- archytaszx-0.9.1/pyproject.toml +94 -0
- archytaszx-0.9.1/setup.cfg +4 -0
- archytaszx-0.9.1/tests/test_bangbox.py +317 -0
- archytaszx-0.9.1/tests/test_certificate.py +549 -0
- archytaszx-0.9.1/tests/test_check.py +303 -0
- archytaszx-0.9.1/tests/test_contract_numeric.py +247 -0
- archytaszx-0.9.1/tests/test_contract_symbolic.py +437 -0
- archytaszx-0.9.1/tests/test_denote.py +217 -0
- archytaszx-0.9.1/tests/test_diagram_graph.py +362 -0
- archytaszx-0.9.1/tests/test_dimension.py +350 -0
- archytaszx-0.9.1/tests/test_docstring_policy.py +155 -0
- archytaszx-0.9.1/tests/test_engine.py +1858 -0
- archytaszx-0.9.1/tests/test_fusion_properties.py +1921 -0
- archytaszx-0.9.1/tests/test_generators.py +128 -0
- archytaszx-0.9.1/tests/test_induction.py +753 -0
- archytaszx-0.9.1/tests/test_match.py +2248 -0
- archytaszx-0.9.1/tests/test_phase.py +372 -0
- archytaszx-0.9.1/tests/test_phase2_oracle.py +93 -0
- archytaszx-0.9.1/tests/test_phase3_oracle.py +82 -0
- archytaszx-0.9.1/tests/test_phase4_oracle.py +71 -0
- archytaszx-0.9.1/tests/test_phase5_certificate_sweep.py +902 -0
- archytaszx-0.9.1/tests/test_phase5_dirac_oracle.py +404 -0
- archytaszx-0.9.1/tests/test_phase5_exhaustive_oracle.py +278 -0
- archytaszx-0.9.1/tests/test_phase5_oracle.py +773 -0
- archytaszx-0.9.1/tests/test_phase6_oracle.py +134 -0
- archytaszx-0.9.1/tests/test_phase7_oracle.py +350 -0
- archytaszx-0.9.1/tests/test_phase8_oracle.py +451 -0
- archytaszx-0.9.1/tests/test_phase9_oracle.py +398 -0
- archytaszx-0.9.1/tests/test_rule.py +429 -0
- archytaszx-0.9.1/tests/test_rules_library.py +777 -0
- archytaszx-0.9.1/tests/test_scalar.py +311 -0
- archytaszx-0.9.1/tests/test_symbolic_dimension_sweep.py +351 -0
- archytaszx-0.9.1/tests/test_three_node_oracle_sweep.py +210 -0
- archytaszx-0.9.1/tests/test_three_parallel_wire_arm.py +121 -0
- archytaszx-0.9.1/tests/test_unify_all.py +223 -0
- archytaszx-0.9.1/tests/test_validate.py +737 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ArchytasZX
|
|
3
|
+
Version: 0.9.1
|
|
4
|
+
Summary: A qufinite ZX-calculus engine with symbolic qudit count and dimension
|
|
5
|
+
Author: Arkhip Alekseyevich Dmitriev
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Arhip-Dmitriev/ArchytasZX
|
|
8
|
+
Project-URL: Repository, https://github.com/Arhip-Dmitriev/ArchytasZX
|
|
9
|
+
Project-URL: Issues, https://github.com/Arhip-Dmitriev/ArchytasZX/issues
|
|
10
|
+
Keywords: zx-calculus,qufinite,qudit,quantum computing,symbolic algebra,graph rewriting,quantum algorithms,symbolic quantum,graphical calculus
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Quantum Computing
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: numpy
|
|
23
|
+
Requires-Dist: sympy
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff; extra == "dev"
|
|
27
|
+
Requires-Dist: mypy; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# ArchytasZX
|
|
31
|
+
|
|
32
|
+
**A qufinite ZX-calculus engine for reasoning and interacting with quantum states that
|
|
33
|
+
leverages symbolic algebra to remove qudit-count and dimensionality limits.**
|
|
34
|
+
|
|
35
|
+
[](LICENSE)
|
|
36
|
+
[](https://www.python.org/downloads/)
|
|
37
|
+
[](#project-status)
|
|
38
|
+
|
|
39
|
+
Example:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
prove_by_induction(boxed, fused, witness={"d": 2})
|
|
43
|
+
# proved=True verdict=proved_uniform index='m' held_symbolic={'d'}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
One call, one proof, an entire doubly indexed family of identities for every qudit count and
|
|
47
|
+
every qudit dimension at once.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Why
|
|
52
|
+
|
|
53
|
+
*Coming soon.*
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
Python ≥ 3.11. `numpy` and `sympy` are the only runtime dependencies.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git clone https://github.com/Arhip-Dmitriev/ArchytasZX.git
|
|
61
|
+
cd ArchytasZX
|
|
62
|
+
python -m venv .venv && source .venv/bin/activate
|
|
63
|
+
pip install -e '.[dev]'
|
|
64
|
+
python -m pytest
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The distribution is named `ArchytasZX`; the importable package is `archytaszx`. There is
|
|
68
|
+
**no REPL and no command-line entry point yet** — `archytaszx/repl/shell.py` is a skeleton
|
|
69
|
+
awaiting implementation. The engine can currently only be used as a Python library, and has
|
|
70
|
+
generally limited use.
|
|
71
|
+
|
|
72
|
+
### Imports
|
|
73
|
+
|
|
74
|
+
The sub-package `__init__.py` files are empty. There are **no re-exports**, so
|
|
75
|
+
`from archytaszx import Diagram` will fail — import by full module path. It is verbose during the
|
|
76
|
+
development phase:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
# Layer A -- symbolic algebra
|
|
80
|
+
from archytaszx.algebra.dimension import Dim, unify_all
|
|
81
|
+
from archytaszx.algebra.phase import Phase, PhaseVector
|
|
82
|
+
from archytaszx.algebra.scalar import Scalar
|
|
83
|
+
|
|
84
|
+
# Layer B -- diagram data model
|
|
85
|
+
from archytaszx.diagram.graph import Diagram, Direction, PortRef
|
|
86
|
+
from archytaszx.diagram.generators import Z_SPIDER, X_SPIDER, FOURIER_BOX
|
|
87
|
+
from archytaszx.diagram.bangbox import abstract_subgraph_count, abstract_port_count, peel_one
|
|
88
|
+
from archytaszx.diagram.validate import validate, validate_or_raise
|
|
89
|
+
|
|
90
|
+
# Layer C -- rewriting
|
|
91
|
+
from archytaszx.rewrite.match import find_matches
|
|
92
|
+
from archytaszx.rewrite.engine import apply
|
|
93
|
+
from archytaszx.rewrite.rules_library import SPIDER_FUSION, FOURIER_CANCELLATION, ZX_CAP
|
|
94
|
+
|
|
95
|
+
# Layer D -- semantics, proof, certificates
|
|
96
|
+
from archytaszx.semantics.check import compare, score, compare_symbolic
|
|
97
|
+
from archytaszx.semantics.contract_symbolic import contract_symbolic
|
|
98
|
+
from archytaszx.semantics.induction import prove_by_induction
|
|
99
|
+
from archytaszx.semantics.certificate import certify, verify
|
|
100
|
+
|
|
101
|
+
# The restricted Dirac front end
|
|
102
|
+
from archytaszx.repl.parser import parse_dirac_source
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Errors
|
|
106
|
+
|
|
107
|
+
Every module raises only its own hierarchy, under a base `<Area>Error`:
|
|
108
|
+
|
|
109
|
+
| Exception | Meaning |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `<Area>GrammarError` | Wrong call |
|
|
112
|
+
| `<Area>DomainError` | Unimplemented as of now |
|
|
113
|
+
|
|
114
|
+
## Quickstart
|
|
115
|
+
|
|
116
|
+
### 1. Fuse two spiders over a symbolic dimension
|
|
117
|
+
|
|
118
|
+
Build a state-prep Z spider whose output feeds a copy spider, with the dimension left as the
|
|
119
|
+
symbol `d`, and fuse them.
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from archytaszx.algebra.dimension import Dim
|
|
123
|
+
from archytaszx.diagram.generators import Z_SPIDER
|
|
124
|
+
from archytaszx.diagram.graph import Diagram, Direction, PortRef
|
|
125
|
+
from archytaszx.rewrite.match import find_matches
|
|
126
|
+
from archytaszx.rewrite.engine import apply
|
|
127
|
+
from archytaszx.rewrite.rules_library import SPIDER_FUSION
|
|
128
|
+
|
|
129
|
+
d = Dim.symbol("d")
|
|
130
|
+
|
|
131
|
+
g = Diagram()
|
|
132
|
+
a = g.add_node(Z_SPIDER, input_dims=[], output_dims=[d, d])
|
|
133
|
+
b = g.add_node(Z_SPIDER, input_dims=[d], output_dims=[d, d])
|
|
134
|
+
g.add_wire(PortRef(a, Direction.OUTPUT, 0), PortRef(b, Direction.INPUT, 0))
|
|
135
|
+
g.set_boundary_outputs([
|
|
136
|
+
PortRef(a, Direction.OUTPUT, 1),
|
|
137
|
+
PortRef(b, Direction.OUTPUT, 0),
|
|
138
|
+
PortRef(b, Direction.OUTPUT, 1),
|
|
139
|
+
])
|
|
140
|
+
|
|
141
|
+
result = apply(g, SPIDER_FUSION, find_matches(g)[0])
|
|
142
|
+
|
|
143
|
+
len(result.diagram.nodes) # 1 -- two spiders became one
|
|
144
|
+
len(result.diagram.boundary_outputs) # 3 -- the boundary is unchanged
|
|
145
|
+
result.diagram.scalar # Scalar(1) -- exact, never discarded
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`d` was never given a value. The exact scalar the rule introduces is tracked rather than
|
|
149
|
+
dropped, which is what makes the result an equality rather than a proportionality.
|
|
150
|
+
|
|
151
|
+
### 2. Check it, and get a replayable certificate
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from archytaszx.semantics.check import compare
|
|
155
|
+
from archytaszx.semantics.certificate import certify, verify
|
|
156
|
+
|
|
157
|
+
compare(g, result.diagram, {"d": 5}).matched # True -- numeric oracle at d = 5
|
|
158
|
+
|
|
159
|
+
certificate = certify(g, [result], label="fuse A into B")
|
|
160
|
+
verify(certificate, {"d": 3}).verified # True
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
`verify` **replays** the derivation from the recorded steps and oracle-checks the input
|
|
164
|
+
against the re-derived output. Tampering with any recorded field (the scalar, the rule name,
|
|
165
|
+
a consumed wire, a side-condition outcome, a multiplicity) fails the replay.
|
|
166
|
+
|
|
167
|
+
### 3. Prove it for every count at once
|
|
168
|
+
|
|
169
|
+
Wrap the same graph in a bang box with symbolic multiplicity `m`, and discharge the identity
|
|
170
|
+
for every value of `m` with `d` still symbolic.
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from archytaszx.diagram.bangbox import abstract_subgraph_count
|
|
174
|
+
from archytaszx.semantics.induction import prove_by_induction
|
|
175
|
+
|
|
176
|
+
boxed, box_id, mult = abstract_subgraph_count(g, frozenset({a, b}), 1, stem="m")
|
|
177
|
+
fused = apply(boxed, SPIDER_FUSION, find_matches(boxed)[0]).diagram
|
|
178
|
+
|
|
179
|
+
proof = prove_by_induction(boxed, fused, witness={"d": 2})
|
|
180
|
+
|
|
181
|
+
proof.proved # True
|
|
182
|
+
proof.verdict # Verdict.PROVED_UNIFORM
|
|
183
|
+
proof.index # 'm': the multiplicity inducted on
|
|
184
|
+
proof.discharge # StepDischarge.UNIFORM_REWRITE -- which tier settled it
|
|
185
|
+
proof.held_symbolic # frozenset({'d'}) -- what stayed universally quantified
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The verdict distinguishes a proof for all `n` from a finite schema check, and `discharge`
|
|
189
|
+
names the tier that did the work. `SCHEMA_CHECKED` is reported separately from the two
|
|
190
|
+
`PROVED_*` verdicts.
|
|
191
|
+
|
|
192
|
+
### 4. Dirac in, with concrete numbers
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
from archytaszx.repl.parser import parse_dirac_source
|
|
196
|
+
|
|
197
|
+
p = parse_dirac_source("sum_{k=0}^{3-1} |k>^{30}; copy")
|
|
198
|
+
|
|
199
|
+
len(p.nodes) # 2
|
|
200
|
+
len(p.bang_boxes) # 1
|
|
201
|
+
dict(p.parameters) # {'d': 3, 'n': 29}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The user typed `3` and `30`. What came back is symbolic in **both** axes, with the values
|
|
205
|
+
recorded in the parameter environment for substitution back on output. The tensor power costs
|
|
206
|
+
*one* leg under a bang box, not thirty, and stays open to induction. Prefix a numeral with
|
|
207
|
+
`literal` to suppress abstraction.
|
|
208
|
+
|
|
209
|
+
### The full tour
|
|
210
|
+
|
|
211
|
+
Every layer end to end — validation, matching, certificates, the numeric and symbolic
|
|
212
|
+
oracles, the Dirac front end, and a proof by induction:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
python examples/api_tour.py
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
[`docs/TUTORIAL.md`](docs/TUTORIAL.md) is the matching API reference, section for section.
|
|
219
|
+
[`examples/demo_visual.py`](examples/demo_visual.py) is a wide-terminal walkthrough that
|
|
220
|
+
prints the full unfiltered trace next to the diagram pictures (working, but outdated).
|
|
221
|
+
|
|
222
|
+
## Architecture
|
|
223
|
+
|
|
224
|
+
Four layers, with the dependency direction running downward:
|
|
225
|
+
`algebra` ← `diagram` ← `rewrite` ← `semantics`.
|
|
226
|
+
|
|
227
|
+
**A — Symbolic algebra substrate** ([`archytaszx/algebra/`](archytaszx/algebra/))
|
|
228
|
+
Dimension expressions — a concrete integer, a symbol such as `d`, or arithmetic such as `d^n`
|
|
229
|
+
or `d1·d2` — normalised through one canonical form with a unifier that decides or constrains
|
|
230
|
+
when two must agree, and `abstract`/`substitute` as inverse directions. Phases as concrete
|
|
231
|
+
values, root-of-unity indices, or free symbolic parameters, carried in vectors whose length is
|
|
232
|
+
tied to `d`. Exact scalars built from roots of unity `ω_d = e^{2πi/d}` and free symbols, with
|
|
233
|
+
a character-sum simplifier that knows `Σ_{k=0}^{d-1} ω_d^{jk} = d·[j ≡ 0 mod d]`.
|
|
234
|
+
|
|
235
|
+
**B — Diagram data model** ([`archytaszx/diagram/`](archytaszx/diagram/))
|
|
236
|
+
Ports carrying their own dimension label; nodes carrying a generator type, ordered input and
|
|
237
|
+
output ports, and a symbolic phase slot; diagrams holding nodes, wires, ordered boundary
|
|
238
|
+
lists, a parameter environment, and an exact scalar accumulator. Bang boxes annotate a scoped
|
|
239
|
+
subgraph with a multiplicity symbol and support instantiate, copy, kill, merge and peel.
|
|
240
|
+
|
|
241
|
+
**C — Rewrite engine** ([`archytaszx/rewrite/`](archytaszx/rewrite/))
|
|
242
|
+
A rule bundles a left-hand pattern, a right-hand builder, side conditions, quantifiers over
|
|
243
|
+
counts and dimensions, and the exact scalar it introduces. The matcher finds occurrences and
|
|
244
|
+
checks every side condition before a rule may fire. The engine applies a rule at a match,
|
|
245
|
+
returns a new diagram, and records structured provenance from which a certificate is emitted.
|
|
246
|
+
|
|
247
|
+
**D — Semantics oracle and proof** ([`archytaszx/semantics/`](archytaszx/semantics/))
|
|
248
|
+
Three rungs in order of preference: rewriting first; symbolic contraction with `d` kept formal
|
|
249
|
+
as the general fallback, and the path by which a supplied concrete value of any size is
|
|
250
|
+
evaluated; numeric contraction at small concrete instantiations as the verification oracle of
|
|
251
|
+
last resort. Alongside them, induction over bang-box multiplicities and replayable
|
|
252
|
+
certificates.
|
|
253
|
+
|
|
254
|
+
Numeric contraction is the oracle. A spider's denotation is `d^rank` entries, so it saturates
|
|
255
|
+
within single digits of legs. Large concrete values are answered by substituting the parameter
|
|
256
|
+
environment into the closed symbolic form, which costs nothing in the size of the value.
|
|
257
|
+
|
|
258
|
+
## Project status
|
|
259
|
+
|
|
260
|
+
This is a **research prototype under active development**. The API is unstable, the rule
|
|
261
|
+
library is very limited, and nothing here should be treated as a useful, finished tool at this
|
|
262
|
+
moment.
|
|
263
|
+
|
|
264
|
+
### Working today
|
|
265
|
+
|
|
266
|
+
| Area | State |
|
|
267
|
+
|---|---|
|
|
268
|
+
| Dimension algebra | Integers, symbols, products, powers; one canonical form; `abstract`/`substitute` both directions |
|
|
269
|
+
| Phase and scalar algebra | Symbolic phase vectors tied to `d`; exact scalars with no silent global factors |
|
|
270
|
+
| Diagram model | Per-port dimensions, ordered boundaries, parameter environment, deep copy |
|
|
271
|
+
| Validation | Joint (leg-order independent) dimension resolution, boundary and port checks, symbol-role separation; typed finding kinds |
|
|
272
|
+
| Generators | Z spider, X spider, Fourier box |
|
|
273
|
+
| Rewrite core | Rule/pattern/builder abstraction, matcher, engine, structured provenance |
|
|
274
|
+
| Rule library | `spider_fusion`, `fourier_cancellation`, `zx_cap` |
|
|
275
|
+
| Numeric oracle | Denotation, contraction, exact comparison, opt-in up-to-global-phase mode |
|
|
276
|
+
| Symbolic contraction | Arbitrary diagram closed with `d` formal, through the character-sum simplifier |
|
|
277
|
+
| Induction | Base + step over a bang-box multiplicity, four-tier step ladder, five distinct verdicts |
|
|
278
|
+
| Certificates | Per-step provenance, independent replay, tamper detection |
|
|
279
|
+
| Dirac front end | One restricted grammar: a summed ket family |
|
|
280
|
+
|
|
281
|
+
### Not yet implemented
|
|
282
|
+
|
|
283
|
+
Mixed dimensions across a diagram and the full qufinite generator set (triangle, W, dimension
|
|
284
|
+
connectives) · the broader rule library and strategy layer · the normal-form decision
|
|
285
|
+
procedure · equality saturation and the e-graph · tactics and proof search · match and
|
|
286
|
+
denotation caching · scalable sheet-wire notation · the diagram-to-Dirac printer · the general
|
|
287
|
+
declaration syntax and the interactive REPL · diagram-wide dimension-constraint propagation.
|
|
288
|
+
|
|
289
|
+
### Known limits inside what is implemented
|
|
290
|
+
|
|
291
|
+
- The dimension unifier is still a placeholder: it decides simple cases, and reports
|
|
292
|
+
`DEFERRED` otherwise. Deferred and bound dimension findings are recorded as
|
|
293
|
+
assumptions, and both reach the certificate.
|
|
294
|
+
- Symbolic contraction handles a symbolic multiplicity only where the bang box is **closed off**
|
|
295
|
+
from the rest of the diagram; a box meeting a wire or a boundary slot has a rank that varies
|
|
296
|
+
with the count.
|
|
297
|
+
- `compare_symbolic` has **three** outcomes, not two — equal, unequal, and *indeterminate*
|
|
298
|
+
(the residual still carries an undecided index sum). Read `.reason` whenever a comparison
|
|
299
|
+
comes back unmatched.
|
|
300
|
+
- The induction step case settles a family whose peeled copies the scalar layer can close; the
|
|
301
|
+
rest falls through to rewriting at symbolic `n` or to a finite schema check, which reports
|
|
302
|
+
itself as one.
|
|
303
|
+
|
|
304
|
+
## Development
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
python -m pytest # default tier: 1408 tests, ~45s
|
|
308
|
+
python -m pytest -m slow # 28 multi-thousand-seed fuzz sweeps and oracle differentials, ~15m
|
|
309
|
+
python -m pytest -m "" # both tiers together
|
|
310
|
+
ruff format . && ruff check . && mypy archytaszx
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
`ruff format` is authoritative for layout; `mypy` runs in strict mode. Counts and timings
|
|
314
|
+
measured 2026-09-08.
|
|
315
|
+
|
|
316
|
+
## References
|
|
317
|
+
|
|
318
|
+
- Wang, *Qufinite ZX-calculus: a unified framework of qudit ZX-calculi* —
|
|
319
|
+
[arXiv:2104.06429](https://arxiv.org/abs/2104.06429)
|
|
320
|
+
- Kissinger et al., on bang boxes and scalable notation —
|
|
321
|
+
[arXiv:2204.11702](https://arxiv.org/abs/2204.11702)
|
|
322
|
+
- van de Wetering, *ZX-calculus for the working quantum computer scientist* —
|
|
323
|
+
[arXiv:2012.13966](https://arxiv.org/abs/2012.13966)
|
|
324
|
+
|
|
325
|
+
## Citation
|
|
326
|
+
|
|
327
|
+
If you use ArchytasZX in academic work, please cite it via [`CITATION.cff`](CITATION.cff), or:
|
|
328
|
+
|
|
329
|
+
```bibtex
|
|
330
|
+
@software{dmitriev_archytaszx,
|
|
331
|
+
author = {Dmitriev, Arkhip Alekseyevich},
|
|
332
|
+
title = {ArchytasZX: a qufinite ZX-calculus engine with symbolic qudit count and dimension},
|
|
333
|
+
year = {2026},
|
|
334
|
+
url = {https://github.com/Arhip-Dmitriev/ArchytasZX},
|
|
335
|
+
license = {Apache-2.0}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Contributing
|
|
340
|
+
|
|
341
|
+
Issues — bug reports, counterexamples, questions about the mathematics — are a vital part of
|
|
342
|
+
the development process. See [`CONTRIBUTING.md`](CONTRIBUTING.md) for setup, the required
|
|
343
|
+
checks, and how to report a soundness bug.
|
|
344
|
+
|
|
345
|
+
## License
|
|
346
|
+
|
|
347
|
+
Apache License 2.0 — see [`LICENSE`](LICENSE).
|
|
348
|
+
|
|
349
|
+
<!--
|
|
350
|
+
Copyright 2026 Arkhip A. Dmitriev
|
|
351
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
352
|
+
you may not use this file except in compliance with the License.
|
|
353
|
+
You may obtain a copy of the License at
|
|
354
|
+
|
|
355
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
356
|
+
|
|
357
|
+
Unless required by applicable law or agreed to in writing, software
|
|
358
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
359
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
360
|
+
See the License for the specific language governing permissions and
|
|
361
|
+
limitations under the License.
|
|
362
|
+
-->
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
ArchytasZX.egg-info/PKG-INFO
|
|
5
|
+
ArchytasZX.egg-info/SOURCES.txt
|
|
6
|
+
ArchytasZX.egg-info/dependency_links.txt
|
|
7
|
+
ArchytasZX.egg-info/requires.txt
|
|
8
|
+
ArchytasZX.egg-info/top_level.txt
|
|
9
|
+
archytaszx/__init__.py
|
|
10
|
+
archytaszx/algebra/__init__.py
|
|
11
|
+
archytaszx/algebra/dimension.py
|
|
12
|
+
archytaszx/algebra/phase.py
|
|
13
|
+
archytaszx/algebra/scalar.py
|
|
14
|
+
archytaszx/diagram/__init__.py
|
|
15
|
+
archytaszx/diagram/bangbox.py
|
|
16
|
+
archytaszx/diagram/generators.py
|
|
17
|
+
archytaszx/diagram/graph.py
|
|
18
|
+
archytaszx/diagram/scalable.py
|
|
19
|
+
archytaszx/diagram/validate.py
|
|
20
|
+
archytaszx/repl/__init__.py
|
|
21
|
+
archytaszx/repl/commands.py
|
|
22
|
+
archytaszx/repl/parser.py
|
|
23
|
+
archytaszx/repl/printer.py
|
|
24
|
+
archytaszx/repl/shell.py
|
|
25
|
+
archytaszx/rewrite/__init__.py
|
|
26
|
+
archytaszx/rewrite/cache.py
|
|
27
|
+
archytaszx/rewrite/egraph.py
|
|
28
|
+
archytaszx/rewrite/engine.py
|
|
29
|
+
archytaszx/rewrite/match.py
|
|
30
|
+
archytaszx/rewrite/normal_form.py
|
|
31
|
+
archytaszx/rewrite/rule.py
|
|
32
|
+
archytaszx/rewrite/rules_library.py
|
|
33
|
+
archytaszx/rewrite/tactics.py
|
|
34
|
+
archytaszx/semantics/__init__.py
|
|
35
|
+
archytaszx/semantics/certificate.py
|
|
36
|
+
archytaszx/semantics/check.py
|
|
37
|
+
archytaszx/semantics/contract_numeric.py
|
|
38
|
+
archytaszx/semantics/contract_symbolic.py
|
|
39
|
+
archytaszx/semantics/denote.py
|
|
40
|
+
archytaszx/semantics/induction.py
|
|
41
|
+
tests/test_bangbox.py
|
|
42
|
+
tests/test_certificate.py
|
|
43
|
+
tests/test_check.py
|
|
44
|
+
tests/test_contract_numeric.py
|
|
45
|
+
tests/test_contract_symbolic.py
|
|
46
|
+
tests/test_denote.py
|
|
47
|
+
tests/test_diagram_graph.py
|
|
48
|
+
tests/test_dimension.py
|
|
49
|
+
tests/test_docstring_policy.py
|
|
50
|
+
tests/test_engine.py
|
|
51
|
+
tests/test_fusion_properties.py
|
|
52
|
+
tests/test_generators.py
|
|
53
|
+
tests/test_induction.py
|
|
54
|
+
tests/test_match.py
|
|
55
|
+
tests/test_phase.py
|
|
56
|
+
tests/test_phase2_oracle.py
|
|
57
|
+
tests/test_phase3_oracle.py
|
|
58
|
+
tests/test_phase4_oracle.py
|
|
59
|
+
tests/test_phase5_certificate_sweep.py
|
|
60
|
+
tests/test_phase5_dirac_oracle.py
|
|
61
|
+
tests/test_phase5_exhaustive_oracle.py
|
|
62
|
+
tests/test_phase5_oracle.py
|
|
63
|
+
tests/test_phase6_oracle.py
|
|
64
|
+
tests/test_phase7_oracle.py
|
|
65
|
+
tests/test_phase8_oracle.py
|
|
66
|
+
tests/test_phase9_oracle.py
|
|
67
|
+
tests/test_rule.py
|
|
68
|
+
tests/test_rules_library.py
|
|
69
|
+
tests/test_scalar.py
|
|
70
|
+
tests/test_symbolic_dimension_sweep.py
|
|
71
|
+
tests/test_three_node_oracle_sweep.py
|
|
72
|
+
tests/test_three_parallel_wire_arm.py
|
|
73
|
+
tests/test_unify_all.py
|
|
74
|
+
tests/test_validate.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
archytaszx
|
archytaszx-0.9.1/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Arkhip A. Dmitriev
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|