SCIENCE · NEUROSYMBOLIC AI

Neurosymbolic programming in 2026: programs with neural parts and logic rules

AUTHOR · XERJ documentation team · REVIEWED BY · XERJ engineering team · PUBLISHED · 2026-12-05 · UPDATED · 2026-12-05
SHORT ANSWER · UPDATED 2026-12-05

What is neurosymbolic programming? It is writing programs that combine neural modules with symbolic code such as logic rules, so a network reads raw input and the rules reason over it exactly. The 2021 survey by Chaudhuri, Ellis, Polozov, Singh, Solar-Lezama and Yue describes it as learning functions from data that are represented as programs using neural modules alongside symbolic primitives.

Key number: DeepProbLog solves MNIST addition with a single rule, addition(X, Y, Z) :- digit(X, A), digit(Y, B), Z is A + B. Only the digit network is learned, from pairs of images labelled with their sum. (source: arXiv 1805.10872)

Last checked: 2026-12-05. Tool facts from each GitHub repository and the GitHub REST API on that date; papers linked in Evidence.

TL;DR A neurosymbolic program has two kinds of parts. Neural modules turn images, audio or text into facts with probabilities. Symbolic parts, such as Datalog rules or plain code, reason over those facts and can show a proof. Because the reasoning is differentiable or probabilistic, the whole program trains from examples. Try it with the addition program below, then compare the tools.

Try it: a neurosymbolic program

MNIST addition: two neural guesses, one logic rule, a proof for the sum

The program: addition(X, Y, Z) :- digit(X, A), digit(Y, B), Z is A + B. The neural predicate digit is a network that reads a handwritten digit and returns probabilities. Set what the network thinks it sees.

Image 1: the network's guess
Image 2: the network's guess

Presets

Sum ZProbabilityDigit pairs that prove it

        

Runs in your browser and sends nothing. The program is the MNIST addition example from the DeepProbLog paper (arXiv 1805.10872): the probability of each sum is the total over digit pairs that satisfy the rule, and the credit line shows how a label of only the sum tells training which digit readings to reward. Each image here has two guesses to keep the numbers easy to follow; a real network gives all ten digits a probability.
PASTE THIS TO YOUR AI AGENT. IT DOES THE REST Act as an AI engineer. Read https://xerj.org/science/neurosymbolic-programming and https://xerj.org/compare/neurosymbolic-ai-frameworks-2026. Find one task in my project where a model reads messy input and a rule could do the reasoning, write the rule as Datalog or plain code, and sketch how the model's output feeds it. Index my repo with https://xerj.org first and cite file paths.

How neurosymbolic programming works

Think of it in three steps. First, a neural predicate wraps a network: digit(img, 3) is true with the probability the network gives. Second, a symbolic program states what you already know, such as how addition works or which rules a decision must follow. Third, a reasoner runs the program over the uncertain facts and adds up the probability of every proof of the answer.

Training works backwards through the same proofs. In the demo, a label of 8 gives credit only to digit readings that can add up to 8, so the network learns to read digits without ever seeing a digit label. DeepProbLog does this on top of the ProbLog language, and Scallop does it with Datalog and provenance semirings.

Neurosymbolic programming languages and tools

Six open source projects you can run today. For a filterable table with more frameworks, solvers and agent memory engines, see neurosymbolic AI frameworks 2026.

ToolLanguageLicenceGitHub starsWhat it is
ScallopDatalog, Rust and PythonMIT530Datalog with recursion, aggregation and negation, plus differentiable reasoning on provenance semirings; scallopy plugs into PyTorch. Paper at PLDI 2023.
DeepProbLogProbLog, PythonApache-2.0367ProbLog with neural predicates, trained end to end from examples such as pairs of digit images labelled with their sum.
Logic Tensor NetworksPythonMIT377First-order fuzzy logic written as tensor operations, so rules become part of the training loss.
DeepLogPython, PyTorchLGPL-2.130KU Leuven framework that compiles neurosymbolic languages into arithmetic circuits inside standard PyTorch workflows. Paper at IJCAI 2026.
DOLPHINPythonMIT22Writes neurosymbolic programs in Python, runs the symbolic part on the CPU and batches probabilities and gradients on the GPU. Paper at ICML 2025.
SymbolicAIPythonBSD-3-Clause1,787Mixes plain Python code with LLM operations and contracts that check the results.

Stars, licences and languages from the GitHub REST API on 2026-12-05. Paper venues from each paper's page, linked in Evidence.

Why write the reasoning as a program

The 2021 survey Neurosymbolic Programming in Foundations and Trends in Programming Languages gives four reasons. Programs handle long, step by step tasks well. They are easier to read and formally verify than a network. The limits of a programming language act as regularization, which helps a model learn from less data and generalize further. And a learned module, such as a digit reader, can be reused in new programs.

DeepProbLog shows the reuse point: a model trained on single digit sums is evaluated on numbers with three digits, with a small change to the logic program and no new training.

Neurosymbolic programming with LLMs

In 2026 the neural part is often a large language model. The model reads the question and writes a program, a set of facts or solver constraints; an interpreter, Datalog engine or SMT solver runs it and returns an answer you can check. See neurosymbolic reasoning for a live rule engine, neurosymbolic AI vs LLM for when to add a solver, and symbolic AI for the rule half on its own.

How XERJ uses it

XERJ is a new way for AI to search for data, with a neurosymbolic model inside. XERJ Query-1 compiles a prompt to a search program you can read and checks the result against stored facts, and XERJ Reader-1 writes a formula over a document that a separate engine calculates. See XERJ Query-1 and neurosymbolic models.

Read next

FAQ

What is neurosymbolic programming?

Neurosymbolic programming is writing programs that combine neural modules with symbolic code such as logic rules. A neural network turns raw input like images or text into facts, and the rules reason over those facts exactly. The program can be trained end to end from examples.

What is an example of neurosymbolic programming?

The classic example is MNIST addition from the DeepProbLog paper. A neural network reads two handwritten digits, and one rule adds them: addition(X, Y, Z) :- digit(X, A), digit(Y, B), Z is A + B. The network learns to read digits from pairs labelled only with their sum.

Which languages are used for neurosymbolic programming?

Datalog in Scallop, ProbLog in DeepProbLog, fuzzy first-order logic in Logic Tensor Networks, and plain Python in DOLPHIN and SymbolicAI. Most of them connect to PyTorch so the neural parts train with ordinary gradient descent.

How is neurosymbolic programming different from deep learning?

Deep learning learns one large network for the whole task. Neurosymbolic programming learns only the perception parts and writes the reasoning as a program. The 2021 survey by Chaudhuri and colleagues lists the gains: programs are easier to read and verify, need less data, generalize further and reuse learned modules.

Is neurosymbolic programming the same as neurosymbolic AI?

It is the programming side of neurosymbolic AI. Neurosymbolic AI is the whole field of joining neural networks with symbolic reasoning; neurosymbolic programming is the practical way to build such a system as code you can run, read and train.

Can LLMs do neurosymbolic programming?

Yes. A common 2026 pattern has an LLM write a small program or a set of logic facts, and a solver or interpreter runs it and checks the result. The LLM is the neural part, and the program is the symbolic part you can read.

Evidence

Related