<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Giuseppe Marra | DTAI Stories</title><link>https://dtai.cs.kuleuven.be/stories/authors/giuseppe-marra/</link><atom:link href="https://dtai.cs.kuleuven.be/stories/authors/giuseppe-marra/index.xml" rel="self" type="application/rss+xml"/><description>Giuseppe Marra</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><lastBuildDate>Tue, 29 Sep 2026 10:04:27 +0200</lastBuildDate><image><url>img/map[gravatar:%!s(bool=false) shape:circle]</url><title>Giuseppe Marra</title><link>https://dtai.cs.kuleuven.be/stories/authors/giuseppe-marra/</link></image><item><title>DeepLog</title><link>https://dtai.cs.kuleuven.be/stories/post/robin-manhaeve/deeplog/</link><pubDate>Tue, 29 Sep 2026 10:04:27 +0200</pubDate><guid>https://dtai.cs.kuleuven.be/stories/post/robin-manhaeve/deeplog/</guid><description>
&lt;div class="card relpub">
&lt;div class="card-body">
&lt;small>
&lt;p>This post is based on the following publications:&lt;/p>
&lt;ul>
&lt;li>
&lt;a href="https://www.ijcai.org/proceedings/2026/980" target="_blank" rel="noopener">DeepLog: A Software Framework for Modular Neurosymbolic AI&lt;/a>. Manhaeve, R., Colamonaco, S., Derkinderen, V., Adriaensen, R., Van Praet, L., De Raedt, L., Marra, G., IJCAI 2026 (Demo Track), pp. 8462–8465.&lt;/li>
&lt;li>
&lt;a href="https://arxiv.org/abs/2508.13697" target="_blank" rel="noopener">The DeepLog Neurosymbolic Machine&lt;/a>. Derkinderen, V., Manhaeve, R., Adriaensen, R., Van Praet, L., De Smet, L., Marra, G., De Raedt, L., arXiv, 2025.&lt;/li>
&lt;/ul>
&lt;p>Software is available on
&lt;a href="https://github.com/ML-KULeuven/deeplog" target="_blank" rel="noopener">GitHub&lt;/a> and
&lt;a href="https://pypi.org/project/pydeeplog/" target="_blank" rel="noopener">PyPI&lt;/a> (&lt;code>pip install pydeeplog&lt;/code>), with
&lt;a href="https://dtai.cs.kuleuven.be/deeplog/" target="_blank" rel="noopener">documentation&lt;/a>.&lt;/p>
&lt;/small>
&lt;/div>
&lt;/div>
&lt;p>In 2020, we wrote on this blog about
&lt;a href="../deepproblog/">DeepProbLog&lt;/a>, which lets a neural network supply the probabilities of the facts in a probabilistic logic program.
Building DeepProbLog meant building everything underneath it: a reasoner to prove the queries, a knowledge compiler to turn the proofs into circuits, and an evaluator to compute those circuits and their gradients.
Every neurosymbolic system since has done the same, each on its own.&lt;/p>
&lt;p>Deep learning stopped working that way a long time ago.
With PyTorch, you describe a model by composing layers, and the framework takes care of the tensors, the gradients and the GPU.
DeepLog does the same for neurosymbolic AI.
You state the logic of a model, as a formula or as a program, and DeepLog turns it into a differentiable PyTorch module that you combine with your networks and train like any other.&lt;/p>
&lt;div style="text-align: center;">
&lt;figure >
&lt;a href="https://github.com/ML-KULeuven/deeplog" target="_blank">
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/robin-manhaeve/deeplog/deeplog_hu3ab0dc21dec6fcce07f8c4b0043d96ad_24523_2000x2000_fit_lanczos_3.png" class="lazyload" alt="DeepLog logo" width="30%" height="756">
&lt;/a>
&lt;/figure>
&lt;p>
&lt;a href="https://github.com/ML-KULeuven/deeplog" target="_blank" rel="noopener">Code&lt;/a>
&lt;i class="fab fa-github pr-1 fa-fw">&lt;/i> ·
&lt;a href="https://dtai.cs.kuleuven.be/deeplog/" target="_blank" rel="noopener">Documentation&lt;/a>
&lt;i class="fas fa-book pr-1 fa-fw">&lt;/i> ·
&lt;a href="https://pypi.org/project/pydeeplog/" target="_blank" rel="noopener">PyPI&lt;/a>
&lt;i class="fab fa-python pr-1 fa-fw">&lt;/i> ·
&lt;a href="https://www.ijcai.org/proceedings/2026/980" target="_blank" rel="noopener">Paper&lt;/a>
&lt;i class="fas fa-file-alt pr-1 fa-fw">&lt;/i>&lt;/p>
&lt;/div>
&lt;h2 id="from-logic-to-a-pytorch-module">From logic to a PyTorch module&lt;/h2>
&lt;p>At the heart of DeepLog is the &lt;em>DeepLog language&lt;/em>, which we introduced in
&lt;a href="https://arxiv.org/abs/2508.13697" target="_blank" rel="noopener">The DeepLog Neurosymbolic Machine&lt;/a>.
It extends first-order logic with neural networks, and every formula in it names the algebra it is evaluated in: boolean, probabilistic, one of many fuzzy logics, or one you define yourself.&lt;/p>
&lt;figure id="figure-every-front-end-produces-a-formula-in-the-deeplog-language-the-compiler-lowers-it-into-one-pytorch-module-with-a-strategy-for-each-part-of-the-formula">
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/robin-manhaeve/deeplog/overview_hu034cd1ffedbb38c65fbb2645ba948730_170024_2000x2000_fit_lanczos_3.png" data-caption="Every front end produces a formula in the DeepLog language. The compiler lowers it into one PyTorch module, with a strategy for each part of the formula.">
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/robin-manhaeve/deeplog/overview_hu034cd1ffedbb38c65fbb2645ba948730_170024_2000x2000_fit_lanczos_3.png" class="lazyload" alt="How DeepLog turns a model into a PyTorch module: front ends such as a DeepProbLog program, a Logic Tensor Network or a semantic-loss constraint produce a DeepLog formula whose parts name their algebras; the compiler lowers the formula with a strategy such as knowledge compilation into an algebraic circuit, enumeration, sampling or one of your own; the result is a PyTorch module that runs on the CPU or GPU with the neural networks inside it." width="100%" height="660">
&lt;/a>
&lt;figcaption>
Every front end produces a formula in the DeepLog language. The compiler lowers it into one PyTorch module, with a strategy for each part of the formula.
&lt;/figcaption>
&lt;/figure>
&lt;p>Whatever you start from, DeepLog takes the same three steps:&lt;/p>
&lt;ol>
&lt;li>A &lt;strong>front end&lt;/strong> turns the model into a formula in the DeepLog language. For DeepProbLog, that is a Prolog engine that proves the queries; for semantic loss, a parser for the constraint. You can also write the formula yourself.&lt;/li>
&lt;li>The &lt;strong>compiler&lt;/strong> lowers the formula: it chooses, for each part, a strategy that turns it into tensor operations. By default, DeepLog computes probabilities exactly by knowledge compilation into &lt;em>algebraic circuits&lt;/em>, graphs of sums and products in the algebras the formula names, because that is the method we know best. But DeepLog is not tied to circuits: enumeration and sampling are strategies too, and other inference methods can be added as new ones.&lt;/li>
&lt;li>The result is one ordinary &lt;code>torch.nn.Module&lt;/code>, with the neural networks inside it. It runs as batched tensor operations on the GPU, next to the networks, instead of on the CPU between them; circuits, for example, are evaluated with
&lt;a href="https://github.com/ML-KULeuven/klay" target="_blank" rel="noopener">KLay&lt;/a>.&lt;/li>
&lt;/ol>
&lt;h2 id="what-to-compute-and-how">What to compute, and how&lt;/h2>
&lt;p>The most direct way to use DeepLog is to write a formula.
The one below asks for the probability of &lt;em>burglary or earthquake&lt;/em>, where a burglary happens with probability 0.8 and an earthquake with probability 0.3:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">deeplog&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">Compiler&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">enumeration&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">parse_formula&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">sampling&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">alarm&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">parse_formula&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;&amp;#34;&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">expectation(Burglary, Earthquake;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2"> p(Burglary,0.8)_probability times p(Earthquake,0.3)_probability):
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2"> =(Burglary,true)_boolean or =(Earthquake,true)_boolean
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">&amp;#34;&amp;#34;&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">Compiler&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">compile&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">alarm&lt;/span>&lt;span class="p">)()&lt;/span> &lt;span class="c1"># 0.86&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">Compiler&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">aggregation_builders&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="p">{&lt;/span>&lt;span class="s2">&amp;#34;expectation&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">enumeration&lt;/span>&lt;span class="p">})&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">compile&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">alarm&lt;/span>&lt;span class="p">)()&lt;/span> &lt;span class="c1"># 0.86&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">Compiler&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">aggregation_builders&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="p">{&lt;/span>&lt;span class="s2">&amp;#34;expectation&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">sampling&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">10_000&lt;/span>&lt;span class="p">)})&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">compile&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">alarm&lt;/span>&lt;span class="p">)()&lt;/span> &lt;span class="c1"># ≈ 0.86&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The &lt;code>_boolean&lt;/code> and &lt;code>_probability&lt;/code> annotations are the algebras: the condition is a boolean formula, and its distribution is a product of probabilities.&lt;/p>
&lt;p>As in PyTorch, where you write the forward pass and the framework derives the gradients, the formula says &lt;em>what&lt;/em> to compute and the compiler decides &lt;em>how&lt;/em>.
By default, DeepLog computes an expectation exactly, by knowledge compilation.
It can also enumerate every possible world, or estimate the value by sampling when a formula is too large to compile.
Choosing between them is one argument to the compiler, and a new inference method plugs in the same way.
Each result is a PyTorch module, so the gradients come for free.&lt;/p>
&lt;h2 id="deepproblog-revisited">DeepProbLog, revisited&lt;/h2>
&lt;p>A front end lets you write in a language you already know.
Here is the MNIST-addition program from our 2020 post, in the form DeepLog reads it:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-prolog" data-lang="prolog">&lt;span class="line">&lt;span class="cl">&lt;span class="nf">nn&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">mnist_classifier&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="nv">X&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="nv">Y&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mf">0..9&lt;/span>&lt;span class="p">])&lt;/span> &lt;span class="s">::&lt;/span> &lt;span class="nf">digit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nv">X&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nv">Y&lt;/span>&lt;span class="p">).&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nf">addition&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nv">X&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nv">Y&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nv">Z&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">:-&lt;/span> &lt;span class="nf">digit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nv">X&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nv">N1&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="nf">digit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nv">Y&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nv">N2&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="o">is&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nv">Z&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s">+&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nv">N1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nv">N2&lt;/span>&lt;span class="p">)).&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/robin-manhaeve/deeplog/addition_huacc37c9c630a44e61097dd49afdbff98_16162_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/robin-manhaeve/deeplog/addition_huacc37c9c630a44e61097dd49afdbff98_16162_2000x2000_fit_lanczos_3.png" class="lazyload" alt="The query addition of an image of a 3 and an image of a 5, with sum 8" width="40%" height="82">
&lt;/a>
&lt;/figure>
&lt;p>The network &lt;code>mnist_classifier&lt;/code> gives, for each image, a distribution over the digit it shows, and the rule says how digits add up.
DeepLog proves the query &lt;code>addition(i1, i2, Z)&lt;/code> and turns the proofs into a formula like the one above: the expected value, under the network&amp;rsquo;s distributions, of &amp;ldquo;the two digits add up to &lt;em>Z&lt;/em>&amp;rdquo;.
It compiles that formula into a PyTorch module that takes two images and returns a probability for each of the 19 possible sums, with the classifier inside it.
You train it with an ordinary PyTorch training loop, on the sums alone, and the classifier learns to recognise digits without ever seeing a digit label.
The
&lt;a href="https://dtai.cs.kuleuven.be/deeplog/examples/deepproblog.html" target="_blank" rel="noopener">DeepProbLog notebook&lt;/a> does this end to end.&lt;/p>
&lt;p>Because the compiled module is batched tensor code, it is much faster than the original DeepProbLog.
Here is the average time to evaluate the network and the circuit for one query on MNIST addition, where the numbers to add have 1 to 4 digits:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align:right">Digits&lt;/th>
&lt;th style="text-align:right">DeepProbLog (CPU)&lt;/th>
&lt;th style="text-align:right">DeepLog (CPU)&lt;/th>
&lt;th style="text-align:right">DeepLog (GPU)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align:right">1&lt;/td>
&lt;td style="text-align:right">6.1 ms&lt;/td>
&lt;td style="text-align:right">11 µs&lt;/td>
&lt;td style="text-align:right">0.56 µs&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">2&lt;/td>
&lt;td style="text-align:right">35 ms&lt;/td>
&lt;td style="text-align:right">41 µs&lt;/td>
&lt;td style="text-align:right">1.5 µs&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">3&lt;/td>
&lt;td style="text-align:right">132 ms&lt;/td>
&lt;td style="text-align:right">2.4 ms&lt;/td>
&lt;td style="text-align:right">0.15 ms&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:right">4&lt;/td>
&lt;td style="text-align:right">–&lt;/td>
&lt;td style="text-align:right">196 ms&lt;/td>
&lt;td style="text-align:right">54 ms&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For single-digit addition, DeepLog is over 500 times faster on a CPU, and over 10,000 times faster on a GPU (an NVIDIA L40S).
The original DeepProbLog handles one query at a time; DeepLog evaluates a whole batch at once.&lt;/p>
&lt;h2 id="one-framework-for-the-alphabet-soup">One framework for the alphabet soup&lt;/h2>
&lt;p>Because DeepLog is a framework and not one more system, it can also bring the existing systems together.
Neurosymbolic AI has grown into an alphabet soup: DeepProbLog, DeepStochLog, DeepSoftLog, NeurASP, Scallop, Logic Tensor Networks, semantic loss, and many more.
Each comes with its own language, its own semantics and its own engine, so comparing two of them means comparing two code bases, and an idea that works in one has to be reimplemented before it can be tried in another.&lt;/p>
&lt;p>Look closely, and most of these systems differ along a handful of axes:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>How you write the knowledge.&lt;/strong> A Prolog program in DeepProbLog, first-order formulas in Logic Tensor Networks, a constraint in conjunctive normal form for semantic loss.&lt;/li>
&lt;li>&lt;strong>What the connectives mean.&lt;/strong> In a probabilistic logic, &lt;em>A or B&lt;/em> is the probability that at least one of them holds. In a fuzzy logic, it is a function of the two truth values, such as their maximum.&lt;/li>
&lt;li>&lt;strong>Where the neural network sits.&lt;/strong> Inside the model, where its outputs become the probabilities of facts, or outside it, where the logic becomes a term in the loss.&lt;/li>
&lt;/ul>
&lt;p>In DeepLog, each of these is a choice within one framework: a front end, an algebra, and where the networks go.
ProbLog, DeepProbLog, semantic loss and Logic Tensor Networks are already implemented on DeepLog.
Reading the connectives in a fuzzy logic instead of in probability, for example, gives you Logic Tensor Networks: our
&lt;a href="https://dtai.cs.kuleuven.be/deeplog/examples/ltn.html" target="_blank" rel="noopener">LTN notebook&lt;/a> reproduces part of the LTN tutorial this way.
Comparing two systems becomes comparing two formulas, compiled by the same compiler and run on the same hardware.&lt;/p>
&lt;h2 id="who-is-it-for">Who is it for?&lt;/h2>
&lt;p>We built DeepLog for two kinds of users.&lt;/p>
&lt;p>&lt;strong>Machine learning practitioners.&lt;/strong> A DeepLog module is a PyTorch module, so you can add logic to an existing model without rewriting your training code.
The
&lt;a href="https://dtai.cs.kuleuven.be/deeplog/examples/semantic_loss.html" target="_blank" rel="noopener">semantic loss notebook&lt;/a>, for example, adds a logical constraint to an MNIST classifier as a term in its loss.
Every module declares symbolic shapes for its inputs and outputs, so connecting two modules that don&amp;rsquo;t fit raises an error instead of producing a silent shape bug.&lt;/p>
&lt;p>&lt;strong>Neurosymbolic researchers.&lt;/strong> You no longer have to write a reasoner, a knowledge compiler and a GPU evaluator before you can try an idea.
A new system is built from DeepLog&amp;rsquo;s parts, the way a new architecture is built from PyTorch&amp;rsquo;s layers, and it runs on the same compiler as the systems it is compared with.
A new inference method becomes a lowering strategy, and every front end can use it at once.&lt;/p>
&lt;h2 id="try-it">Try it&lt;/h2>
&lt;div class="codeblock codeblock-inline codeblock-highlighted" id="codeblock-0">&lt;div id="codeblock-0-code" class="codeblock-body">&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pip install pydeeplog&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/div>&lt;button type="button" class="btn btn-sm codeblock-btn js-codeblock-copy" data-target="codeblock-0-code" aria-label="Copy to clipboard" title="Copy">
&lt;i class="fas fa-copy" aria-hidden="true">&lt;/i>
&lt;span class="codeblock-btn-label">Copy&lt;/span>
&lt;/button>&lt;/div>
&lt;p>The
&lt;a href="https://dtai.cs.kuleuven.be/deeplog/" target="_blank" rel="noopener">documentation&lt;/a> teaches DeepLog through notebooks, from symbolic shapes to MNIST addition, in two reading paths: one
&lt;a href="https://dtai.cs.kuleuven.be/deeplog/ml_practitioner.html" target="_blank" rel="noopener">for ML practitioners&lt;/a> and one
&lt;a href="https://dtai.cs.kuleuven.be/deeplog/nesy_developer.html" target="_blank" rel="noopener">for neurosymbolic developers&lt;/a>. Every notebook opens in Colab.
At IJCAI 2026 in Bremen, we presented DeepLog in the demo track and in a half-day tutorial, whose
&lt;a href="https://dtai.cs.kuleuven.be/tutorials/deeplog/" target="_blank" rel="noopener">materials are online&lt;/a>.
Questions, bug reports and ideas are welcome as
&lt;a href="https://github.com/ML-KULeuven/deeplog/issues" target="_blank" rel="noopener">GitHub issues&lt;/a>.&lt;/p>
&lt;p>DeepLog is developed at DTAI as part of the ERC Advanced Grant project DeepLog (grant agreement No. 101142702).&lt;/p></description></item></channel></rss>