Skip to content

GhostScience (PhD Mode) ​

GhostScience is GhostAI's PhD-level scientific computing engine. It provides structured tools for symbolic math, numerical methods, optimization, statistics, control systems, signal processing, simulation, and method comparison -- all running inside a PII-protected sandbox with a regulatory-grade computation provenance ledger.

Architecture ​

User Input (LaTeX / MATLAB / Python / natural language)
    │
    v
DSL Parser ── syntax detection + normalization
    │
    v
PII Detection + Tokenization (PreDact middleware)
    │
    v
LLM Reasoning Layer (problem classification, method selection)
    │
    v
Scientific Orchestrator (code generation, cache check, sandbox dispatch)
    │
    v
PhD Sandbox Container (50+ libraries, gVisor isolation)
    │
    v
Output PII Scan
    │
    v
Structured Result (LaTeX + plots + units + uncertainty + provenance)

GhostScience is a capability layer within GhostAI, not a standalone application. Every security, compliance, and observability feature of the platform applies automatically to scientific computation.

Scientific Tools ​

GhostScience provides eight structured tools that the AI reasoning layer invokes based on problem analysis:

ToolCapabilities
Symbolic MathematicsSolve, integrate, differentiate, simplify, series expand, Laplace/Fourier transforms. Accepts any syntax. Returns LaTeX with step-by-step derivation.
Numerical MethodsODE/PDE systems, linear algebra, eigenvalue problems, root finding. Returns solutions with error bounds, condition numbers, and convergence history.
OptimizationConvex (CVXPy), nonlinear (SciPy), multi-objective (pymoo). Auto-classifies convexity. Returns optimal values, Lagrange multipliers, Pareto fronts.
Control SystemsTransfer function and state-space analysis. Bode, Nyquist, root locus. Stability margins. Controller design (PID, LQR, H-infinity).
Signal ProcessingFFT/STFT, wavelet transforms, filter design, spectral density. Returns spectrum plots, filter coefficients, time-frequency representations.
Statistical AnalysisHypothesis testing, regression, time series, Bayesian inference, survival analysis. Auto-propagates uncertainty. Returns test statistics and diagnostic plots.
SimulationDynamic systems (continuous, discrete, hybrid), Monte Carlo, sensitivity analysis. Returns time series, phase portraits, and uncertainty bounds.
Method ComparisonSolve the same problem with multiple methods. Compare accuracy, speed, memory, and stability side-by-side with a recommendation and rationale.

Using GhostScience from Chat ​

When PhD Mode is enabled and the sandbox is available, the eight scientific tools are registered as LLM tool calls in the chat interface. Ask a scientific question in any notation:

  • LaTeX: "Evaluate $\int_0^\infty e^{-x^2} dx$"
  • MATLAB-style: "Solve the transfer function tf([1 2], [1 3 2]) and plot the Bode diagram"
  • Natural language: "Integrate x squared plus 3x with respect to x"
  • Python: "Use scipy to solve the Lorenz attractor ODE system"

The LLM classifies the problem, selects the appropriate tool, and invokes it through the scientific orchestrator. Results are rendered with interactive Plotly charts, KaTeX-formatted equations, and step-by-step explanations.

See DSL Syntax Guide for the full input format reference.

AI-Powered Scientific Reasoning ​

The LLM reasoning layer adds capabilities that traditional tools lack:

  • Problem classification -- identifies PDE type, detects stiffness, classifies optimization convexity before selecting a solver
  • Method selection -- chooses solvers based on problem structure, explains the choice, and compares alternatives
  • Numerical awareness -- monitors condition numbers, convergence rates, and truncation errors
  • Validation -- substitutes results back into original equations, checks conservation laws, compares with limiting cases
  • Physical intuition -- tracks units via Pint, references CODATA physical constants, catches dimensional inconsistencies
  • Research continuity -- remembers variable definitions, model structures, and method preferences across sessions

PhD Sandbox ​

The sandbox is a hardened Docker container running a curated scientific Python stack with 50+ libraries across 17 domains:

DomainLibraries
Symbolic MathSymPy, galgebra
Numerical ComputingJAX, SciPy, NumPy
OptimizationCVXPy, pymoo
Control Systemspython-control, slycot
Signal ProcessingPyWavelets, librosa
Statisticsstatsmodels, PyMC, ArviZ
Uncertaintyuncertainties, SALib
Unitspint, scipy.constants
VisualizationPlotly, PyVista, matplotlib

The full library stack is listed in requirements-phd.txt and requirements-phd-full.txt (extended stack). See the PhD Sandbox Deployment Guide for Docker image details.

Security ​

The PhD sandbox inherits and extends the Code Interpreter security model:

  • gVisor isolation -- intercepts syscalls at the kernel boundary
  • Custom seccomp profile -- allows computation syscalls, denies network and ptrace
  • Read-only filesystem -- only /workspace and /tmp are writable
  • No network -- blocked at the kernel level
  • Resource caps -- CPU, memory, and execution time are hard-limited per container
  • Supply chain -- all packages pinned with SHA-256 hashes, images scanned with Trivy/Grype

Provenance ​

Every computation produces an immutable provenance record containing the tool name, parameters, generated code, environment hash, execution metrics, result hash, method rationale, unit verification, uncertainty summary, and data lineage. Records satisfy FDA 21 CFR Part 11, SOX Section 404, HIPAA, and NERC CIP audit requirements.

See Provenance & Export for the full record schema and export formats.

Reproducibility ​

GhostScience guarantees bitwise-identical results for deterministic computations:

  • All generated code sets explicit random seeds
  • NumPy and SciPy random generators are seeded from the provenance record
  • The environment hash (image ID + library versions + config) is stored
  • A verification endpoint (POST /api/phd/reproduce/{id}) re-executes a computation and compares result hashes

Configuration ​

VariableDefaultDescription
PHD_MODE_ENABLEDfalseMaster toggle for GhostScience
PHD_SANDBOX_IMAGEghostai-phd-sandbox:latestCPU sandbox Docker image
PHD_SANDBOX_GPU_IMAGEghostai-phd-sandbox-gpu:latestGPU sandbox image (CUDA 12.2)
PHD_SANDBOX_TIMEOUT300Max execution time (seconds)
PHD_SANDBOX_MEMORY_LIMIT4gContainer memory limit
PHD_SANDBOX_CPU_LIMIT2.0CPU cores per container
PHD_PARALLEL_MAX4Max concurrent PhD executions
PHD_GPL_FREEfalseExclude GPL-licensed libraries
PHD_MAX_SESSIONS_PER_USER3Persistent session limit per user
PHD_MAX_SESSIONS_PER_ORG20Persistent session limit per org
PHD_SESSION_TTL_HOURS24Session expiry

PhD Mode also requires the general sandbox to be enabled (SANDBOX_ENABLED=true).

SOC 2 Type II Certified | BAA Available | HIPAA-Ready