[Paper Review] Siamese recurrent networks learn first-order logic reasoning and exhibit zero-shot compositional generalization
This paper demonstrates that Siamese Recurrent Neural Networks (SRNs) with LSTM and GRU cells can learn first-order logic entailment relations in a synthetic, compositional language without explicit syntactic or semantic priors. The models achieve near-perfect zero-shot compositional generalization on unseen sentence lengths and novel vocabulary, outperforming recursive networks and showing robustness to semantic reassignment of ontologies.
Can neural nets learn logic? We approach this classic question with current methods, and demonstrate that recurrent neural networks can learn to recognize first order logical entailment relations between expressions. We define an artificial language in first-order predicate logic, generate a large dataset of sample 'sentences', and use an automatic theorem prover to infer the relation between random pairs of such sentences. We describe a Siamese neural architecture trained to predict the logical relation, and experiment with recurrent and recursive networks. Siamese Recurrent Networks are surprisingly successful at the entailment recognition task, reaching near perfect performance on novel sentences (consisting of known words), and even outperforming recursive networks. We report a series of experiments to test the ability of the models to perform compositional generalization. In particular, we study how they deal with sentences of unseen length, and sentences containing unseen words. We show that set-ups using LSTMs and GRUs obtain high scores on these tests, demonstrating a form of compositionality.
Motivation & Objective
- To investigate whether recurrent neural networks can learn compositional logical reasoning in first-order predicate logic without symbolic priors.
- To test if deep learning models can generalize beyond memorization, particularly to novel sentence structures and unseen vocabulary.
- To develop a scalable, automatic data generation pipeline for logical entailment tasks using formal logic and theorem proving.
- To evaluate the compositional generalization capacity of RNNs using zero-shot tests on unseen lengths and novel words.
- To compare Siamese RNNs with recursive networks in learning logical inference, focusing on architectural inductive biases.
Proposed method
- Define an artificial language using first-order logic (FOL) with four lexical categories: quantifiers, nouns, verbs, and adverbs.
- Generate sentences via a phrase structure grammar and automatically infer entailment relations using a standard first-order theorem prover.
- Design a Siamese neural architecture that processes pairs of sentences and predicts one of seven entailment relations (entailment, contradiction, etc.).
- Train recurrent networks (LSTM, GRU) on sentence pairs, using shared weights to compare representations in a Siamese setup.
- Apply zero-shot generalization tests by replacing vocabulary with unseen terms or altering ontology structure while preserving syntactic and semantic structure.
- Use word embeddings as input features, with no explicit syntactic parsing or symbolic control structures.
Experimental results
Research questions
- RQ1Can recurrent neural networks learn to recognize first-order logic entailment relations without any prior symbolic inductive bias?
- RQ2To what extent can Siamese RNNs generalize to sentences of unseen lengths during inference?
- RQ3Can the models generalize to sentences containing entirely novel vocabulary not seen during training?
- RQ4How robust are the models to semantic reassignment of the noun ontology, such as shifting from human groups to animals or religions?
- RQ5Do Siamese RNNs outperform recursive networks designed for hierarchical structure in logical reasoning tasks?
Key findings
- Siamese Recurrent Networks (SRNs) with GRU and LSTM cells achieve 97.2% test accuracy on entailment recognition for novel sentences composed of known words.
- The GRU model maintains 86.7% accuracy after replacing all training nouns with completely unseen ones (r₄), demonstrating strong zero-shot compositional generalization.
- Even when the noun ontology is restructured into semantically unrelated domains (e.g., animals, religion, America), the GRU model retains 56.3–59.0% accuracy, significantly above chance for a seven-class problem.
- The performance of SRNs surpasses that of recursive neural networks, despite the latter being explicitly structured to model syntactic hierarchies.
- The models generalize effectively to unseen sentence lengths, indicating that they have learned compositional rules rather than memorizing patterns.
- The results suggest that recurrent networks can learn and apply compositional logical rules in a formal language, challenging the view that such reasoning is fundamentally beyond deep learning.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.