Learning Symbolic Rules for Reasoning in Quasi-Natural Language

Symbolic reasoning , rule-based symbol manipulation , is a hallmark of human intelligence . However , rule-based systems have had limited success competing with learning-based systems outside formalized domains such as automated theorem proving . We hypothesize that this is due to the manual construction of rules in past attempts . In this work , we ask how we can build a rule-based system that can reason with natural language input but without the manual construction of rules . We propose MetaQNL , a “ Quasi-Natural ” language that can express both formal logic and natural language sentences , and MetaInduce , a learning algorithm that induces MetaQNL rules from training data consisting of questions and answers , with or without intermediate reasoning steps . Our approach achieves state-of-theart accuracy on multiple reasoning benchmarks ; it learns compact models with much less data and produces not only answers but also checkable proofs . 1 INTRODUCTION . Symbolic reasoning—rule-based symbol manipulation—is a core component of human intelligence ( Mercier & Sperber , 2017 ) . It has been a core part of computer science research , and has achieved significant success in domains such as software verification ( Darvas et al. , 2005 ) and theorem proving ( Kovács & Voronkov , 2013 ; McCune , 1997 ) . However , such success has been restricted to domains amenable to rigid , precise formalization . It remains a challenge how to translate such success into “ informal ” domains such as reasoning with common sense knowledge and natural language input . Prior attempts to build rule-based systems , which rely on manually constructed rules , have achieved limited success and tended to produce brittle systems . Deep learning provides an attractive alternative that can easily sidestep the question of representation . A deep network can be trained to perform a reasoning task by directly predicting the answer without explicit symbol manipulation ( Clark et al. , 2020 ) . However , deep networks can require a large amount of training data and can suffer from poor generalization . More importantly , unlike symbolic systems , a deep network is a black box that is hard to interpret , inspect , and verify . Such lack of interpretability can be undesirable in certain applications , especially those critical to safety and security . In this work , we ask how to build a rule-based system that reasons symbolically but can work with natural language and handle domains difficult to formalize . Such a system would perform reasoning by explicit symbol manipulation based on known rules , therefore more interpretable and verifiable , but at the same time flexible enough to handle natural language input . At a glance , this may appear a large departure from the conventional wisdom that learning-based systems , particularly deep networks , are far superior to rule-based systems , as history has demonstrated repeatedly . However , we hypothesize that this conventional wisdom is incorrect because it assumes a false dichotomy between using learning and using rules ; rule-based systems underperformed not because they were rule-based , but because it is difficult to construct rules manually . Further , we hypothesize learning rules from data is key to building effective rule-based systems , but it may require a different kind of learning than gradient descent . The goal of this work is thus to develop a method that automatically learns symbolic rules from data to enable rules-based reasoning with natural language . This poses two main questions . First , what is the system of rules—the basic structures that define what symbols and manipulations allowed—such that it is compatible with not only formal logic but also natural language ? Second , what is the learning algorithm that induces a set of rules from training data ? In this work , we take initial steps toward answering both questions . We propose MetaQNL , a formal symbolic system we call a “ Quasi-Natural Language ” , which is compatible with not only rigorous logical inference but also natural language expressions . We also propose MetaInduce , a learning algorithm that induces MetaQNL rules from training data that consists of questions and answers , with or without intermediate reasoning steps . MetaQNL : a Symbolic System in Quasi-Natural Language . In MetaQNL , a sentence is a sequence of words and variables ( “ The elephant is [ X ] ” ) . They also include ordinary English sentences without variables . A rule consists of multiple sentences as its premises ( “ The elephant is [ X ] ” , “ If something is [ X ] then it [ Y ] ” ) and one sentence as its conclusion ( “ The elephant [ Y ] ” ) . When applying the rule in reasoning , variables are substituted with concrete sentences ( [ X ] → strong , [ Y ] → likes cats ) . Therefore , rules capture abstract knowledge that is independent of specific instances—the above rule holds whether [ Y ] is “ likes cats ” or “ is sleepy ” . Such abstraction is essential for reasoning in both humans and machines ( Marcus & Davis , 2020 ) . Fig . 1 illustrates how sentences and rules are used in reasoning . Starting from known sentences ( assumptions ) , we apply rules to derive new sentences until the goal is reached . At each step , we substitute the variables in a rule with concrete sentences . This process resembles Metamath ( Megill & Wheeler , 2019 ) , a formal language developed for formalizing mathematical proofs , where each step also consists of selecting a theorem and instantiating it with a suitable substitution . So we refer to the reasoning process as theorem proving and the result in Fig . 1 as a proof . It is worth noting that reasoning in MetaQNL is interpretable by design : it is transparent about what rules are assumed ; it produces not only an answer , but also a proof that can be mechanically checked against the rules . Assumptions and the goal are usually given when applying our system to a specific task . To solve the task , two issues remain : ( 1 ) Rule induction : What is the set of rules ? ( 2 ) Theorem proving : How to apply the rules to find a proof ? Theorem proving has been studied extensively in classical AI ( Robinson & Voronkov , 2001 ) and more recently with deep learning ( Alemi et al. , 2016 ; Yang & Deng , 2019 ; Bansal et al. , 2019 ) , and we can adapt existing algorithms such as forward chaining and backward chaining ( Russell & Norvig , 2002 ) . In this work , we simply use existing provers and focus instead on the more challenging problem of rule induction . MetaInduce : an Algorithm to Learn MetaQNL Rules . Rule induction can be formulated as a discrete optimization problem that seeks a minimum set of rules that are consistent with training examples . Note that it is important to seek a small number of rules because we always have a trivial solution that consists of one rule per example but is unlikely to generalize . This optimization is challenging due to the discrete , combinatorial search space . We introduce MetaInduce , a general method for learning MetaQNL rules . It encodes the problem as a maximum satisfiability ( MAX-SAT ) problem , which can be solved efficiently by off-the-shelf solvers ( De Moura & Bjørner , 2008 ) . Our method consists of 3 steps . First , given a training example , a rule proposer proposes a set of concrete rules ( rules without variables ) as candidates . This set can be overcomplete and inaccurate . These rules are used to prove the example using existing provers such as forward/backward chaining . Second , we generate abstract rules from concrete rules via a symbolic procedure called anti-unification ( Plotkin , 1970 ; Kutsia et al. , 2014 ) . Third , we encode the proof paths in MAX-SAT and solve for a subset of all rules using a MAX-SAT solver . Overview of Results . We benchmark our method on 2 tasks : learning compositional instructions and logical reasoning . For learning compositional instructions , our method not only achieves 100 % accuracy on two standard benchmarks : MiniSCAN ( Lake et al. , 2019 ) and SCAN ( Lake & Baroni , 2018 ) , but also recovers precisely the ground truth rules . For logical reasoning , our method achieves state of the art on the RuleTaker dataset ( Clark et al. , 2020 ) . Compared to existing methods , our approach learns compact models with much less data , and produces not only answers but also checkable proofs . On RuleTaker , our approach learns a model that has only 2869 symbols but is competitive with a prior approach that uses a neural network with 11 billion parameters . 2 RELATED WORK . Symbolic reasoning . Symbolic reasoning has been studied extensively in classical AI , such as theorem proving ( Kovács & Voronkov , 2013 ; Robinson & Voronkov , 2001 ) . An open problem is to perform symbolic reasoning in domains without a natural formalization , such as natural images or texts . One common approach is to manually construct a formal system ( e.g. , based on first-order logic with manually defined functions and predicates ) , then perform semantic parsing to translate images or texts into formalized statements as input to a reasoning module operating in a clean formal world . For example , to judge whether one statement implies another , Mineshima et al . ( 2015 ) use a semantic parser to convert both statements into higher-order logic ( with predefined predicates ) , and then run an automated theorem prover . Semantic parsing is still far from reliable ; therefore , researchers have developed techniques for learning it jointly with the reasoning module ( Mao et al. , 2018 ; Saparov & Mitchell , 2021 ; Dai et al. , 2019 ; Li et al. , 2020 ) . In contrast , our approach does not require a semantic parser , because rules in MetaQNL are directly applicable to natural language . Natural Logic ( McAllester & Givan , 1993 ; MacCartney & Manning , 2007 ; Angeli et al. , 2016 ) is a class of symbolic systems defined using the syntax of natural language , bypassing semantic parsing . Compared to our system , Natural Logic is more specialized because it is a specific logic committed to a set of predefined rules ( namely seven set-theoretical relations ) , which restrict the type of reasoning it can perform to monotonicity reasoning ( Icard III & Moss , 2014 ) . In contrast , our system has no such restrictions because is not a specific logic but a meta-language with minimal structure such that it can instantiate various types of reasoning , just as MetaMath is a meta-language that can describe a variety of mathematical logics ( Megill & Wheeler , 2019 ) . None of these works discussed so far learn rules from data ; they instead use a predefined formal system that is already specialized and already encodes a substantial amount of prior knowledge . In contrast , MetaQNL is almost “ knowledge-free ” in the sense that it imposes the weakest possible structure on the permitted rules and lets the specific rules emerge from data through learning . Reasoning with neural networks . Neural networks can perform “ soft ” reasoning in the space of continuous vectors without manipulating discrete symbols explicitly . Prior works have used transformer-based ( Vaswani et al. , 2017 ) language models for soft reasoning ( Polu & Sutskever , 2020 ; Saha et al. , 2020 ; Tafjord et al. , 2020 ; Gontier et al. , 2020 ; Talmor et al. , 2020 ) . Clark et al . ( 2020 ) finetune a pretrained transformer to classify whether the goal is provable from the assumptions , encoding them as sentences in a constrained natural language . Saha et al . ( 2020 ) and Tafjord et al . ( 2020 ) go one step further to generate proofs in addition to yes/no answers . Bostrom et al . ( 2021 ) generate conclusions from premises in unconstrained natural language . Instead of using a generic transformer , researchers have also added inductive biases to the neural architecture . Many are inspired by symbolic reasoning and are often called neuro-symbolic architectures . Rocktäschel & Riedel ( 2017 ) introduce Neural Theorem Provers ( NTPs ) . Given the assumptions and the goal in first-order logic , they use backward chaining to recursively construct a neural network . However , NTPs only work for formalized inputs and do not scale due to exponentially many proof paths in backward chaining . Weber et al . ( 2019 ) extend NTPs to natural language by extracting symbols from sentences using an off-the-shelf named entity recognizer . Minervini et al . ( 2020 ) make NTPs more scalable by dynamically pruning unpromising proof paths in backward chaining . Researchers have also attempted to embed symbolic structures such as logic formulas into continuous vectors while preserving logical operations ( Grefenstette , 2013 ; Kathryn & Mazaitis , 2018 ; Lee et al. , 2016 ; Schlag et al. , 2019 ) . For example , tensor product representations ( TPRs ) ( Smolensky , 1990 ) represent symbols as tensors and perform variable binding/unbinding via tensor operations such as inner/outer product . Dong et al . ( 2018 ) propose Neural Logic Machines ( NLMs ) —a neuro-symbolic architecture based on continuous approximation of logical inference . Predicates are represented as tensors ; rules are neural operators that map tensors to tensors . Cingillioglu & Russo ( 2020 ) propose an end-to-end neural architecture called unification networks to learn rules with variables from concrete examples . However , their system of rules is significantly less general than ours : their variables can only bind to a single word , whereas our variables bind to arbitrary sentences . In addition , their system does not support multistep chained reasoning . All reasoning is done in a single step : producing a conclusion in the form of an answer ( `` yes/no '' , a number , etc . ) given a number of premises consisting of a question and a set of supporting facts . Unlike these prior works , we learn symbolic rules instead of weights in a neural network . Further , during inference , we generate symbolic proofs whose correctness with respect to the induced rules is guaranteed and can be mechanically checked . Saha et al . ( 2020 ) and Tafjord et al . ( 2020 ) also generate proofs , but their proofs are natural language texts whose correctness is neither guaranteed nor mechanically checkable—their approach trains neural networks to directly predict both answers and proofs , but does not expose a system of rules against which a proof can be checked . Rule induction . Inductive logic programming ( ILP ) learns rules in first-order logic programs such as Prolog and Datalog ( Plotkin , 1972 ; Muggleton , 1991 ; Cropper & Dumančić , 2020 ) . Extending it to natural language is non-trivial—partially due to the need for a predefined ontology of objects and predicates , as well as a perfect semantic parser , both of which are infeasible . Unlike ILP , we learn rules in MetaQNL , which can express not only logic programs but also natural language sentences . And our experiments show that MetaQNL can solve tasks that are not easily solvable by ILP . For learning rules , our MetaInduce algorithm draws inspiration from existing ILP approaches . They encode proofs as either a boolean satisfiability problem solvable by off-the-shelf SAT solvers ( Raghothaman et al. , 2019 ) or a differentiable function amenable to gradient descent ( Yang et al. , 2017 ; Evans & Grefenstette , 2018 ; Si et al. , 2019 ) . Compared to these approaches , our rule space is different and more complex . Our rules consist of sentences with variables , whereas rules in ILP are typically Horn clauses in first-order logic . Further , ILP often imposes strong syntactic constraints on what rules are valid , e.g. , using rule templates ( Evans & Grefenstette , 2018 ; Raghothaman et al. , 2019 ) , or restricting to binary predicates ( Evans & Grefenstette , 2018 ) . These constraints are critical to good performance but are domain-dependent and difficult to get right ( Cropper & Dumančić , 2020 ) . Over-constraining the rule space makes the system less expressive , less generally applicable , and more brittle in the presence of noise . Another difference is that we minimize the number of rules in order to generalize , which is unnecessary for ILP due to stronger syntactic constraints . Our space of rules includes a rich hierarchy from abstract rules to concrete rules , making the search space much larger . In contrast , most ILP works assume function-free first-order logic such as Datalog . Their variables can only be instantiated with concrete entities , making their rule space much simpler . RNNLogic ( Qu et al. , 2021 ) learns first-order rules for knowledge base completion . They generate rules using RNNs , which is feasible because they require that rules can be expressed as a sequence of predicates . The strong syntactic constraint makes it less suitable for more general reasoning . Beyond first-order logic , Nye et al . ( 2020 ) learn rules for a string rewriting system . MetaQNL is more general because it can be applied to not only string rewriting but also other forms of reasoning ( see Sec . 5 ) .

Summary: The work proposes two new concepts: + MetaQNL: a symbolic system in Quasi-Natural Language. Instead of representing rules in a formal symbolic format such as first order logic rules, in MetaQNL, a rule is represented in a Quasi-Natural Language format which includes words, variables and control symbols. Since the rules are represented in an informal representation. An interesting property of the MetaQNL representation is that it allows to perform backward or forward inference by substitution of variables with sentences. The authors assume that texts can be translated into the MetaQNL format and thus solving the reasoning problems with text input is possible via mining rules from text and backward/forward reasoning with the Quasi-Natural Language. + To mine rule from text, the authors proposes an algorithm called MetaInduce. MetaInduce iterates through the training data several time to build a compact set of rules that trades complexity to prediction accuracy. It is a bottom up rule induction approach where it includes a Rule proposer which propose a concrete rule from a training example and an anti-unification module to abstract the concrete rule with more generalised rules. A pruning process based on MAX-SAT is used to prune the set of rules such that it optimise the regularised objective.