Neurosymbolic Programming for Science

Jennifer J. Sun, Megan Tjandrasuwita, Atharva Sehgal, Armando Solar-Lezama, Swarat Chaudhuri, Yisong Yue, Omar Costilla Reyes

TL;DR

Neurosymbolic Programming (NP) bridges the gap between flexible deep learning and interpretable, rule-based scientific modeling by expressing scientific hypotheses as programs in a Domain-Specific Language (DSL). Using computational animal behavior analysis as a case study, this paper outlines the core principles of NP, the opportunities it unlocks for scientific discovery, and the key hurdles—such as scalability, continuous relaxations, and benchmarking—that must be solved to integrate NP into everyday scientific workflows.

What Problem Does This Paper Address?

Building an automated "AI scientist" requires models that can learn complex patterns from raw, noisy data while remaining interpretable, verifiable, and consistent with existing scientific laws.

Current machine learning approaches struggle with this trade-off:

  • Purely neural models (e.g., 1D CNNs) fit high-dimensional data well but operate as black boxes, making error diagnosis, counterfactual reasoning, and scientific validation difficult.
  • Purely symbolic models (e.g., hand-coded heuristics or expert systems) are transparent and parameter-free but brittle, scaling poorly to noisy real-world data and complex dynamics.

This paper explores how Neurosymbolic Programming (NP) can unify these two paradigms, mapping out where current techniques succeed and identifying the critical gaps preventing their widespread adoption across the natural and social sciences.

Methods

NP formulates hypothesis generation as program synthesis over a Domain-Specific Language (DSL):

  • DSL-Driven Inductive Bias: Domain experts specify the primitives, constraints, and valid compositions in a DSL. The program's discrete syntax tree defines its architecture, while learnable continuous weights define its parameters.
  • Continuous Relaxations & Smooth Interpretation: Standard program primitives (e.g., discrete if-then-else branches) are non-differentiable. NP uses continuous relaxations—such as replacing hard step functions with temperature-scaled hyperbolic tangents or Gaussian smoothing—enabling gradient-based optimization of continuous parameters alongside discrete structural search.
  • Differentiable Domain Primitives: Instead of generic, uninterpretable higher-order operators (like raw fold or map), domain-specific differentiable operations are embedded into the DSL (for example, Morlet filters that model temporal impulse responses in behavioral classification).
  • Library Learning: Algorithms automatically discover repetitive sub-programs across successful tasks and consolidate them into higher-level DSL primitives (e.g., concepts akin to DreamCoder).

Datasets

Not discussed in the paper as an empirical experimental study.

The paper is a perspective and position paper. It does not introduce a new dataset, but discusses existing benchmarks and pipelines in computational ethology:

  • Video and tracked keypoint trajectories from animal behavior frameworks, such as MARS (Mouse Action Recognition System) and Bento for social mouse behavior.
  • Pose-tracking data from systems like DeepLabCut and SLEAP.
  • The authors explicitly call for the creation of new standardized, cross-domain benchmarks centered on low-dimensional spatiotemporal data.

Key Insights and Ideas

  • Hypotheses as Code: Framing scientific theories as modular programs allows models to output artifacts that look remarkably similar to the code or rules human experts write manually (e.g., defining an animal "attack" or "sniff" behavior via distance and acceleration thresholds).
  • Graceful Handling of Domain Shifts: When experimental setups change (such as arena dimensions changing mouse scale), symbolic program components can be scaled or adjusted analytically, avoiding the catastrophic failure common in black-box neural nets.
  • Bridging the Hardware Divide: A subtle bottleneck in NP is computational heterogeneity: neural representation learning heavily relies on GPU parallelism, whereas combinatorial symbolic program synthesis runs predominantly on CPUs.
  • Distilling Informal Science: Much scientific knowledge exists informally (e.g., natural language ethograms or causal intuitions). The challenge is not writing a single "universal" scientific DSL, but distilling targeted domain knowledge into task-specific DSLs.

Key Results

Because this is a conceptual framework paper presented at the NeurIPS 2022 AI for Science Workshop, no new quantitative benchmark results are introduced. Instead, the authors highlight qualitative findings from across the literature:

  • NP models synthesize compact programs that differentiate subtle expert annotations in animal behavior without sacrificing performance.
  • Integrating symbolic domain knowledge yields data-efficient learning for rare behavioral classes (events occurring in $<1\%$ of observations) and produces more scientifically meaningful clusters in unsupervised structural discovery compared to standard neural baselines.

Limitations and Future Work

The authors highlight several major open challenges:

  1. Scalability: Synthesizing programs across long temporal sequences or directly from high-dimensional inputs (such as raw video frames rather than pre-extracted pose trajectories) remains computationally prohibitive.
  2. Approximation vs. Trainability Trade-offs: Continuous relaxations introduce approximation errors; under-approximating retains discontinuities in the optimization landscape, while over-smoothening reduces precision.
  3. Benchmarking & Reproducibility: Many program synthesis algorithms rely on stochastic search, making reproducible program discovery difficult. Objective quantitative metrics for explanation stability, actionability, and compactness are still lacking.
  4. Tooling & HCI: For domain scientists to adopt NP, user-friendly graphical interfaces (similar to existing ML annotation suites) must be built to allow scientists to interact with program synthesis loops and active learning interfaces.

Summary updated

BibTeX
@inproceedings{sun2022neurosymbolic,
  author = {Jennifer J. Sun and Megan Tjandrasuwita and Atharva Sehgal and Armando Solar-Lezama and Swarat Chaudhuri and Yisong Yue and Omar Costilla Reyes},
  title = {{Neurosymbolic Programming for Science}},
  booktitle = {AI4Science @ NeurIPS},
  year = {2022},
  url = {https://openreview.net/forum?id=MJtzhkSRQr},
}
Figure