Declarative Neural Predicates
- Declarative neural predicates are functions defined by neural networks that yield probabilistic truth values and integrate with logic programming.
- They enable neuro-symbolic reasoning by linking symbolic logic with gradient-based training, query optimization, and cost-aware evaluation.
- Systems like DeepProbLog and BlazeIt showcase their practical use in tasks such as image classification, aggregate queries, and compositional reasoning.
A declarative neural predicate is a neural network-defined function or relation that can be referenced within a symbolic, logic-based, or SQL-style language in a manner that exposes both its semantics and its invocation cost, enabling reasoning, learning, and optimization alongside other declarative constructs. Unlike procedural calls or black-box UDFs, declarative neural predicates can integrate with logic programming, probabilistic reasoning, query optimization, or unification, thus bridging statistical learning and symbolic manipulation in neuro-symbolic and data analytics systems.
1. Formal Definitions and Syntax of Declarative Neural Predicates
In neuro-symbolic programs and declarative query languages, a neural predicate generalizes the concept of a logical predicate by mapping symbolic or perceptual input to probabilistic or numeric truth values via a neural network module. This can take several forms depending on semantic context:
- Probabilistic Logic Setting: A neural predicate is a learned function of the form
where is the input domain (e.g., images, embeddings) and gives the probabilistic truth value for a symbolic atom such as . The predicate is integrated into the logic program's possible-worlds semantics, such that for any ground atom , the probability is determined by the neural model output (Hinnerichs et al., 2024, Manhaeve et al., 2018, Geh et al., 2023).
- ASP and Logic Programming: The predicate is declared via a Neural Annotated Disjunction Rule (NADR), where for example: 4 associates a neural classifier with the predicate symbol, generating a probability distribution over possible values (Geh et al., 2023).
- Declarative SQL Extensions/Analytics: In FrameQL (BlazeIt system), neural predicates appear in WHERE/HAVING clauses as SQL-like expressions such as: 5 which are evaluated by neural models (object detector/classifier). The language grammar is extended so that a condition can be either logical or a neural predicate: 6 These can return booleans or real-valued scores depending on context (Kang et al., 2018).
- First-Order Logic Extensions: In model-query languages, neural predicates can be referenced in FO or FO(SUM) formulas either as black-box functions (constraint query) or as components in summations over weighted graphs or circuits, analogous to aggregate SQL expressions (Grohe et al., 2024).
2. Semantics, Compositionality, and Integration in Logic Programs
Declarative neural predicates are tightly coupled with the semantics of the logic or data-processing system. They are not mere functional links to deep networks; rather, their probabilistic outputs become logical facts, and structured queries can reason over their values.
- Possible-Worlds Semantics: Each possible grounding of a neural predicate is treated as a stochastic fact; possible worlds are constructed with probabilities assigned by the neural outputs, and probabilistic inference reduces to weighted model counting or answer set enumeration over all such worlds (Manhaeve et al., 2018, Geh et al., 2023).
- Prototype and Encoder-Decoder Architectures: In frameworks such as DeclDeepProblog, neural predicates are defined relationally by introducing learnable prototype vectors associated with symbolic classes (e.g., digits), plus neural encoders/decoders that map between sensory instances and prototypes. The logic program can invoke either discriminative (encode→similarity) or generative (decode) branches, and unification in logic triggers the correct neural operation (Hinnerichs et al., 2024).
- Relational Compositionality: Neural predicates may be higher-arity (e.g., ) and used in learned logic rules, allowing symbolic constraints, arithmetic, and relational composition alongside neural outputs. For example: 7 (Geh et al., 2023, Manhaeve et al., 2018).
- SQL/FrameQL Analytics: Neural predicates enable declarative query optimization, as the system is aware of the model's invocation cost and can choose between exact and approximate (proxy) evaluation strategies, enabling both error-bounded and limit queries at the language level (Kang et al., 2018).
3. Learning and Inference Paradigms
Training declarative neural predicates involves end-to-end optimization across the logic/statistics/symbolic boundary:
- Gradient-Based Training via Logic Program Compilation: For programs integrating neural predicates, the overall training objective is typically the log-likelihood of observed groundings or queries. The symbolic engine (e.g., DeepProbLog, dPASP) compiles the proof or answer set structure into circuits or enumerations, enabling backpropagation through neural modules, aggregate probabilities, and circuit flows (Manhaeve et al., 2018, Geh et al., 2023, Hinnerichs et al., 2024).
- Handling Weak Supervision and Latent Labels: Observations may be partial or distant (e.g., only sum of digits observed, not individual digits), necessitating marginalization over all possible latent groundings, with gradients accumulating over all consistent interpretations (Geh et al., 2023).
- Symbolic-Controlled Neural Calls: During both learning and inference, the logic engine determines call patterns to encoder, decoder, or similarity modules based on query structure and variable binding, allowing for both discriminative and generative reasoning without modifying neural weights for each query (Hinnerichs et al., 2024).
- Query Optimization in Video Analytics: BlazeIt leverages neural predicates to optimize aggregate queries (using neural networks as control variates for variance reduction and error-bounded sampling) and limit queries (using proxy-predicted scores for prioritized extraction), integrating model cost and accuracy targets into the declarative optimization plan (Kang et al., 2018).
4. Expressiveness, Hierarchical Structure, and Limitations
Declarative neural predicates extend the expressiveness of symbolic systems, but their capabilities and limitations can be formally characterized:
- Emergent Predication in Neural Models: The hidden states of neural sequence models and readers can be interpreted as encoding atomic formulas (where is a predicate/property and is an entity/constant), often factorizing into statement and entity subspaces. This supports the integration of learned vectors as declarative predicate instances and informs design principles for more interpretable architectures (Wang et al., 2016).
- Order of Logic vs. Network Depth: Classical feedforward networks of depth 0 can faithfully represent only predicates up to 1-th order logic; higher-order predicates lie in the null space of the model and are unrecoverably lost after tokenization and embedding. Thus, a hard expressivity boundary exists: for instance, 2 layers cannot represent 3-order quantification or counting predicates exactly. Remedying this requires either increased depth, modular symbolic extensions, or external symbolic buffers (Cochran, 28 Jul 2025).
- Black-box vs. White-box Declarative Querying: Query languages can treat neural modules (black-box constraint logic) or their internal structure (white-box first-order with summation, akin to SQL with aggregates). For fixed-depth, piecewise-linear networks, white-box query languages can subsume black-box constraint queries for all linear properties, yielding practical uniformity of expressive power for interpretable query interfaces (Grohe et al., 2024).
5. Practical Systems and Implementation Architectures
Several concrete systems implement and exploit declarative neural predicates to enable scalable, expressive, and trainable neuro-symbolic reasoning:
| System | Host Framework | Neural Predicate Declaration | Inference/Learning Integration |
|---|---|---|---|
| DeepProbLog | ProbLog | nn(name, Vars, Labels) :: ... ; ... |
Weighted model counting, circuit-based backprop |
| dPASP | ASP (clingo) | ?::pred(X,...,{labels}) as @net ... |
Stable-model enumeration, max-entropy semantics |
| DeclDeepProblog | DeepProbLog (ext.) | Relational prototypes, encoder/decoder | Problog unification and symbolic control |
| BlazeIt/FrameQL | SQL extension | NN in WHERE/HAVING conditions | Rule-based optimization, proxy/control variate |
Each system supports the declarative blending of logic rules and learned neural modules, typically enabling end-to-end training and reasoning across both subsymbolic and symbolic domains (Manhaeve et al., 2018, Geh et al., 2023, Hinnerichs et al., 2024, Kang et al., 2018).
6. Illustrative Applications and Experimental Findings
Declarative neural predicates have enabled a variety of applications:
- Distant Supervision Tasks: Learning digit addition from images with only the sum observed, as in DeepProbLog and dPASP. These approaches achieve task-level accuracy (sum classification ≈ 98%, digit classification ≈ 98%) while expressing the logic and learning in a concise, fully declarative program (Manhaeve et al., 2018, Geh et al., 2023).
- Video Analytics at Scale: BlazeIt supports high-level SQL-like queries such as error-bounded frame counting and cardinality-limited event selection, yielding up to 83x speedups over naive baselines for limit queries and 10–100x reduction in model invocations for aggregate queries (Kang et al., 2018).
- Unification-Driven Query Reuse: Declarative neural predicates in DeclDeepProblog enable generative queries (e.g., "generate an image of digit 3"), compositional queries ("which two digits sum to 7?"), and cross-modal extensions, supporting zero-shot inference without retraining (Hinnerichs et al., 2024).
7. Broader Implications and Future Directions
The declarative design of neural predicates enables clean separation between knowledge representation and inference, supports arbitrary query answering, and is conducive to multi-modal, continual, and compositional reasoning (Hinnerichs et al., 2024). Practical extensions include:
- Dynamic and Hierarchical Prototypes: For expressive, compositional, and continually growing predicate vocabularies.
- Hybrid Symbolic-NN Architectures: Leveraging explicit logic layers, memory-augmented modules, or iterative unrolling to surpass depth-based logic limitations (Cochran, 28 Jul 2025).
- Expanding Declarative Query Languages: Fusing constraint-logic and SQL paradigms for white- and black-box neural model introspection, verification, and management (Grohe et al., 2024).
- Cognitive and Neuroscientific Connections: Predicate learning frameworks employing neural oscillations and dynamic assemblies demonstrate representational independence and compositional binding in systems that mirror cortical patterns (Martin et al., 2018).
Taken together, declarative neural predicates provide a principled, general-purpose mechanism for neuro-symbolic learning and reasoning, bridging statistical modeling and symbolic abstraction with rigorously formalized semantics and growing practical impact across AI and data systems.