wikillm

Concept · 1 paper · updated 2026-10-31

Differentiable fuzzy logic

Gives logical formulas truth values in [0, 1] and replaces AND, OR, NOT, implication and quantifiers with smooth operators, so a knowledge base becomes a training objective. One paper so far: Logic Tensor Networks, with stable product operators and p-mean quantifiers. Choices: operator family, quantifier exponents, masks, refutation. Results are author-reported.

fuzzy-logicneurosymbolic-aifirst-order-logicknowledge-representation

Markdown5 min read

AI-compiled overview, updated 2026-10-31, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

Overview

Logical rules are exact, but gradient descent needs a number that changes smoothly with the parameters. Differentiable fuzzy logic gives every formula a truth value in [0, 1] and defines each connective and quantifier as a smooth function of its operands 2012.13635 §2.1 2012.13635 §2.2. A knowledge base then has one satisfiability score, and training maximises it 2012.13635 §3.2. In practice the loss is 1 minus that score, averaged over mini-batches 2012.13635 §4.

The shared pattern is: ground the variables on data, evaluate each formula to a truth value, aggregate the axioms, and take a gradient step. Every variant differs in which operators it uses and how strictly the quantifiers aggregate. The operators must keep gradients usable, which many standard fuzzy operators do not 2012.13635 §2.4.

Variants

The only compiled paper is the Logic Tensor Networks (LTN) framework. Its design is the stable product configuration, used in every example in the paper 2012.13635 §2.4 2012.13635 §4. Card: Logic Tensor Networks.

Stable product configuration

  • Connectives. Conjunction is the product of truth values. Disjunction is the probabilistic sum a + b − ab. Negation is 1 − a. Implication is Reichenbach's, 1 − a + ab 2012.13635 §2.4. Before each operator, inputs are shifted away from exactly 0 or 1 by a small constant 2012.13635 §2.4.
  • Quantifiers. The universal quantifier is a p-mean of the errors 1 − a, which approximates a minimum. The existential quantifier is a p-mean of the truth values, which approximates a maximum. Both need p ≥ 1 2012.13635 §2.4.
  • Free variables become axes. A formula with several free variables is evaluated on the product of their instance sets, and each quantifier aggregates over the axes it binds 2012.13635 §2.2.2 2012.13635 §2.2.3.
  • Diagonal quantification. Diag(x, y) pairs the i-th instance of x with the i-th instance of y, so it needs equal counts and is not the same as stacking the variables into one 2012.13635 §2.2.3.
  • Guards. A mask restricts a quantifier to the instances it selects. Masked-out instances give no gradient. The guarded form is not the same as writing the mask as an implication inside the quantifier 2012.13635 §2.3.

Learning and reasoning on top

  • Satisfiability. A formula aggregator combines the truth values of all axioms into one score 2012.13635 §3.1.4. Learning maximises it over the grounding parameters, optionally with a regulariser 2012.13635 §3.2.
  • Query. After training, the paper defines four query types, for formulas and terms, on the training instances or on unseen ones 2012.13635 §3.3.
  • Reasoning. A formula follows from a knowledge base at threshold q, with 1/2 < q < 1, if every grounding that satisfies the knowledge base at least to q also gives the formula at least q 2012.13635 §3.4. Two approximations are given. Querying after learning checks the formula on the best grounding found. Refutation searches for a grounding that satisfies the knowledge base but makes the formula fall below q, using a soft penalty on the knowledge base 2012.13635 §3.4.

When to use which

SituationUseWhy
A standard deep net must respect rules, and you want plain gradient trainingStable product operators with p-mean quantifiersIt is the configuration the paper uses throughout and the one it argues keeps gradients usable 2012.13635 §2.4 2012.13635 §4
Labels exist only as a derived quantity, such as the sum of two digitsDiagonal quantification plus an existential quantifier whose p rises during trainingA fixed p = 2 from the start gave poor multi-digit results, and a rising schedule to p = 6 is preferred 2012.13635 §4.4. Reported single-digit accuracy is 98.04 ± 0.13 against 97.20 ± 0.45 for DeepProbLog, with 30 000 training examples 2012.13635 tab. 2
Very little labelled data, with the rules carrying much of the signalThe same setup, trained on the small splitWith 3 000 training images the paper reports 93.49 ± 0.28 against 92.18 ± 1.57 for DeepProbLog 2012.13635 tab. 2. Intervals overlap for the multi-digit rows, so treat the gaps as small
Multi-label task with positive examples onlyWrite the exclusion axioms explicitlyA sigmoid output does not enforce exclusivity. Single-label tasks with a softmax already have it 2012.13635 §4.2 2012.13635 §4.3
A rule applies only to a subset of instancesA guarded quantifier, not an implication inside the quantifierMasked-out instances get no gradient, and an empty mask gives 1 for ∀ and 0 for ∃ 2012.13635 §2.3
You must check whether a rule follows from the knowledge baseRefutation at a threshold qQuerying after learning missed a counterexample that refutation found in the paper's example 2012.13635 §4.8 2012.13635 §3.4
Step time is part of the budgetBudget for the overheadThe only timing reported is about 5.36 ms per step against 2.72 ms for the CNN baseline, at batch 32 2012.13635 tab. 1
Formulas with many free variablesDiagonal quantification or masksValues grow as the product of the instance counts, so cost rises quickly 2012.13635 §2.2.2

Implementation sketch

The common core is the operator set, the quantifier aggregation, and the satisfaction loss. Variants differ in the operators, the exponents and the masks. The sketch uses the stable product configuration.

Pseudocode
# Shift a truth value away from its boundary  [arxiv:2012.13635 §2.4]
# The paper does not state the constant; the card records the released code's value
def shift(a, eps):
    # keeps the value strictly inside (0, 1) so gradients do not vanish
    return (1 - eps) * a + eps

# Connectives on truth values in [0, 1], stable product  [arxiv:2012.13635 §2.4]
def conj(a, b):
    # product of the shifted values
    return shift(a, eps) * shift(b, eps)

def disj(a, b):
    # probabilistic sum on values shifted away from 1
    x, y = (1 - eps) * a, (1 - eps) * b
    return x + y - x * y

def neg(a):
    # standard complement
    return 1 - a

def implies(a, b):
    # Reichenbach: 1 - a + a*b
    return neg(shift(a, eps)) + shift(a, eps) * (1 - eps) * b

# Quantifiers over the instances of a variable  [arxiv:2012.13635 §2.4]
def forall(truths, p):
    # p-mean of the errors, approximates min; p >= 1
    errors = 1 - truths
    return 1 - mean(errors ** p) ** (1 / p)

def exists(truths, p):
    # p-mean of the values, approximates max; p >= 1
    return mean(truths ** p) ** (1 / p)
Pseudocode
# Train by maximising satisfaction of the knowledge base  [arxiv:2012.13635 §3.2]
for batch in data:
    # ground the data variables on this batch and evaluate each axiom
    truths = [truth(axiom, theta, batch) for axiom in kb]
    # formula aggregator over the axioms  [arxiv:2012.13635 §3.1.4]
    sat = aggregate(truths)
    # loss = 1 - Sat, minimised with Adam at learning rate 0.001  [arxiv:2012.13635 §4]
    theta = adam_step(theta, grad(1 - sat, theta))

Contradictions

None between papers, as only one card is compiled for this concept. The paper's text and its released code differ in several settings, such as the existential schedule in the digit-addition experiments and the exponents in the smokes-friends example. Those differences are listed on the card's Paper vs code section; check them before reimplementing. Logic Tensor Networks

Papers

  • Logic Tensor Networks: the Real Logic language with stable product operators, p-mean quantifiers, diagonal quantification, satisfaction-based learning and refutation-based reasoning, with author-reported MNIST addition results.

Source and license

Compiled from the papers listed on this page, all published under CC BY, CC BY-SA or CC0, with citations. See each paper's page for its authors and license.