Skip to main content
QUICK REVIEW

[Paper Review] Learning Nonlinear Loop Invariants with Gated Continuous Logic Networks (Extended Version)

Yao, Jianan, Ryan, Gabriel|arXiv (Cornell University)|Mar 17, 2020
Formal Methods in VerificationComputer Science38 citations
TL;DR

This paper introduces Gated Continuous Logic Networks (G-CLNs), a neural architecture that learns general nonlinear loop invariants by combining gating mechanisms, dropout, and a novel Piecewise Biased Quadratic Unit (PBQU) activation to improve robustness and convergence. It achieves 26 out of 27 solved nonlinear loop invariant problems—3 more than prior work—with a 97.5% convergence rate on quadratic problems, significantly outperforming baseline CLN models.

ABSTRACT

Verifying real-world programs often requires inferring loop invariants with nonlinear constraints. This is especially true in programs that perform many numerical operations, such as control systems for avionics or industrial plants. Recently, data-driven methods for loop invariant inference have shown promise, especially on linear invariants. However, applying data-driven inference to nonlinear loop invariants is challenging due to the large numbers of and magnitudes of high-order terms, the potential for overfitting on a small number of samples, and the large space of possible inequality bounds. In this paper, we introduce a new neural architecture for general SMT learning, the Gated Continuous Logic Network (G-CLN), and apply it to nonlinear loop invariant learning. G-CLNs extend the Continuous Logic Network (CLN) architecture with gating units and dropout, which allow the model to robustly learn general invariants over large numbers of terms. To address overfitting that arises from finite program sampling, we introduce fractional sampling---a sound relaxation of loop semantics to continuous functions that facilitates unbounded sampling on real domain. We additionally design a new CLN activation function, the Piecewise Biased Quadratic Unit (PBQU), for naturally learning tight inequality bounds. We incorporate these methods into a nonlinear loop invariant inference system that can learn general nonlinear loop invariants. We evaluate our system on a benchmark of nonlinear loop invariants and show it solves 26 out of 27 problems, 3 more than prior work, with an average runtime of 53.3 seconds. We further demonstrate the generic learning ability of G-CLNs by solving all 124 problems in the linear Code2Inv benchmark. We also perform a quantitative stability evaluation and show G-CLNs have a convergence rate of $97.5\%$ on quadratic problems, a $39.2\%$ improvement over CLN models.

Motivation & Objective

  • Address the challenge of learning nonlinear loop invariants in real-world numerical programs, especially in avionics and industrial control systems.
  • Overcome limitations in data-driven invariant inference, such as overfitting, large search spaces, and weak inequality bounds.
  • Develop a general-purpose neural architecture that can infer complex nonlinear invariants without relying on fixed formula templates.
  • Improve training stability and convergence for high-order polynomial invariants through architectural innovations and sampling techniques.
  • Enable sound, scalable, and precise learning of nonlinear inequality constraints from finite program traces.

Proposed method

  • Propose Gated Continuous Logic Networks (G-CLNs), an enhanced neural architecture based on CLNs that incorporates gating units, dropout (specifically Term Dropout), and batch normalization to improve training stability and generalization.
  • Introduce Fractional Sampling, a sound relaxation of loop semantics that enables dense, unbounded sampling over the real domain, mitigating overfitting from finite integer samples.
  • Design the Piecewise Biased Quadratic Unit (PBQU), a custom activation function that naturally learns tight nonlinear inequality bounds by modeling piecewise quadratic behavior.
  • Use differentiable relaxation of SMT formulas to train G-CLNs via gradient descent, allowing end-to-end learning of logical invariants from program traces.
  • Apply weight normalization and regularization to prevent dominance of high-order terms and avoid degenerate solutions during optimization.
  • Integrate the G-CLN framework into a complete invariant inference system that supports both equality and inequality constraints in nonlinear loops.

Experimental results

Research questions

  • RQ1How can a neural network architecture be designed to robustly learn general nonlinear loop invariants without relying on predefined formula templates?
  • RQ2What sampling strategy enables effective and sound learning of nonlinear invariants from finite program traces while avoiding overfitting?
  • RQ3How can a neural activation function be constructed to naturally learn tight, verification-relevant inequality bounds?
  • RQ4What architectural and training improvements are necessary to achieve high convergence rates on complex nonlinear invariant problems?
  • RQ5How does the proposed method compare in scalability and accuracy to prior data-driven approaches on both nonlinear and linear invariant benchmarks?

Key findings

  • The G-CLN system successfully solves 26 out of 27 nonlinear loop invariant problems from the benchmark, outperforming prior work by solving 3 additional problems.
  • Fractional Sampling enables effective learning of high-degree polynomial invariants (up to 6th order) by allowing dense sampling over the real domain.
  • The system achieves a 97.5% convergence rate on quadratic problems, representing a 39.2% improvement over baseline CLN models.
  • Data normalization and Term Dropout are critical for preventing high-order terms from dominating training and for avoiding degenerate solutions.
  • The G-CLN framework generalizes well, solving all 124 theoretically solvable problems in the Code2Inv linear invariant benchmark within 30 seconds.
  • Quantitative stability evaluation confirms that gating and regularization significantly improve model convergence, especially in the presence of poor weight initialization.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.