## Phase 113: Kalika Final Completeness — Optimization, Automatic Differentiation, Measure Theory, Approximation Theory, Algebraic Combinatorics, Verified Computation, Remaining Tool Interfaces & Platform Hardening

The final phase closes every remaining gap identified in the exhaustive
three-pass audit. Ensures Kalika has: a general-purpose optimization library
(LP/SDP/convex/global — critical for the conformal bootstrap and variational
physics), automatic differentiation throughout (enabling differentiable physics
across every module), verified computation infrastructure, and interfaces to
every remaining standard tool in the physics/mathematics ecosystem. After this
phase, no significant computational capability used by foremost experts in
theoretical physics or mathematics should be absent from Kalika.

---

### 113.1 General Optimization Library (`@kalika/optimization`)

#### 113.1.1 Core Solvers

- [x] **113.1.1.1** Implement linear programming (LP) solver: simplex method
      (revised simplex with sparse LU factorization) and interior-point method
      (Mehrotra predictor-corrector), supporting standard/canonical form,
      infeasibility detection, unboundedness detection, and dual solution —
      matching HiGHS (open-source LP/MIP solver) for moderate-scale problems
- [x] **113.1.1.2** Implement **semidefinite programming (SDP) solver**:
      primal-dual interior-point method for symmetric positive-semidefinite
      matrix constraints, with arbitrary-precision arithmetic mode (matching
      SDPB — the solver used for the conformal bootstrap that produced
      world-record Ising critical exponents) — this is the single most important
      solver for the bootstrap program
- [x] **113.1.1.3** Implement convex optimization framework: disciplined convex
      programming (DCP) interface matching CVXPY — user specifies objective and
      constraints using atoms (norm, log_det, lambda_max, etc.), automatic
      verification of convexity, and dispatch to appropriate solver (LP, SOCP,
      SDP, or general convex via interior-point)
- [x] **113.1.1.4** Implement nonlinear optimization: unconstrained (gradient
      descent, L-BFGS, conjugate gradient, Newton-CG), constrained (augmented
      Lagrangian, SQP, interior-point), and bound-constrained (L-BFGS-B) —
      matching NLopt's algorithm portfolio with unified interface
- [x] **113.1.1.5** Implement global optimization: multistart with local
      optimization, basin-hopping, simulated annealing, differential evolution,
      and CMA-ES (Covariance Matrix Adaptation Evolution Strategy) — for
      non-convex optimization problems that arise in parameter fitting,
      landscape scanning, and variational physics
- [x] **113.1.1.6** Implement SDPB interface: for problems requiring SDPB's
      arbitrary-precision SDP solver (conformal bootstrap with Λ > 20
      derivatives), provide a direct interface to SDPB (subprocess + XML input
      format), translating Kalika's SDP problems to SDPB's input format and
      parsing results — essential for serious bootstrap computations
- [x] **113.1.1.7** Implement variational problem discretization: given a
      functional to minimize (∫ L(y, y', x) dx), discretize via finite elements
      or spectral methods and convert to a finite-dimensional optimization
      problem solvable by the above solvers — the bridge between calculus of
      variations (physics) and numerical optimization

#### 113.1.2 Physics-Specific Optimization

- [x] **113.1.2.1** Implement variational method for quantum mechanics: given a
      Hamiltonian and a parametric trial wavefunction ψ(x; α₁, ..., αₙ),
      minimize ⟨ψ|H|ψ⟩/⟨ψ|ψ⟩ with respect to parameters — the Ritz method, using
      the nonlinear optimizer above, with automatic gradient computation via AD
- [x] **113.1.2.2** Implement least-squares fitting with physical constraints:
      fit experimental data to theoretical models (χ² minimization) with
      physical constraints (e.g., positivity, unitarity bounds, sum rules),
      error propagation (Hessian-based or MCMC), and goodness-of-fit assessment
      — the bread-and-butter of experimental-theoretical comparison

---

### 113.2 Automatic Differentiation (`@kalika/autodiff`)

- [x] **113.2.1.1** Implement forward-mode AD: dual number arithmetic (x + εx')
      propagating first derivatives through all Kalika numerical operations
      (arithmetic, elementary functions, special functions, linear algebra) —
      O(n) cost for n input derivatives, optimal for computing Jacobians of f:
      R^m → R^n with m << n
- [x] **113.2.1.2** Implement reverse-mode AD: computation graph recording
      (tape) + backward pass for computing gradients — O(1) cost per output for
      computing gradients of f: R^n → R regardless of n, enabling efficient
      optimization of functions with many parameters (neural networks,
      variational problems, parameter fitting)
- [x] **113.2.1.3** Implement AD through ODE solvers: adjoint method for
      computing gradients of ODE solutions with respect to parameters (matching
      torchdiffeq / DiffEqFlux approach) — df/dθ where x(t; θ) solves dx/dt =
      f(x, θ, t). This enables: gradient-based fitting of dynamical models,
      neural ODE training, and sensitivity analysis of physical simulations
- [x] **113.2.1.4** Implement AD through PDE solvers: adjoint-state method for
      spectral and FEM solvers — computing gradients of PDE-derived observables
      with respect to material parameters, boundary conditions, or geometry.
      This enables: inverse problems (inferring parameters from observations),
      shape optimization, and topology optimization
- [x] **113.2.1.5** Implement AD through the CAS engine: for numerical
      evaluation of symbolic expressions with parameters, provide automatic
      derivatives without resorting to finite differences — the symbolic
      expression tree IS the computation graph, so reverse-mode AD is natural.
      This makes every CAS computation automatically differentiable
- [x] **113.2.1.6** Ensure AD compatibility across all numerical modules: verify
      that ODE solvers (Phase 103.2.1), PDE solvers (Phase 103.2.2), Monte Carlo
      integrators (Phase 103.3), tensor network contractions (Phase 103.4), and
      special function evaluations (Phase 103.6) all support gradient
      propagation — making Kalika a fully differentiable physics platform

---

### 113.3 Measure Theory & Foundations (`@kalika/measure-theory`)

- [x] **113.3.1.1** Implement measure space framework: sigma-algebras (generated
      by sets, Borel sigma-algebra on R^n), measures (Lebesgue, counting, Dirac,
      product measures), measurable functions, and the Lebesgue integral (as the
      rigorous foundation for all integration in Kalika) — primarily as type
      definitions and verification infrastructure rather than computation
      (measures are verified, not numerically evaluated)
- [x] **113.3.1.2** Implement Lebesgue integration theory utilities: dominated
      convergence theorem checker (given a sequence f_n → f and dominating
      function g, verify |f_n| ≤ g), monotone convergence theorem checker,
      Fubini's theorem (conditions for swapping integration order), and change
      of variables formula verification — as symbolic verification tools that
      validate integration manipulations in derivation chains
- [x] **113.3.1.3** Implement ergodic theory basics: measure-preserving
      transformations (verify that T\_\*μ = μ), ergodicity test (mixing
      coefficients), Birkhoff ergodic theorem (time average = space average for
      ergodic systems), topological/measure-theoretic entropy computation
      (symbolic dynamics: topological entropy as log of spectral radius of
      transition matrix, Kolmogorov-Sinai entropy via Lyapunov exponents) —
      connecting to dynamical systems (Phase 112.8)

---

### 113.4 Approximation Theory (`@kalika/approximation`)

- [x] **113.4.1.1** Implement polynomial approximation: best uniform
      (minimax/Chebyshev) approximation via Remez algorithm (iterative exchange
      algorithm for finding the equioscillation polynomial), best L²
      approximation (orthogonal projection onto polynomial subspaces), and
      Jackson/Bernstein theorems for approximation rate estimation
- [x] **113.4.1.2** Implement rational approximation: Padé approximants [m/n]
      (matching Taylor series to order m+n), multipoint Padé, continued fraction
      representation, and AAA (Adaptive Anker-Anderson) algorithm for rational
      approximation on arbitrary point sets — used extensively in physics for
      resumming divergent series, QCD running coupling, and analytic
      continuation
- [x] **113.4.1.3** Implement Chebyshev technology: Chebyshev interpolation on
      Chebyshev nodes (near-optimal polynomial interpolation), Clenshaw
      evaluation algorithm, chebfun-style automatic precision (adaptively
      increase polynomial degree until convergence), and operations on Chebyshev
      representations (addition, multiplication, integration, differentiation,
      root finding — all in coefficient space) — matching the chebfun/ApproxFun
      paradigm for working with functions as data

---

### 113.5 Algebraic Combinatorics (`@kalika/algebraic-combinatorics`)

- [x] **113.5.1.1** Implement matroid framework: matroid construction (from
      matrix, graph, or abstract bases/circuits/rank function), matroid
      operations (dual, contraction, deletion, direct sum), characteristic
      polynomial computation, Tutte polynomial, matroid intersection — relevant
      for optimization (greedy algorithms), tropical geometry, and algebraic
      geometry (June Huh's work)
- [x] **113.5.1.2** Implement poset framework: partially ordered set
      construction, Hasse diagram, Möbius function (via Möbius inversion on the
      incidence algebra), zeta polynomial, order polynomial, and P-partition
      theory — connecting to generating functions, species, and representation
      theory
- [x] **113.5.1.3** Implement Ehrhart theory: given a lattice polytope P,
      compute the Ehrhart polynomial L(P, t) = |tP ∩ Z^n| (counting lattice
      points in dilations), Ehrhart series, h\*-vector, and verify Ehrhart
      reciprocity (interior points vs boundary points) — connecting to toric
      geometry and the string landscape (counting lattice points in reflexive
      polytopes)
- [x] **113.5.1.4** Implement Kazhdan-Lusztig polynomials for matroids:
      P\_{M}(t) as defined by Elias-Proudfoot-Wakefield, computing via the
      deletion-contraction recursion with Z-polynomials — the polynomials whose
      non-negativity was proved by Braden-Huh-Matherne-Proudfoot-Wang, resolming
      a long-standing conjecture. Connects combinatorics to Hodge theory

---

### 113.6 Verified Computation Extensions

- [x] **113.6.1.1** Implement interval Newton method: given f(x) = 0 and an
      interval [a,b], use interval arithmetic to either verify a unique root
      exists in [a,b] (Krawczyk operator) or prove no root exists — providing
      computer-assisted proofs of existence/uniqueness results
- [x] **113.6.1.2** Implement Taylor model arithmetic: represent functions as
      Taylor polynomials with rigorous interval remainder bounds, propagate
      through ODE integration (giving guaranteed solution enclosures), and
      through composition/inversion — matching COSY Infinity capabilities for
      beam physics and dynamical systems
- [x] **113.6.1.3** Implement verified global optimization: interval
      branch-and-bound for finding the guaranteed global minimum of a function
      on a box domain (using interval arithmetic to eliminate regions that
      provably do not contain the minimum) — for computer-assisted proofs
      requiring global optimality

---

### 113.7 Remaining Tool Interfaces

#### 113.7.1 Cosmological Pipeline

- [x] **113.7.1.1** Implement CLASS interface (via Python subprocess): submit
      cosmological parameters → receive CMB C_l^{TT/TE/EE/BB}, matter power
      spectrum P(k), transfer functions, and derived parameters (H_0, sigma_8,
      etc.) — CLASS (Cosmic Linear Anisotropy Solving System) is the modern
      standard Boltzmann solver
- [x] **113.7.1.2** Implement CAMB interface (via Python subprocess): same
      capabilities as CLASS — CAMB (Code for Anisotropies in the Microwave
      Background) is the alternative standard, used by the Planck collaboration.
      Supporting both ensures results can be cross-checked
- [x] **113.7.1.3** Implement Cobaya interface: submit parameter estimation
      tasks to Cobaya (cosmological Bayesian analysis framework) — specifying
      theory code (CLASS/CAMB), likelihoods (Planck, BAO, SNe, H_0), sampler
      (MCMC, nested sampling, minimizer), and retrieving chains/posteriors for
      analysis in Kalika
- [x] **113.7.1.4** Implement cosmological likelihood library: built-in
      likelihoods for standard datasets (Planck 2018/PR4, DESI BAO, Pantheon+
      SNe Ia, SH0ES H_0) — sufficient for self-contained cosmological parameter
      estimation without external dependencies

#### 113.7.2 One-Loop Provider Interface

- [x] **113.7.2.1** Implement BLHA2 (Binoth Les Houches Accord v2) interface:
      the standard protocol connecting Monte Carlo event generators with
      one-loop amplitude providers — implement both the order file exchange
      phase (contract negotiation: process list, coupling orders, IR subtraction
      scheme) and the runtime phase (pass momenta, receive: tree, loop,
      color-correlated, spin-correlated amplitudes and subtraction terms)
- [x] **113.7.2.2** Implement OpenLoops interface (via shared library): call
      OpenLoops for fast numerical one-loop amplitudes for SM and BSM processes
      — OpenLoops uses numerical recursion (on-the-fly reduction) and is the
      fastest general-purpose one-loop provider
- [x] **113.7.2.3** Implement Collier interface (via shared library or
      subprocess): access the Collier library for numerically stable evaluation
      of one-loop scalar and tensor integrals (Denner-Dittmaier reduction) — the
      standard reference library for one-loop integral numerics

#### 113.7.3 BSM Reinterpretation

- [x] **113.7.3.1** Implement CheckMATE interface: given signal events (from
      Kalika's cross-section computation or external generator), pass to
      CheckMATE for comparison against implemented LHC search analyses — returns
      observed/expected exclusion CL_s for each analysis, identifying which
      searches constrain the model
- [x] **113.7.3.2** Implement SModelS interface: given a BSM spectrum (SLHA),
      decompose into simplified model topologies and compare against the SModelS
      database of LHC upper limits — fast BSM exclusion checking without full
      event generation
- [x] **113.7.3.3** Implement HiggsBounds/HiggsSignals interface: given BSM
      Higgs sector predictions (masses, couplings, branching ratios), check
      exclusion (HiggsBounds) and compatibility with measured Higgs signal
      strengths (HiggsSignals) — essential for any BSM Higgs phenomenology

#### 113.7.4 Mesh Generation & Computational Geometry

- [x] **113.7.4.1** Implement Gmsh interface (via subprocess or API): generate
      2D triangular / 3D tetrahedral meshes for arbitrary geometries specified
      by CAD-like boundary descriptions — providing production-quality meshes
      for FEM/DG solvers in @kalika/numerical
- [x] **113.7.4.2** Implement basic computational geometry: convex hull
      (Qhull-style), Delaunay triangulation, Voronoi diagram,
      point-in-polygon/polyhedron, and polygon/polyhedron volume — utilities
      needed across many modules (polytope computation, mesh generation, TDA)

#### 113.7.5 D-modules (Interface)

- [x] **113.7.5.1** Implement D-module interface via Macaulay2/SINGULAR: send
      Weyl algebra computations (Bernstein-Sato polynomial, annihilator of f^s,
      de Rham cohomology, D-module restriction) to Macaulay2's Dmodules package
      or SINGULAR's dmod_lib via subprocess — providing access to D-module
      computation without reimplementing the complex algorithms

---

### 113.8 Mathematical Logic Interface

- [x] **113.8.1.1** Implement model-theoretic computation basics: first-order
      structure representation, formula evaluation in a structure (model
      checking), quantifier elimination for decidable theories (Presburger
      arithmetic: integer linear arithmetic, Tarski: real closed fields —
      already partially covered in 104.2.2.3), and finite model enumeration for
      small signatures
- [x] **113.8.1.2** Implement computability theory utilities: Turing machine
      simulator (for educational/demonstration purposes), decidability oracle
      for standard theories (Presburger, Th(R, +, ×), WS1S/WS2S via MONA), and
      Rice's theorem illustration — providing the logical foundations

---

### 113.9 Platform Hardening & Final Quality

- [x] **113.9.1.1** Run comprehensive cross-module integration tests: verify
      that CAS results feed correctly into physics libraries (e.g., symbolic
      Christoffel symbols from GR module match numerical evaluation from
      numerical engine), AI agent suggestions align with CAS computations, and
      knowledge graph queries return results consistent with direct computation
      — minimum 50 cross-module tests
- [x] **113.9.1.2** Run performance benchmarks for ALL modules against stated
      SOTA targets: CAS vs Mathematica/FLINT, group theory vs GAP, number theory
      vs PARI/GP, tensor calculus vs xAct, Feynman diagrams vs FeynCalc/FORM,
      numerical LA vs LAPACK, sparse solvers vs PETSc — publish results in
      benchmark suite with regression tracking
- [x] **113.9.1.3** Run adversarial testing: intentionally introduce errors into
      inputs for every major pipeline (malformed expressions, ill-conditioned
      matrices, singular limits, boundary cases) and verify graceful error
      handling with informative messages — minimum 200 adversarial test cases
- [x] **113.9.1.4** Run accessibility compliance audit: verify WCAG 2.1 AA for
      all UI components, screen reader testing for mathematical content,
      keyboard navigation for all operations — no sighted-only features
- [x] **113.9.1.5** Generate final benchmark report: comprehensive comparison of
      Kalika capabilities against ALL 150+ named SOTA systems, documenting for
      each: what Kalika matches, what it exceeds, and what gaps remain with
      specific plans to close them — the public-facing evidence that Kalika is a
      credible SOTA platform

---

### 113.10 Tests

- [x] **113.10.1.1** Write optimization tests: verify LP solver finds optimal
      vertex, SDP solver reproduces SDPB bootstrap bounds for 2D Ising (known
      result: Δ_σ = 0.5181...), convex optimizer finds minimum of known convex
      functions, global optimizer finds Rosenbrock minimum — minimum 60 test
      cases
- [x] **113.10.1.2** Write AD tests: verify forward-mode gradients match finite
      differences to machine precision for 50+ expressions, reverse-mode
      gradients for neural-network-scale computations (100+ parameters), and
      adjoint ODE gradients match finite differences for Lotka-Volterra and
      harmonic oscillator — minimum 80 test cases
- [x] **113.10.1.3** Write verified computation tests: verify interval Newton
      finds/excludes roots correctly for 20+ functions, Taylor model ODE
      enclosures contain the true solution for Lorenz/harmonic oscillator, and
      global optimizer certifies global minimum bounds — minimum 30 test cases
- [x] **113.10.1.4** Write cosmological pipeline tests: verify CLASS/CAMB
      interfaces return consistent C_l for ΛCDM with known parameters, Cobaya
      reproduces Planck 2018 posterior contours, and likelihood evaluations
      match published values — minimum 15 test cases
