6.5.9 · D4Research Frontiers & Practice

Exercises — Neuro-symbolic AI

2,843 words13 min readBack to topic

Level 1 — Recognition

Recall Solution L1.1

Recall the two columns from the parent note. Neural nets are great at perception but weak at logical consistency, sample efficiency, and systematic reasoning. Symbolic systems are great at exact rules but weak at perception and robustness to noise.

  • (a) symbolic-only weakness — symbolic engines can't read pixels.
  • (b) neural-only weakness — no built-in logical consistency, so mutually-exclusive labels can both fire.
  • (c) neural-only weakness — a symbolic rule for addition needs zero examples; the neural net needs many.
  • (d) symbolic-only weakness — hand-coded rules are brittle to noise; neural nets are the robust half.
Recall Solution L1.2

Using the glossary taxonomy above: the neural part runs first and hands symbols to the reasoner, which then reasons over them. That is Neural-Symbolic. It is not Symbolic-Neural (symbolic knowledge constraining neural training), and not Hybrid (bidirectional coupling where both inform each other every step).


Level 2 — Application

Recall Solution L2.1

Here is a gate: it lets the penalty through only when the sum exceeds 1 (a real violation), and clamps to 0 otherwise so satisfied constraints add nothing. Since , the gate passes it: . Gradient descent will now push the network to lower or until their sum drops to .

Recall Solution L2.2

An implication is violated exactly when is confident but is not, i.e. . The gap measures how much. Backprop can reduce it by (i) decreasing (be less sure of pneumonia) or (ii) increasing (raise opacity confidence) — whichever the data loss allows.

Recall Solution L2.3

These are chosen because they are smooth (differentiable), and they reduce to real logic at the corners — try and you get back / style truth tables.

  • AND: .
  • OR: .
  • NOT : .

Level 3 — Analysis

Recall Solution L3.1

The AND (product) — for each intermediate we need both premises true, so we multiply:

  • via :
  • via :

The inner max (existential "there exists some ") — we only need one connecting middle person, so we take the best path: .

The outer max (OR with what we already knew) — combine the new derivation with the old value: .

So . Notice the weaker link in each path caps its strength (product punishes uncertainty), and the whole rule reports the strongest available chain.

Recall Solution L3.2

(a) find(cube) peaks attention on the cube at with weight — it is a detector answering "where is the cube?". (b) left_of shifts the attention mass to the left, so the new peak lands on the object sitting left of the cube (at , weight ). It answers "given this reference region, where is left of it?". (c) No retraining needed. The whole point of modularity is reuse: find and query_color are independent, trained-once modules. Only the composition (which spatial module we slot in) changes. Swapping left_ofright_of just picks a different pre-trained spatial module.

Recall Solution L3.3

We relax logic because we want to train with gradient descent, and gradient descent needs a slope everywhere. The crisp has a flat top and a kink: at the derivative with respect to the larger input is exactly . A zero gradient means backprop sends no learning signal to that input — it is "invisible" to the optimizer. The product has and : both inputs get a signal, proportional to the other's confidence. That is why the product t-norm is preferred for learning even though is a valid logical AND for inference.


Level 4 — Synthesis

Recall Solution L4.1

(a) Compute each violation with its gate:

  • .
  • (rule 2 is already satisfied!). (b) Only rule 1 contributes. Its penalty is while active, so Both partials equal . Decreasing either or lowers the loss at rate per unit. (The big weight is a red herring — its rule is inactive.)
Recall Solution L4.2

Two candidate middle people :

  • via Bea:
  • via Dan:

Existential max: . The Ann→Bea→Cy chain wins because both of its links are strong; the product punishes the weak link on the other path.


Level 5 — Mastery

Recall Solution L5.1

Stage B. , so violation . Penalty . (This large penalty is exactly what teaches the detector to stop claiming "both ball and cube here".)

Stage C, step 1 (AND = product). The rule needs both ball and red to be true, so we multiply the two truth degrees:

Stage C, step 2 (OR = ). The next rule fires if throwable or heavy holds, so we use the t-norm OR with and : The pipeline moved from raw pixels () → a consistency-corrected detector → chained logical conclusions, each step differentiable so the whole thing trains end-to-end. That is the entire promise of Neuro-symbolic AI in one worked example.

Recall Solution L5.2

(a) . A false premise kills the AND — matches crisp logic. (b) . A true disjunct makes the OR certainly true — matches crisp logic. (c) The inner over an empty set is taken as (nothing derived), so . With no connecting , no new fact is created — correct. (d) . Maximum uncertainty is its own negation — the fixed point of NOT, exactly where a truth value is least informative. (e) At the boundary the gap is , so . This is the hinge of : for sums the penalty is flat at zero (rule satisfied); the instant the sum crosses the penalty rises linearly with slope . So the constraint is "free" right up to the equality line and only starts pulling once the two probabilities genuinely over-commit past a total of .


Recall Self-test: state the rule from memory

AND (product t-norm) ::: OR (product t-norm) ::: NOT ::: Implication violation ::: Mutual-exclusivity violation ::: Why product AND over for learning ::: gives zero gradient to the larger input; product gives nonzero gradient to both Total loss shape :::

See also: 6.4.02-Explainable-AI (why symbolic outputs are interpretable) · 6.5.01-Few-Shot-Learning (symbolic priors buy sample efficiency) · 6.2.04-Knowledge-Graphs (where the facts live) · 4.3.05-Attention-Mechanisms (the find module's heatmaps) · 6.5.07-Reinforcement-Learning-Advanced · 6.5.10-Causal-Inference · 6.1.03-Neural-Network-Architectures.