zephirum 2.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.
Files changed (60) hide show
  1. zephirum-2.1.0/LICENSE +21 -0
  2. zephirum-2.1.0/PKG-INFO +291 -0
  3. zephirum-2.1.0/README.md +270 -0
  4. zephirum-2.1.0/pyproject.toml +31 -0
  5. zephirum-2.1.0/setup.cfg +4 -0
  6. zephirum-2.1.0/src/battery_ci.py +95 -0
  7. zephirum-2.1.0/src/oq3.py +84 -0
  8. zephirum-2.1.0/src/quantum_types.py +133 -0
  9. zephirum-2.1.0/src/shot_auditor.py +67 -0
  10. zephirum-2.1.0/src/zephirum.egg-info/PKG-INFO +291 -0
  11. zephirum-2.1.0/src/zephirum.egg-info/SOURCES.txt +58 -0
  12. zephirum-2.1.0/src/zephirum.egg-info/dependency_links.txt +1 -0
  13. zephirum-2.1.0/src/zephirum.egg-info/entry_points.txt +3 -0
  14. zephirum-2.1.0/src/zephirum.egg-info/requires.txt +13 -0
  15. zephirum-2.1.0/src/zephirum.egg-info/top_level.txt +25 -0
  16. zephirum-2.1.0/src/zkernel.py +53 -0
  17. zephirum-2.1.0/src/zqea_kem.py +65 -0
  18. zephirum-2.1.0/src/zqea_sig.py +94 -0
  19. zephirum-2.1.0/src/zqgate/__init__.py +1 -0
  20. zephirum-2.1.0/src/zqgate/cli.py +31 -0
  21. zephirum-2.1.0/src/zquantum.py +154 -0
  22. zephirum-2.1.0/src/zyql_auditkit.py +64 -0
  23. zephirum-2.1.0/src/zyql_cirq.py +56 -0
  24. zephirum-2.1.0/src/zyql_lisp.py +211 -0
  25. zephirum-2.1.0/src/zyql_llm_compress.py +131 -0
  26. zephirum-2.1.0/src/zyql_mps.py +73 -0
  27. zephirum-2.1.0/src/zyql_protocols.py +80 -0
  28. zephirum-2.1.0/src/zyql_quantum_gate.py +265 -0
  29. zephirum-2.1.0/src/zyql_rag_layer.py +157 -0
  30. zephirum-2.1.0/src/zyql_robust.py +181 -0
  31. zephirum-2.1.0/src/zyql_runtime.py +161 -0
  32. zephirum-2.1.0/src/zyql_selfverified.py +198 -0
  33. zephirum-2.1.0/src/zyql_witness.py +193 -0
  34. zephirum-2.1.0/src/zyql_world3.py +118 -0
  35. zephirum-2.1.0/src/zyql_worldscale.py +122 -0
  36. zephirum-2.1.0/src/zyql_zne.py +71 -0
  37. zephirum-2.1.0/src/zyqml_core.py +143 -0
  38. zephirum-2.1.0/tests/test_auditkit.py +21 -0
  39. zephirum-2.1.0/tests/test_canonical.py +52 -0
  40. zephirum-2.1.0/tests/test_cirq.py +28 -0
  41. zephirum-2.1.0/tests/test_decisoes_certificadas.py +26 -0
  42. zephirum-2.1.0/tests/test_frontiers.py +137 -0
  43. zephirum-2.1.0/tests/test_kem.py +67 -0
  44. zephirum-2.1.0/tests/test_lisp_regression.py +58 -0
  45. zephirum-2.1.0/tests/test_llm_compress.py +72 -0
  46. zephirum-2.1.0/tests/test_meta.py +15 -0
  47. zephirum-2.1.0/tests/test_multiple_testing.py +135 -0
  48. zephirum-2.1.0/tests/test_protocols.py +33 -0
  49. zephirum-2.1.0/tests/test_qasm3.py +80 -0
  50. zephirum-2.1.0/tests/test_regression_seal.py +20 -0
  51. zephirum-2.1.0/tests/test_rodada_h.py +207 -0
  52. zephirum-2.1.0/tests/test_rodada_h2.py +125 -0
  53. zephirum-2.1.0/tests/test_runtime.py +104 -0
  54. zephirum-2.1.0/tests/test_selfverified.py +60 -0
  55. zephirum-2.1.0/tests/test_shot_auditor.py +44 -0
  56. zephirum-2.1.0/tests/test_witness.py +60 -0
  57. zephirum-2.1.0/tests/test_world3.py +23 -0
  58. zephirum-2.1.0/tests/test_worldscale.py +29 -0
  59. zephirum-2.1.0/tests/test_zqea_sig.py +36 -0
  60. zephirum-2.1.0/tests/test_zqea_verify.py +32 -0
zephirum-2.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Serena Solutions
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,291 @@
1
+ Metadata-Version: 2.4
2
+ Name: zephirum
3
+ Version: 2.1.0
4
+ Summary: ZEPHIRUM: Lisp-style quantum programming language with the ZYQL trivalent decision core (1/0/REFUSED)
5
+ Author-email: Reginaldo Gonçalves <builderquantunxia@gmail.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy
11
+ Requires-Dist: lark
12
+ Requires-Dist: qiskit>=2.6
13
+ Provides-Extra: hardware
14
+ Requires-Dist: qiskit-aer>=0.17; extra == "hardware"
15
+ Requires-Dist: qiskit-ibm-runtime>=0.50; extra == "hardware"
16
+ Provides-Extra: interop
17
+ Requires-Dist: cirq>=1.4; extra == "interop"
18
+ Provides-Extra: test
19
+ Requires-Dist: qiskit-qasm3-import>=0.5; extra == "test"
20
+ Dynamic: license-file
21
+
22
+ <p align="center"><img src="assets/social-preview-1280x640.png" alt="ZYQL: Exact-decision language" width="640"></p>
23
+
24
+ # ZEPHIRUM
25
+
26
+ **The quantum programming language with receipts.** ZYQL, its decision core, returns one of three verdicts — `1` (permitted), `0` (forbidden) or `REFUSED` (insufficient confidence) — and seals every decision in a verifiable receipt.
27
+
28
+ ![version](https://img.shields.io/badge/version-2.1.0-6e46b8)
29
+ ![license](https://img.shields.io/badge/license-MIT-blue)
30
+ ![kernel](https://img.shields.io/badge/kernel-statevector%20%5Bre%2Cim%5D%20float64-cyan)
31
+ ![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.23632019-gold)
32
+ [![CI](https://github.com/SerenaSolutions/zephirum-lang/actions/workflows/ci.yml/badge.svg)](https://github.com/SerenaSolutions/zephirum-lang/actions/workflows/ci.yml)
33
+ [![CodeQL](https://github.com/SerenaSolutions/zephirum-lang/actions/workflows/codeql.yml/badge.svg)](https://github.com/SerenaSolutions/zephirum-lang/actions/workflows/codeql.yml)
34
+ ![python](https://img.shields.io/badge/python-3.10%20%7C%203.11-blue)
35
+
36
+ **Contents** — [What it is](#what-it-is) · [Quickstart](#quickstart) · [Evidence](#evidence) · [Architecture](#architecture) · [Tests & reproducibility](#tests--reproducibility) · [Learn](#learn) · [Layout](#layout) · [Scope & honest limits](#honest-scope) · [Citation](#citation)
37
+
38
+ ---
39
+
40
+ ## What it is
41
+
42
+ ZEPHIRUM is a small quantum programming language. ZYQL is its decision algorithm:
43
+ every computational decision is trivalent — `1` (permitted), `0` (forbidden),
44
+ `REFUSED` (input-dependent or insufficient confidence) — and carries a sealed
45
+ receipt (SHA3-256 integrity seal, hash proves content integrity, not authorship).
46
+ ML-DSA-44 / FIPS 204 signatures are a DECLARED ROADMAP item — to be implemented
47
+ with an accredited module and HSM-held keys, never hand-rolled (see [docs/receipts.md](docs/receipts.md)).
48
+
49
+ Decisions are produced by Deutsch–Jozsa interference, one oracle call, with a
50
+ declared noise band (±0.15). Nothing executes silently: unknown syntax raises
51
+ an explicit error. Simulation mode is labeled as simulation.
52
+
53
+ - **Trivalent semantics** — refusal is a first-class verdict, not an exception.
54
+ - **Receipts by construction** — every decision can be sealed (Z-QEA, SHA3-256).
55
+ - **Hardware-verified** — measured on IBM Heron with job IDs published below.
56
+
57
+ ## Quickstart
58
+
59
+ ```bash
60
+ git clone https://github.com/SerenaSolutions/zephirum-lang.git && cd zephirum-lang
61
+ pip install -e . # or: PYTHONPATH=src
62
+ ```
63
+
64
+ ```python
65
+ from zyql_quantum_gate import ZYQLQuantumGate
66
+
67
+ gate = ZYQLQuantumGate(3, lambda x: x ^ 1) # balanced oracle
68
+ r = gate.run_quantum(shots=2048)
69
+ print(r["decision"], r.get("refusal_reason", "")) # REFUSED BALANCED_ORACLE
70
+ ```
71
+
72
+ ```bash
73
+ zyql-decide --oracle balanced --shots 512 # CLI runtime, Hoeffding error bound
74
+ python3 src/zyql_lisp.py examples/hello_world.zph # language front-end + sealed receipt
75
+ ```
76
+
77
+ The baptism of the language — a trivalent greeting, sealed by ZEPHIRUM itself:
78
+
79
+ ```lisp
80
+ ;; hello_world.zph — ZEPHIRUM v2 (Lisp)
81
+ (hello "Zephirum")
82
+ (seal "examples/hello_world.receipt.json")
83
+ ```
84
+
85
+ ```console
86
+ $ python3 src/zyql_lisp.py examples/hello_world.zph
87
+ Hello, Zephirum! | decisao = 1
88
+ SELO: <sha3-256 do recibo — carimbo temporal, varia por execucao>
89
+ ```
90
+
91
+ The `hello` form prints the greeting and returns the trivalent verdict `1`
92
+ (a greeting is always permitted). The `seal` form writes a Z-QEA receipt
93
+ (SHA3-256) of everything executed — the Hello World carries a sealed receipt,
94
+ as every decision in this house does. Source: [`examples/hello_world.zph`](examples/hello_world.zph).
95
+
96
+ ## Evidence
97
+
98
+ ![S3 fusion channels measured on IBM Heron](assets/proofs/s3-fusion-hardware.png)
99
+
100
+ *Real-data figure: theoretical braid curves (gold: B_R∘B_S, violet: B_S∘B_R) and the
101
+ points measured on IBM Heron `ibm_fez` — 98.1% vs 95.8%. The braid order is
102
+ distinguishable on silicon. Full detail: [docs/PROOFS.md](docs/PROOFS.md).*
103
+
104
+ ![Non-Abelian anyon braiding — AI art](assets/proofs/non-abelian-braids-art.png)
105
+
106
+ *Hero art (declared: AI-generated) — braided world-lines of non-Abelian anyons
107
+ converging into three fusion channels, the geometry the experiments probe.*
108
+
109
+ ### Proofs of concept — non-Abelian anyons (S3 qutrit miniature)
110
+
111
+ | Claim | Mode | Result | Receipt |
112
+ |-------|------|--------|---------|
113
+ | Fusion space is 3-dimensional (qutrit in 2 qubits) | noiseless | exact 1/3+1/3+1/3, forbidden channel vetoed | [sealed receipt](experiments/s3_qutrit_final_receipt.json) |
114
+ | Braiding is non-Abelian (order matters) | noiseless | commutator L1 = 6 exact; B_R∘B_S → ch2, B_S∘B_R → ch1 | same |
115
+ | Noiseless round | noiseless | exact-zero deviation vs theory (canonical rationals) | same |
116
+ | ZYQL trivalent decisions 1 / 0 / REFUSED | **IBM Heron** | **3/3 PASS** (job `dbbugbk24mrc73cif420`) | [battery receipt](experiments/zyql_hardware_battery.json) |
117
+ | Braid order measured on real hardware | **IBM Heron** | **98.1% vs 95.8%** (job `dbbueufi0auc73dtp7og`) | [master receipt](experiments/s3_qutrit_final_receipt.json) |
118
+ | **Shots-to-verdict efficiency** | **IBM Heron** | **256 shots** to a first-step verdict — **96.88% savings vs 8192** | receipt `28f406202e9d125a` (issue #40) |
119
+
120
+ Receipt seal (SHA3-256): `a44192463ea669564a3da51728c8577e59e5684c67cf2d48f7a95442d548476a` — verify it yourself: `python3 .github/actions/zqea-verify/zqea_verify.py experiments/s3_qutrit_final_receipt.json`
121
+ In language: [`examples/s3_qutrit.zph`](examples/s3_qutrit.zph).
122
+
123
+ Verified on real hardware (IBM Heron `ibm_fez`, cited as test laboratory with
124
+ verifiable job IDs; no endorsement claimed):
125
+
126
+ - Constant purpose: measured p(000)=0.9844 (job `db6ded84qg6s73c4jvug`)
127
+ - S3 qutrit miniature: fusion channels (qutrit-in-qubits) + braiding non-commutativity,
128
+ noiseless with exact-zero deviation and on hardware: ch2=98.1% (RS) vs ch1=95.8% (SR),
129
+ full ZYQL battery 3/3 PASS on `ibm_fez` (jobs `dbbueufi0auc73dtp7og`, `dbbugbk24mrc73cif420`;
130
+ Z-QEA receipt sealed, see `experiments/`)
131
+ - Balanced purpose: p(000)=0.0000, orthogonal outcome 93.9%
132
+ - Same-task confrontation vs textbook Qiskit (job `db6dklcvf2bc73d122t0`):
133
+ Zephyron transpiles to depth 2 / 0 two-qubit gates vs depth 10 / 3 CZ
134
+
135
+ Benchmark suite: [`benchmarks/`](benchmarks/) (public comparative benchmark, issue #28).
136
+
137
+ ## Architecture
138
+
139
+ ```
140
+ program (.zph, Lisp) ──► front-end parser ──► canonical decision form
141
+ │ │
142
+ │ Deutsch–Jozsa interference
143
+ │ (one oracle call, noise band ±0.15)
144
+ │ │
145
+ │ trivalent verdict: 1 / 0 / REFUSED
146
+ │ │
147
+ └──────────────► Z-QEA receipt ◄─────────────┘
148
+ (SHA3-256 seal + machine-readable refusal_reason)
149
+ ```
150
+
151
+ The repository ships the language heart only: kernel (state-vector, `[re,im]`
152
+ float64), OpenQASM 3 transpiler, trivalent gate, quantum types (no-cloning
153
+ enforced) and the receipt chain. See [Honest scope](#honest-scope).
154
+
155
+ The language:
156
+
157
+ ```
158
+ circuit bell {
159
+ qubit[2] q;
160
+ H q[0];
161
+ CNOT q[0] -> q[1];
162
+ }
163
+ ```
164
+
165
+ ## Tests & reproducibility
166
+
167
+ - **13 test suites** (`tests/`): canonical rational battery, certified decisions,
168
+ frontiers, KEM, Lisp regression, meta, multiple-testing correction,
169
+ runtime, shot auditor, Z-QEA verifier, hardware rounds.
170
+ - **CI matrix**: Python 3.10 and 3.11 on every push and pull request, with
171
+ `PYTHONHASHSEED=0` for reproducible runs; **CodeQL** static analysis;
172
+ **signed releases with build provenance** (SLSA attestation); a dedicated
173
+ **ZQ-GATE self-test** workflow.
174
+ - **Statistical discipline**: multiple-comparison correction is part of the test
175
+ battery — verdicts are not claimed on uncorrected p-values.
176
+ - **Verifiable by construction**: every hardware claim above points to a sealed
177
+ receipt and a job ID; receipts are re-verifiable with
178
+ `.github/actions/zqea-verify/zqea_verify.py`.
179
+ - Published testing roadmap (fuzzing the front-end, unitary-equivalence
180
+ assertions, executed notebooks, coverage gate): tracked in issues.
181
+
182
+ ## Learn
183
+
184
+ - [docs/LEARN.md](docs/LEARN.md) — progressive tutorial: first decision to sealed hardware receipts
185
+ - [docs/COOKBOOK.md](docs/COOKBOOK.md) — copy-paste recipes, every one executed and recorded
186
+ - [docs/MIGRATION.md](docs/MIGRATION.md) — embedding Zephirum in Python, C and CI pipelines
187
+ - [docs/PROOFS.md](docs/PROOFS.md) — hardware proofs, figures and receipts
188
+ - [docs/MATURITY.md](docs/MATURITY.md) — component-by-component maturity
189
+
190
+ ## Layout
191
+
192
+ - `src/` — kernel (state-vector), OpenQASM 3 transpiler, trivalent gate,
193
+ quantum types (no-cloning enforced), neural RAG layer, runtime (`zyql_runtime`)
194
+ - `tests/` — 13 suites (see above)
195
+ - `examples/` — `hello_world.zph`, `bell.zph`, `grover.zph`, `dj_constant.zph`, `s3_qutrit.zph`
196
+ - `benchmarks/` — public comparative benchmark suite
197
+ - `notebooks/` — scientific presentation layer
198
+ - `experiments/` — hardware rounds and sealed receipts (job IDs)
199
+ - `docs/` — language reference, receipt specification, proofs, maturity, dossier
200
+ - `playground/` — browser playground assets · `site/` — docs site · `paper/` — preprint sources
201
+ - `zephirum-vscode/` — VS Code extension for `.zph`
202
+ - `docker/` — reproducible container
203
+
204
+ ## Technical Dossier
205
+
206
+ A consolidated, receipt-cited dossier of the project — what it is, what has been measured on real quantum hardware, the public m50 commitment, Industry 5.0 applications and the declared honest limits: **[docs/DOSSIER.md](docs/DOSSIER.md)**
207
+
208
+
209
+ ## Self-verified device decision (new, 2026-10-29)
210
+
211
+ A decisão trivalente agora roda **na QPU** com a própria QPU certificando a execução:
212
+
213
+ - **Auto-verificação (espelho C†)** no mesmo job — taxa de zeros medida vira `selfcheck_p0` no recibo; abaixo do limiar ⇒ `REFUSED`.
214
+ - **Evidência sequencial** com regra de parada (alpha-spending) declarada **antes** da execução.
215
+ - **Recibo** com protocolo + contagens por lote + `job_id`, selado SHA3-256.
216
+
217
+ | Oráculo | Veredito | p0 | selfcheck | Shots | job_id (ibm_fez) |
218
+ |---|---|---|---|---|---|
219
+ | constante | **1** | 0.992 | 0.969 | 128 | `dbhm3ao1h92s73821mm0` |
220
+ | balanceado | **0** | 0.016 | 0.992 | 128 | `dbhm3ik2d77s739d10j0` |
221
+
222
+ Especificação completa: **[docs/SELFVERIFIED.md](docs/SELFVERIFIED.md)** · recibos em `experiments/selfcheck_ibm_fez_20261029/`.
223
+
224
+
225
+ ## Refusal witness — abstenção com prova (new, 2026-10-29)
226
+
227
+ `REFUSED` deixa de ser "não sei" e vira "não sei **porque** a evidência não fecha":
228
+ a TVD entre a distribuição ideal (referência exata) e a medida no dispositivo tem
229
+ intervalo de confiança declarado **antes** da execução.
230
+
231
+ | Dispositivo | Shots | TVD | Janela | ε | Veredito | job_id |
232
+ |---|---|---|---|---|---|---|
233
+ | ibm_fez | 4096 | 0.0317 | [0.000, 0.104] | 0.10 | **REFUSED** | `dbhn296ne4hc73bd7u1g` |
234
+ | ibm_marrakesh | 8192 | 0.0198 | [0.000, 0.071] | 0.10 | **1 CERTIFICADO** | `dbhn8hs2d77s739d32lg` |
235
+
236
+ O primeiro voo absteve; com o dobro de evidência, certificou. Especificação:
237
+ **[docs/WITNESS.md](docs/WITNESS.md)** · recibos em `experiments/witness_20261029/`.
238
+
239
+
240
+ ## Hardware protocols (2026-10-29)
241
+
242
+ Protocolos pré-declarados, executados no plano Open com recibo selado
243
+ (`docs/PROTOCOLS.md`):
244
+
245
+ | Protocolo | Medida | Resultado | job_id |
246
+ |---|---|---|---|
247
+ | P-10 fronteira clássica×hardware | TVD vs ideal, n=3..5 | 0.0139 / 0.0188 / 0.0183 | `dbhp6ks2d77s739d692g` |
248
+ | P-08 ZNE vs C† | p0 n=4, com/sem ZNE | 0.0197 → **0.0116** (−41%) | `dbhp6ok2d77s739d6990` |
249
+
250
+
251
+ ## Apps v1 (2026-10-29)
252
+
253
+ - **AuditKit (CPA-01)** — certificacao de entropia quantica com recibo: hardware
254
+ `ibm_marrakesh`, 4096 bits, veredito **1** (job `dbhpaomne4hc73bdbp7g`).
255
+ - **Quantum Regression Seal (QRS-01)** — gate de CI/CD que pega miscompilacao
256
+ silenciosa por comparacao unitaria; action reutilizavel no repo.
257
+
258
+ Detalhes: **[docs/APPS.md](docs/APPS.md)**
259
+
260
+ ## Honest scope
261
+
262
+ This repository contains the language heart only: kernel, types, gate, receipts.
263
+ It does not contain, and will never contain, the Zephirum OS distribution,
264
+ bootloader, installer, or activation keys. Simulations are labeled as
265
+ simulations; without error correction, useful executions are bounded well
266
+ under 20 qubits.
267
+
268
+ ## Runtime de produção (v1.8.0)
269
+
270
+ ```python
271
+ from zyql_runtime import decide, Verdict
272
+ r = decide(lambda x: x & 1, n=3, shots=512) # -> Verdict.REFUSED
273
+ r.error_bound # limite de erro Hoeffding declarado
274
+ ```
275
+ CLI: `zyql-decide --oracle balanced --shots 512`
276
+
277
+ ## ⚠️ Desambiguação / Disambiguation — no PyPI package exists
278
+
279
+ Instruções circulando na web citam `pip install zephirum-quantum-plugin` e um
280
+ repositório `SerenaSolutions/zephirum`. **Nenhum dos dois existe.** Este
281
+ (`zephirum-lang`) é o único repositório oficial. Nenhum pacote da ZEPHIRUM está
282
+ publicado no PyPI — qualquer instrução citando esse pacote não vem da casa.
283
+
284
+ ## Citation
285
+
286
+ See `CITATION.cff`. Software deposit: Zenodo concept DOI 10.5281/zenodo.23632019
287
+ (code MIT, companion thesis CC BY-NC-ND 4.0), (c) Serena Solutions.
288
+
289
+ ## License
290
+
291
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,270 @@
1
+ <p align="center"><img src="assets/social-preview-1280x640.png" alt="ZYQL: Exact-decision language" width="640"></p>
2
+
3
+ # ZEPHIRUM
4
+
5
+ **The quantum programming language with receipts.** ZYQL, its decision core, returns one of three verdicts — `1` (permitted), `0` (forbidden) or `REFUSED` (insufficient confidence) — and seals every decision in a verifiable receipt.
6
+
7
+ ![version](https://img.shields.io/badge/version-2.1.0-6e46b8)
8
+ ![license](https://img.shields.io/badge/license-MIT-blue)
9
+ ![kernel](https://img.shields.io/badge/kernel-statevector%20%5Bre%2Cim%5D%20float64-cyan)
10
+ ![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.23632019-gold)
11
+ [![CI](https://github.com/SerenaSolutions/zephirum-lang/actions/workflows/ci.yml/badge.svg)](https://github.com/SerenaSolutions/zephirum-lang/actions/workflows/ci.yml)
12
+ [![CodeQL](https://github.com/SerenaSolutions/zephirum-lang/actions/workflows/codeql.yml/badge.svg)](https://github.com/SerenaSolutions/zephirum-lang/actions/workflows/codeql.yml)
13
+ ![python](https://img.shields.io/badge/python-3.10%20%7C%203.11-blue)
14
+
15
+ **Contents** — [What it is](#what-it-is) · [Quickstart](#quickstart) · [Evidence](#evidence) · [Architecture](#architecture) · [Tests & reproducibility](#tests--reproducibility) · [Learn](#learn) · [Layout](#layout) · [Scope & honest limits](#honest-scope) · [Citation](#citation)
16
+
17
+ ---
18
+
19
+ ## What it is
20
+
21
+ ZEPHIRUM is a small quantum programming language. ZYQL is its decision algorithm:
22
+ every computational decision is trivalent — `1` (permitted), `0` (forbidden),
23
+ `REFUSED` (input-dependent or insufficient confidence) — and carries a sealed
24
+ receipt (SHA3-256 integrity seal, hash proves content integrity, not authorship).
25
+ ML-DSA-44 / FIPS 204 signatures are a DECLARED ROADMAP item — to be implemented
26
+ with an accredited module and HSM-held keys, never hand-rolled (see [docs/receipts.md](docs/receipts.md)).
27
+
28
+ Decisions are produced by Deutsch–Jozsa interference, one oracle call, with a
29
+ declared noise band (±0.15). Nothing executes silently: unknown syntax raises
30
+ an explicit error. Simulation mode is labeled as simulation.
31
+
32
+ - **Trivalent semantics** — refusal is a first-class verdict, not an exception.
33
+ - **Receipts by construction** — every decision can be sealed (Z-QEA, SHA3-256).
34
+ - **Hardware-verified** — measured on IBM Heron with job IDs published below.
35
+
36
+ ## Quickstart
37
+
38
+ ```bash
39
+ git clone https://github.com/SerenaSolutions/zephirum-lang.git && cd zephirum-lang
40
+ pip install -e . # or: PYTHONPATH=src
41
+ ```
42
+
43
+ ```python
44
+ from zyql_quantum_gate import ZYQLQuantumGate
45
+
46
+ gate = ZYQLQuantumGate(3, lambda x: x ^ 1) # balanced oracle
47
+ r = gate.run_quantum(shots=2048)
48
+ print(r["decision"], r.get("refusal_reason", "")) # REFUSED BALANCED_ORACLE
49
+ ```
50
+
51
+ ```bash
52
+ zyql-decide --oracle balanced --shots 512 # CLI runtime, Hoeffding error bound
53
+ python3 src/zyql_lisp.py examples/hello_world.zph # language front-end + sealed receipt
54
+ ```
55
+
56
+ The baptism of the language — a trivalent greeting, sealed by ZEPHIRUM itself:
57
+
58
+ ```lisp
59
+ ;; hello_world.zph — ZEPHIRUM v2 (Lisp)
60
+ (hello "Zephirum")
61
+ (seal "examples/hello_world.receipt.json")
62
+ ```
63
+
64
+ ```console
65
+ $ python3 src/zyql_lisp.py examples/hello_world.zph
66
+ Hello, Zephirum! | decisao = 1
67
+ SELO: <sha3-256 do recibo — carimbo temporal, varia por execucao>
68
+ ```
69
+
70
+ The `hello` form prints the greeting and returns the trivalent verdict `1`
71
+ (a greeting is always permitted). The `seal` form writes a Z-QEA receipt
72
+ (SHA3-256) of everything executed — the Hello World carries a sealed receipt,
73
+ as every decision in this house does. Source: [`examples/hello_world.zph`](examples/hello_world.zph).
74
+
75
+ ## Evidence
76
+
77
+ ![S3 fusion channels measured on IBM Heron](assets/proofs/s3-fusion-hardware.png)
78
+
79
+ *Real-data figure: theoretical braid curves (gold: B_R∘B_S, violet: B_S∘B_R) and the
80
+ points measured on IBM Heron `ibm_fez` — 98.1% vs 95.8%. The braid order is
81
+ distinguishable on silicon. Full detail: [docs/PROOFS.md](docs/PROOFS.md).*
82
+
83
+ ![Non-Abelian anyon braiding — AI art](assets/proofs/non-abelian-braids-art.png)
84
+
85
+ *Hero art (declared: AI-generated) — braided world-lines of non-Abelian anyons
86
+ converging into three fusion channels, the geometry the experiments probe.*
87
+
88
+ ### Proofs of concept — non-Abelian anyons (S3 qutrit miniature)
89
+
90
+ | Claim | Mode | Result | Receipt |
91
+ |-------|------|--------|---------|
92
+ | Fusion space is 3-dimensional (qutrit in 2 qubits) | noiseless | exact 1/3+1/3+1/3, forbidden channel vetoed | [sealed receipt](experiments/s3_qutrit_final_receipt.json) |
93
+ | Braiding is non-Abelian (order matters) | noiseless | commutator L1 = 6 exact; B_R∘B_S → ch2, B_S∘B_R → ch1 | same |
94
+ | Noiseless round | noiseless | exact-zero deviation vs theory (canonical rationals) | same |
95
+ | ZYQL trivalent decisions 1 / 0 / REFUSED | **IBM Heron** | **3/3 PASS** (job `dbbugbk24mrc73cif420`) | [battery receipt](experiments/zyql_hardware_battery.json) |
96
+ | Braid order measured on real hardware | **IBM Heron** | **98.1% vs 95.8%** (job `dbbueufi0auc73dtp7og`) | [master receipt](experiments/s3_qutrit_final_receipt.json) |
97
+ | **Shots-to-verdict efficiency** | **IBM Heron** | **256 shots** to a first-step verdict — **96.88% savings vs 8192** | receipt `28f406202e9d125a` (issue #40) |
98
+
99
+ Receipt seal (SHA3-256): `a44192463ea669564a3da51728c8577e59e5684c67cf2d48f7a95442d548476a` — verify it yourself: `python3 .github/actions/zqea-verify/zqea_verify.py experiments/s3_qutrit_final_receipt.json`
100
+ In language: [`examples/s3_qutrit.zph`](examples/s3_qutrit.zph).
101
+
102
+ Verified on real hardware (IBM Heron `ibm_fez`, cited as test laboratory with
103
+ verifiable job IDs; no endorsement claimed):
104
+
105
+ - Constant purpose: measured p(000)=0.9844 (job `db6ded84qg6s73c4jvug`)
106
+ - S3 qutrit miniature: fusion channels (qutrit-in-qubits) + braiding non-commutativity,
107
+ noiseless with exact-zero deviation and on hardware: ch2=98.1% (RS) vs ch1=95.8% (SR),
108
+ full ZYQL battery 3/3 PASS on `ibm_fez` (jobs `dbbueufi0auc73dtp7og`, `dbbugbk24mrc73cif420`;
109
+ Z-QEA receipt sealed, see `experiments/`)
110
+ - Balanced purpose: p(000)=0.0000, orthogonal outcome 93.9%
111
+ - Same-task confrontation vs textbook Qiskit (job `db6dklcvf2bc73d122t0`):
112
+ Zephyron transpiles to depth 2 / 0 two-qubit gates vs depth 10 / 3 CZ
113
+
114
+ Benchmark suite: [`benchmarks/`](benchmarks/) (public comparative benchmark, issue #28).
115
+
116
+ ## Architecture
117
+
118
+ ```
119
+ program (.zph, Lisp) ──► front-end parser ──► canonical decision form
120
+ │ │
121
+ │ Deutsch–Jozsa interference
122
+ │ (one oracle call, noise band ±0.15)
123
+ │ │
124
+ │ trivalent verdict: 1 / 0 / REFUSED
125
+ │ │
126
+ └──────────────► Z-QEA receipt ◄─────────────┘
127
+ (SHA3-256 seal + machine-readable refusal_reason)
128
+ ```
129
+
130
+ The repository ships the language heart only: kernel (state-vector, `[re,im]`
131
+ float64), OpenQASM 3 transpiler, trivalent gate, quantum types (no-cloning
132
+ enforced) and the receipt chain. See [Honest scope](#honest-scope).
133
+
134
+ The language:
135
+
136
+ ```
137
+ circuit bell {
138
+ qubit[2] q;
139
+ H q[0];
140
+ CNOT q[0] -> q[1];
141
+ }
142
+ ```
143
+
144
+ ## Tests & reproducibility
145
+
146
+ - **13 test suites** (`tests/`): canonical rational battery, certified decisions,
147
+ frontiers, KEM, Lisp regression, meta, multiple-testing correction,
148
+ runtime, shot auditor, Z-QEA verifier, hardware rounds.
149
+ - **CI matrix**: Python 3.10 and 3.11 on every push and pull request, with
150
+ `PYTHONHASHSEED=0` for reproducible runs; **CodeQL** static analysis;
151
+ **signed releases with build provenance** (SLSA attestation); a dedicated
152
+ **ZQ-GATE self-test** workflow.
153
+ - **Statistical discipline**: multiple-comparison correction is part of the test
154
+ battery — verdicts are not claimed on uncorrected p-values.
155
+ - **Verifiable by construction**: every hardware claim above points to a sealed
156
+ receipt and a job ID; receipts are re-verifiable with
157
+ `.github/actions/zqea-verify/zqea_verify.py`.
158
+ - Published testing roadmap (fuzzing the front-end, unitary-equivalence
159
+ assertions, executed notebooks, coverage gate): tracked in issues.
160
+
161
+ ## Learn
162
+
163
+ - [docs/LEARN.md](docs/LEARN.md) — progressive tutorial: first decision to sealed hardware receipts
164
+ - [docs/COOKBOOK.md](docs/COOKBOOK.md) — copy-paste recipes, every one executed and recorded
165
+ - [docs/MIGRATION.md](docs/MIGRATION.md) — embedding Zephirum in Python, C and CI pipelines
166
+ - [docs/PROOFS.md](docs/PROOFS.md) — hardware proofs, figures and receipts
167
+ - [docs/MATURITY.md](docs/MATURITY.md) — component-by-component maturity
168
+
169
+ ## Layout
170
+
171
+ - `src/` — kernel (state-vector), OpenQASM 3 transpiler, trivalent gate,
172
+ quantum types (no-cloning enforced), neural RAG layer, runtime (`zyql_runtime`)
173
+ - `tests/` — 13 suites (see above)
174
+ - `examples/` — `hello_world.zph`, `bell.zph`, `grover.zph`, `dj_constant.zph`, `s3_qutrit.zph`
175
+ - `benchmarks/` — public comparative benchmark suite
176
+ - `notebooks/` — scientific presentation layer
177
+ - `experiments/` — hardware rounds and sealed receipts (job IDs)
178
+ - `docs/` — language reference, receipt specification, proofs, maturity, dossier
179
+ - `playground/` — browser playground assets · `site/` — docs site · `paper/` — preprint sources
180
+ - `zephirum-vscode/` — VS Code extension for `.zph`
181
+ - `docker/` — reproducible container
182
+
183
+ ## Technical Dossier
184
+
185
+ A consolidated, receipt-cited dossier of the project — what it is, what has been measured on real quantum hardware, the public m50 commitment, Industry 5.0 applications and the declared honest limits: **[docs/DOSSIER.md](docs/DOSSIER.md)**
186
+
187
+
188
+ ## Self-verified device decision (new, 2026-10-29)
189
+
190
+ A decisão trivalente agora roda **na QPU** com a própria QPU certificando a execução:
191
+
192
+ - **Auto-verificação (espelho C†)** no mesmo job — taxa de zeros medida vira `selfcheck_p0` no recibo; abaixo do limiar ⇒ `REFUSED`.
193
+ - **Evidência sequencial** com regra de parada (alpha-spending) declarada **antes** da execução.
194
+ - **Recibo** com protocolo + contagens por lote + `job_id`, selado SHA3-256.
195
+
196
+ | Oráculo | Veredito | p0 | selfcheck | Shots | job_id (ibm_fez) |
197
+ |---|---|---|---|---|---|
198
+ | constante | **1** | 0.992 | 0.969 | 128 | `dbhm3ao1h92s73821mm0` |
199
+ | balanceado | **0** | 0.016 | 0.992 | 128 | `dbhm3ik2d77s739d10j0` |
200
+
201
+ Especificação completa: **[docs/SELFVERIFIED.md](docs/SELFVERIFIED.md)** · recibos em `experiments/selfcheck_ibm_fez_20261029/`.
202
+
203
+
204
+ ## Refusal witness — abstenção com prova (new, 2026-10-29)
205
+
206
+ `REFUSED` deixa de ser "não sei" e vira "não sei **porque** a evidência não fecha":
207
+ a TVD entre a distribuição ideal (referência exata) e a medida no dispositivo tem
208
+ intervalo de confiança declarado **antes** da execução.
209
+
210
+ | Dispositivo | Shots | TVD | Janela | ε | Veredito | job_id |
211
+ |---|---|---|---|---|---|---|
212
+ | ibm_fez | 4096 | 0.0317 | [0.000, 0.104] | 0.10 | **REFUSED** | `dbhn296ne4hc73bd7u1g` |
213
+ | ibm_marrakesh | 8192 | 0.0198 | [0.000, 0.071] | 0.10 | **1 CERTIFICADO** | `dbhn8hs2d77s739d32lg` |
214
+
215
+ O primeiro voo absteve; com o dobro de evidência, certificou. Especificação:
216
+ **[docs/WITNESS.md](docs/WITNESS.md)** · recibos em `experiments/witness_20261029/`.
217
+
218
+
219
+ ## Hardware protocols (2026-10-29)
220
+
221
+ Protocolos pré-declarados, executados no plano Open com recibo selado
222
+ (`docs/PROTOCOLS.md`):
223
+
224
+ | Protocolo | Medida | Resultado | job_id |
225
+ |---|---|---|---|
226
+ | P-10 fronteira clássica×hardware | TVD vs ideal, n=3..5 | 0.0139 / 0.0188 / 0.0183 | `dbhp6ks2d77s739d692g` |
227
+ | P-08 ZNE vs C† | p0 n=4, com/sem ZNE | 0.0197 → **0.0116** (−41%) | `dbhp6ok2d77s739d6990` |
228
+
229
+
230
+ ## Apps v1 (2026-10-29)
231
+
232
+ - **AuditKit (CPA-01)** — certificacao de entropia quantica com recibo: hardware
233
+ `ibm_marrakesh`, 4096 bits, veredito **1** (job `dbhpaomne4hc73bdbp7g`).
234
+ - **Quantum Regression Seal (QRS-01)** — gate de CI/CD que pega miscompilacao
235
+ silenciosa por comparacao unitaria; action reutilizavel no repo.
236
+
237
+ Detalhes: **[docs/APPS.md](docs/APPS.md)**
238
+
239
+ ## Honest scope
240
+
241
+ This repository contains the language heart only: kernel, types, gate, receipts.
242
+ It does not contain, and will never contain, the Zephirum OS distribution,
243
+ bootloader, installer, or activation keys. Simulations are labeled as
244
+ simulations; without error correction, useful executions are bounded well
245
+ under 20 qubits.
246
+
247
+ ## Runtime de produção (v1.8.0)
248
+
249
+ ```python
250
+ from zyql_runtime import decide, Verdict
251
+ r = decide(lambda x: x & 1, n=3, shots=512) # -> Verdict.REFUSED
252
+ r.error_bound # limite de erro Hoeffding declarado
253
+ ```
254
+ CLI: `zyql-decide --oracle balanced --shots 512`
255
+
256
+ ## ⚠️ Desambiguação / Disambiguation — no PyPI package exists
257
+
258
+ Instruções circulando na web citam `pip install zephirum-quantum-plugin` e um
259
+ repositório `SerenaSolutions/zephirum`. **Nenhum dos dois existe.** Este
260
+ (`zephirum-lang`) é o único repositório oficial. Nenhum pacote da ZEPHIRUM está
261
+ publicado no PyPI — qualquer instrução citando esse pacote não vem da casa.
262
+
263
+ ## Citation
264
+
265
+ See `CITATION.cff`. Software deposit: Zenodo concept DOI 10.5281/zenodo.23632019
266
+ (code MIT, companion thesis CC BY-NC-ND 4.0), (c) Serena Solutions.
267
+
268
+ ## License
269
+
270
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "zephirum"
7
+ version = "2.1.0"
8
+ description = "ZEPHIRUM: Lisp-style quantum programming language with the ZYQL trivalent decision core (1/0/REFUSED)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ dependencies = ["numpy", "lark", "qiskit>=2.6"]
14
+ authors = [{name = "Reginaldo Gonçalves", email = "builderquantunxia@gmail.com"}]
15
+
16
+ [project.optional-dependencies]
17
+ # execucao em hardware real e simulacao ruidosa (Qiskit Runtime / Aer)
18
+ hardware = ["qiskit-aer>=0.17", "qiskit-ibm-runtime>=0.50"]
19
+ # paridade de semantica com o ecossistema Google
20
+ interop = ["cirq>=1.4"]
21
+ # verificacao de ida e volta OpenQASM 3 (usada apenas pelos testes)
22
+ test = ["qiskit-qasm3-import>=0.5"]
23
+
24
+ [project.scripts]
25
+ zqgate = "zqgate.cli:main"
26
+ zyql-decide = "zyql_runtime:main"
27
+
28
+ [tool.setuptools]
29
+ package-dir = {"" = "src"}
30
+ packages = ["zqgate"]
31
+ py-modules = ["battery_ci", "oq3", "quantum_types", "shot_auditor", "zkernel", "zqea_kem", "zqea_sig", "zquantum", "zyql_auditkit", "zyql_cirq", "zyql_lisp", "zyql_llm_compress", "zyql_mps", "zyql_protocols", "zyql_quantum_gate", "zyql_rag_layer", "zyql_robust", "zyql_runtime", "zyql_selfverified", "zyql_witness", "zyql_world3", "zyql_worldscale", "zyql_zne", "zyqml_core"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+