"""ATON QAI — Public Interactive Photonic Workbench (app.py). Public-safe, self-contained Gradio Space for https://huggingface.co/spaces/ATON-QAI/QAI-Photonic-Workbench. Implements standard open quantum-optical equations for two-photon Hong-Ou-Mandel interference and Mach-Zehnder meshes. """ from __future__ import annotations import hashlib import json import math from typing import Dict, List, Tuple import gradio as gr PROGRAMS: Dict[str, Dict[str, str]] = { "HOM-01: Hong-Ou-Mandel Two-Photon Dip (2 Modes)": { "family": "HOM_INTERFERENCE", "modes": "2", "photons": "2", "code": ( "qai 1.0;\n" "profile photonic.dv.linear;\n\n" "experiment hom_dip(theta: angle = pi / 2) {\n" " let m: modes<2, fock> = prepare fock [1, 1];\n" " let (a, b) = sym_mzi(theta)(m[0], m[1]);\n" " emit measure pnr (a, b);\n" "}\n" ), "property_checked": "Unitary trace conservation & balanced HOM zero-coincidence invariant", }, "MZI-02: Single-Photon Mach-Zehnder Phase Sweep (2 Modes)": { "family": "CLEMENTS_RECK_MZI", "modes": "2", "photons": "1", "code": ( "qai 1.0;\n" "profile photonic.dv.linear;\n\n" "experiment mzi_fringe(theta: angle = pi / 3) {\n" " let m: modes<2, fock> = prepare fock [1, 0];\n" " let (a, b) = sym_mzi(theta)(m[0], m[1]);\n" " emit measure pnr (a, b);\n" "}\n" ), "property_checked": "Probability simplex normalization & single-photon fringe visibility", }, "CLEMENTS-04: 4-Mode Universal Interferometer Mesh (4 Modes, 2 Photons)": { "family": "BOSON_SAMPLING", "modes": "4", "photons": "2", "code": ( "qai 1.0;\n" "profile photonic.dv.linear;\n\n" "experiment clements_4mode(theta: angle = pi / 2) {\n" " let m: modes<4, fock> = prepare fock [1, 1, 0, 0];\n" " let u = clements_mesh<4>(theta);\n" " emit measure pnr u(m);\n" "}\n" ), "property_checked": "Total Fock photon-number conservation & partial-distinguishability bounds", }, }