## Phase 111: Kalika Interoperability & Verification — Data Formats, Physics Interchange Protocols, Cross-CAS Bridges, Computation Verification & Reproducibility Infrastructure

Closes the interoperability gap: Kalika must speak every data format in
theoretical physics and mathematics, bridge to every major CAS, and provide the
verification infrastructure that turns computation into trusted knowledge. The
reproducibility crisis in theoretical physics (retractions, unchecked
calculations, software-version-dependent results) makes verified, reproducible
computation a moral imperative, not just a feature. Informed by Matthew
Schwartz's "vibe physics" experiment showing AI can compute at graduate level
but cannot verify its own work — verification must be a first-class system
capability, not an afterthought.

---

### 111.1 Physics Data Format Support

#### 111.1.1 HEP Event & Spectrum Formats

- [x] **111.1.1.1** Implement SLHA/SLHA2 parser and writer: read/write SUSY Les
      Houches Accord files — BLOCK structures (MASS, NMIX, UMIX, VMIX, STOPMIX,
      SBOTMIX, STAUMIX, ALPHA, HMIX, GAUGE, MSoft, Au, Ad, Ae, Yu, Yd, Ye),
      DECAY tables with branching ratios, and SLHA2 extensions (CVHMIX, IMVHMIX
      for CP violation, RPV blocks, NMSSM blocks) — enabling Kalika to consume
      spectra from SPheno/SoftSUSY/FlexibleSUSY and feed them to
      decay/cross-section computations
- [x] **111.1.1.2** Implement UFO 2.0 model reader: parse Python-based UFO model
      directories (particles.py, vertices.py, parameters.py, couplings.py,
      lorentz.py, propagators.py, decays.py, form_factors.py) to extract
      complete Feynman rules for any BSM model — enabling Kalika's Feynman
      engine (Phase 101) to compute with FeynRules/SARAH-generated models
      without reimplementation
- [x] **111.1.1.3** Implement LHE/LHEF reader and writer: parse Les Houches
      Event Format XML (init block for run-level info, event blocks with
      particle lines: IDUP, ISTUP, MOTHUP, ICOLUP, PUP, VTIMUP, SPINUP) and
      write events from Kalika's cross-section calculations — for interfacing
      with parton showers
- [x] **111.1.1.4** Implement HepMC3 reader: parse HepMC3 ASCII and ROOT-binary
      event records (GenEvent, GenVertex, GenParticle with four-momenta, PDG
      IDs, status codes, color flow, weight vectors) — for analyzing Monte Carlo
      events from Pythia/Herwig/Sherpa
- [x] **111.1.1.5** Implement WCxf reader and writer: parse/produce Wilson
      Coefficient Exchange Format JSON/YAML (EFT name, basis, scale, coefficient
      dictionary with complex values) — for interoperability with wilson,
      flavio, smelli, DsixTools in the EFT phenomenology ecosystem
- [x] **111.1.1.6** Implement LHAPDF grid reader: parse LHAPDF6 grid files
      (.info metadata + .dat member grids with x-Q² grid points per flavor) to
      evaluate parton distribution functions f_a(x, Q²) for any parton flavor a
      at arbitrary (x, Q²) via interpolation — essential for any cross-section
      calculation at hadron colliders
- [x] **111.1.1.7** Implement PDG Monte Carlo particle numbering: full
      implementation of the PDG scheme (quarks 1-6, leptons 11-16, gauge bosons
      21-24, Higgs 25, SUSY particles, hadrons via quark-content encoding,
      nuclei via 10LZZZAAAI) with name ↔ ID conversion and particle property
      lookup — the universal particle identification standard

#### 111.1.2 Scientific Data Formats

- [x] **111.1.2.1** Implement HDF5 reader/writer: read and write HDF5 files
      (groups, datasets, attributes, compound types, variable-length data) using
      the `hdf5` npm package or Rust `hdf5-rs` crate — the universal scientific
      data format used by LIGO/Virgo (GW strain data), lattice QCD ensembles,
      N-body simulations, and ML datasets
- [x] **111.1.2.2** Implement ROOT file reader (via `uproot` pattern): parse
      ROOT TTree/RNTuple files by implementing the ROOT binary format directly
      (basket/page reading, compression handling: zlib, LZ4, ZSTD, LZMA) —
      matching Python `uproot`'s approach of native format parsing without ROOT
      dependency. Critical for accessing LHC experimental data
- [x] **111.1.2.3** Implement FITS reader: parse FITS (Flexible Image Transport
      System) files — primary and extension HDUs, image arrays, binary tables,
      ASCII tables, with WCS (World Coordinate System) header parsing — for
      astronomical data from telescopes, surveys, and CMB experiments
- [x] **111.1.2.4** Implement YODA reader/writer: parse/produce YODA
      histogram/scatter objects (Histo1D, Histo2D, Profile1D, Scatter2D with bin
      edges, sumW, sumW2, sumWX) — for comparing Kalika's theoretical
      predictions against Monte Carlo validation via Rivet
- [x] **111.1.2.5** Implement HEPData YAML reader: parse HEPData submission
      format (independent/dependent variables with asymmetric uncertainties,
      qualifiers, keywords) — for importing published experimental measurements
      for theory-experiment comparison

#### 111.1.3 Mathematical Interchange Formats

- [x] **111.1.3.1** Implement OpenMath 2.0 reader/writer: parse and produce
      OpenMath XML (OMS, OMA, OMBIND, OMATTR, OMV, OMI, OMF, OMSTR, OMB, OME,
      OMFOREIGN) with Content Dictionary symbol resolution — the lingua franca
      for CAS interoperability
- [x] **111.1.3.2** Implement Content MathML reader: parse semantic Content
      MathML (apply, ci, cn, csymbol, bind, bvar, condition,
      domainofapplication) and convert to Kalika Expr AST — for importing
      mathematical content from web documents, OMDoc, and other MathML-producing
      tools
- [x] **111.1.3.3** Implement TPTP format writer: export Kalika propositions
      (universally quantified equalities, inequalities, logical combinations) as
      TPTP FOF/TFF/THF problems — for dispatching proof obligations to automated
      theorem provers (Vampire, E, SPASS)
- [x] **111.1.3.4** Implement SMT-LIB 2.6 writer: export decidable Kalika
      propositions as SMT-LIB benchmarks (declare-sort, declare-fun, assert,
      check-sat, get-model) in appropriate logics (QF_LRA, QF_NRA, QF_LIA,
      QF_NIA, AUFLIRA) — for dispatching to Z3/CVC5
- [x] **111.1.3.5** Implement SCSCP client: connect to SCSCP-compliant CAS
      servers (GAP, SINGULAR, Maple) via TCP, send computation requests as
      OpenMath procedure calls, receive results — enabling Kalika to call out to
      specialized systems for computations they excel at (GAP for group theory,
      SINGULAR for commutative algebra)

---

### 111.2 Formal Proof Format Import

- [x] **111.2.1.1** Implement Lean 4 source parser: parse `.lean` files to
      extract: theorem statements (with types), proof terms (tactic proofs and
      term-mode proofs), definition bodies, import declarations, and namespace
      structure — converting Lean's syntax tree to Kalika's knowledge graph
      entries
- [x] **111.2.1.2** Implement Coq `.v` file parser: extract theorem statements,
      proof scripts (tactic sequences), definition bodies, and module structure
      from Coq vernacular files — for importing MathComp formalized algebra
- [x] **111.2.1.3** Implement Isabelle `.thy` file parser: extract lemma/theorem
      statements, Isar proof structures, definition bodies, and theory imports —
      for importing Archive of Formal Proofs content
- [x] **111.2.1.4** Implement Metamath `.mm` file parser: extract axioms,
      theorem labels, proof steps (compressed proof format), and the dependency
      graph — for importing the highly verified set.mm database
- [x] **111.2.1.5** Implement cross-prover theorem deduplication: given the same
      mathematical result formalized in multiple systems (Lean, Coq, Isabelle),
      identify and link them as the "same" theorem in the knowledge graph —
      using statement-level semantic matching (normalize types, compare modulo
      notation differences)

---

### 111.3 Cross-CAS Bridges

- [x] **111.3.1.1** Implement Mathematica/WolframScript bridge: send expressions
      to WolframScript (free Wolfram Engine) for evaluation, translate Kalika
      Expr → Wolfram Language InputForm and parse Wolfram OutputForm → Kalika
      Expr — for leveraging Mathematica's unmatched breadth when Kalika's native
      capabilities fall short. Bidirectional with timeout and error handling
- [x] **111.3.1.2** Implement SageMath bridge: call SageMath functions via
      Python subprocess, translate Kalika expressions to SageMath's Python
      representation and parse results — for accessing GAP (group theory),
      SINGULAR (commutative algebra), PARI/GP (number theory), and other wrapped
      systems through Sage's unified interface
- [x] **111.3.1.3** Implement SymPy bridge: direct Python interop (SymPy
      expressions ↔ Kalika expressions), enabling mixed computation where SymPy
      handles specific tasks (Galois group for polynomials, Diophantine solving)
      and Kalika handles others
- [x] **111.3.1.4** Implement Symbolica bridge: interface with the new Rust CAS
      Symbolica (by Ben Ruijl of FORM fame) for high-performance polynomial
      manipulation and Feynman integral reduction — a natural Rust-to-Rust
      bridge since both Kalika's CAS engine and Symbolica are Rust
- [x] **111.3.1.5** Implement FTheoryTools/OSCAR bridge: interface with the
      OSCAR computer algebra system (Julia) for F-theory model building, toric
      geometry, and polyhedral computation — accessing capabilities from
      FTheoryTools (2025), polymake, and SINGULAR through OSCAR's unified Julia
      interface

---

### 111.4 Computation Verification Infrastructure

#### 111.4.1 Multi-Level Verification Pipeline

- [x] **111.4.1.1** Implement automatic numerical spot-checking: for every
      symbolic computation result, evaluate both the input and output
      numerically at 10+ randomly chosen points using ball arithmetic (rigorous
      error bounds), verify agreement within computed error bounds — catches
      ~99% of algebraic errors with negligible computational cost. Run
      automatically on every CAS result, no user action required
- [x] **111.4.1.2** Implement cross-CAS verification: for high-stakes results
      (user-flagged or automatically flagged by complexity), independently
      verify using a different CAS backend (e.g., if Kalika computed it, verify
      with SageMath or WolframScript) — independent implementation reduces
      correlated-bug risk. Log the verification source and result
- [x] **111.4.1.3** Implement formal verification pipeline: attempt to translate
      the result to a Lean 4 statement and generate a tactic proof via the AI
      prover (Phase 104) — if successful, the result is formally verified (the
      strongest possible guarantee). Track success rate by computation type to
      identify areas where formal verification is reliable vs. unreliable
- [x] **111.4.1.4** Implement verification badge system: every computed result
      displays its verification level — "formally verified" (green,
      Lean-checked), "numerically verified" (blue, spot-check passed),
      "cross-CAS verified" (teal, independent CAS agrees), "unverified" (gray,
      not yet checked), "contradiction detected" (red, verification failed) —
      making trust levels transparent to the user

#### 111.4.2 Published Result Verification

- [x] **111.4.2.1** Implement "verify paper claim" workflow: user inputs a
      mathematical claim from a published paper (as LaTeX or natural language) →
      Kalika translates to symbolic form → attempts independent derivation using
      CAS → compares against the paper's stated result → reports
      agreement/disagreement with derivation chain — directly addressing the
      reproducibility crisis
- [x] **111.4.2.2** Implement derivation comparison: given two derivations of
      the same result (e.g., Kalika's and a paper's), align the steps, identify
      where they diverge, and flag potential errors in either — a "diff" for
      mathematical proofs
- [x] **111.4.2.3** Implement errata detection: when a user cites a paper's
      result, automatically check whether the result has known errata,
      retractions, or corrections (via Crossref/Retraction Watch API
      integration) — preventing propagation of known errors

#### 111.4.3 Computation Reproducibility

- [x] **111.4.3.1** Implement deterministic computation: ensure that every CAS
      computation is fully deterministic (fixed random seeds for any randomized
      algorithms, deterministic ordering of operations, no floating-point
      non-determinism) so that the same input always produces bit-identical
      output — the foundation of reproducibility
- [x] **111.4.3.2** Implement computation receipts: for every significant
      computation, produce a signed receipt containing: input expression hash,
      output expression hash, Kalika version, CAS engine version, timestamp,
      verification status, and the full derivation chain — enabling third-party
      verification of computation claims
- [x] **111.4.3.3** Implement "reproduce from paper" tool: given a paper's arXiv
      ID, download LaTeX source → extract mathematical claims and computations →
      attempt to reproduce each computation independently → generate a
      reproducibility report (which claims verified, which failed, which
      couldn't be parsed) — the ultimate tool for the reproducibility crisis in
      theoretical physics

---

### 111.5 Notebook Format Interoperability

- [x] **111.5.1.1** Implement .ipynb (Jupyter) importer: parse Jupyter notebook
      JSON, convert code cells to Kalika code cells, markdown cells to prose
      cells, output cells to cached results, and preserve kernel metadata —
      enabling migration from Jupyter to Kalika
- [x] **111.5.1.2** Implement .ipynb exporter: convert Kalika notebooks to
      Jupyter .ipynb format with Python kernel metadata, translating Kalika CAS
      calls to SymPy equivalents where possible — for sharing with Jupyter users
- [x] **111.5.1.3** Implement .nb (Mathematica) importer: parse Wolfram Language
      notebook expressions (Cell, CellGroupData, BoxData) to extract code cells,
      text cells, and outputs — best-effort conversion acknowledging that
      interactive Manipulate objects and dynamic content may not fully translate
- [x] **111.5.1.4** Implement Pluto.jl (.jl) importer: parse Julia source files
      with Pluto cell boundary comments, convert Julia expressions to Kalika
      equivalents where possible, preserve reactive cell structure
- [x] **111.5.1.5** Implement LaTeX paper importer: parse .tex files to extract
      equations (math mode environments), theorem/proof structures, and
      bibliography — converting a published paper into a partially-executable
      Kalika notebook where equations can be evaluated and verified

---

### 111.6 Citation Format Support

- [x] **111.6.1.1** Implement BibTeX/BibLaTeX parser and writer: full parsing of
      .bib files (all standard entry types and fields, including string macros
      and cross-references) and generation of .bib output from Kalika's citation
      database — with LaTeX special character handling
- [x] **111.6.1.2** Implement RIS parser and writer: read/write RIS tagged
      format for interchange with EndNote, Zotero, and institutional library
      systems
- [x] **111.6.1.3** Implement CSL-JSON parser and writer: read/write Citation
      Style Language JSON for interchange with Pandoc, Zotero, and web-based
      citation tools
- [x] **111.6.1.4** Implement DOI resolver: given a DOI, fetch full metadata
      from Crossref API (title, authors, journal, volume, pages, year, abstract,
      references, funding) and auto-create a citation entry — one-click citation
      from DOI
- [x] **111.6.1.5** Implement arXiv ID resolver: given an arXiv ID (both modern
      YYMM.NNNNN and legacy archive/YYMMNNN formats), fetch metadata from arXiv
      API and auto-create citation entry — with version awareness (v1, v2, etc.)
- [x] **111.6.1.6** Implement INSPIRE key resolver: given an INSPIRE texkey
      (e.g., `Maldacena:1997re`), fetch full bibliographic data from INSPIRE-HEP
      API and auto-create citation entry — the standard citation system in
      high-energy physics

---

### 111.7 Visualization Export Formats

- [x] **111.7.1.1** Implement TikZ-Feynman code generator: from Kalika's Feynman
      diagram data structures, generate TikZ-Feynman LaTeX code with proper
      particle line styles (fermion: straight with arrow, photon: wavy, gluon:
      curly, scalar: dashed, ghost: dotted), vertex types, and layout hints —
      producing publication-quality Feynman diagrams directly pasteable into
      LaTeX papers
- [x] **111.7.1.2** Implement PGFplots code generator: from Kalika's plot data,
      generate PGFplots LaTeX code for 2D/3D plots with axis labels, legends,
      error bars, and fill regions — matching the quality expected by physics
      journals
- [x] **111.7.1.3** Implement glTF 3D exporter: from Kalika's 3D visualizations
      (manifolds, field configurations, crystal structures), generate glTF 2.0
      files viewable in any web browser via Three.js — for interactive 3D
      supplementary figures in web-published papers

---

### 111.8 Tests

- [x] **111.8.1.1** Write data format round-trip tests: for each supported
      format (SLHA, LHE, HepMC3, HDF5, FITS, YODA, WCxf, BibTeX, OpenMath,
      CSL-JSON), verify import → export → re-import preserves all data — minimum
      5 round-trip tests per format, using reference files from the respective
      communities
- [x] **111.8.1.2** Write cross-CAS bridge tests: verify
      Mathematica/SageMath/SymPy bridges correctly translate and compute 20+
      expressions each (polynomials, integrals, matrices, group operations) —
      comparing Kalika results against reference CAS output
- [x] **111.8.1.3** Write verification pipeline tests: intentionally introduce
      errors into 50+ known-correct computations, verify that the verification
      pipeline (numerical spot-check, cross-CAS, formal) catches each error —
      measuring false-negative rate (missed errors) which must be <1% for
      numerical spot-checking
- [x] **111.8.1.4** Write format parser robustness tests: feed
      malformed/edge-case files for each format (empty files, missing fields,
      large files, unicode, special characters) and verify graceful error
      handling — minimum 10 edge-case tests per format
