117 research outputs found
Automated Generation of Non-Linear Loop Invariants Utilizing Hypergeometric Sequences
Analyzing and reasoning about safety properties of software systems becomes
an especially challenging task for programs with complex flow and, in
particular, with loops or recursion. For such programs one needs additional
information, for example in the form of loop invariants, expressing properties
to hold at intermediate program points. In this paper we study program loops
with non-trivial arithmetic, implementing addition and multiplication among
numeric program variables. We present a new approach for automatically
generating all polynomial invariants of a class of such programs. Our approach
turns programs into linear ordinary recurrence equations and computes closed
form solutions of these equations. These closed forms express the most precise
inductive property, and hence invariant. We apply Gr\"obner basis computation
to obtain a basis of the polynomial invariant ideal, yielding thus a finite
representation of all polynomial invariants. Our work significantly extends the
class of so-called P-solvable loops by handling multiplication with the loop
counter variable. We implemented our method in the Mathematica package Aligator
and showcase the practical use of our approach.Comment: A revised version of this paper is published in the proceedings of
ISSAC 201
Invariant Generation for Multi-Path Loops with Polynomial Assignments
Program analysis requires the generation of program properties expressing
conditions to hold at intermediate program locations. When it comes to programs
with loops, these properties are typically expressed as loop invariants. In
this paper we study a class of multi-path program loops with numeric variables,
in particular nested loops with conditionals, where assignments to program
variables are polynomial expressions over program variables. We call this class
of loops extended P-solvable and introduce an algorithm for generating all
polynomial invariants of such loops. By an iterative procedure employing
Gr\"obner basis computation, our approach computes the polynomial ideal of the
polynomial invariants of each program path and combines these ideals
sequentially until a fixed point is reached. This fixed point represents the
polynomial ideal of all polynomial invariants of the given extended P-solvable
loop. We prove termination of our method and show that the maximal number of
iterations for reaching the fixed point depends linearly on the number of
program variables and the number of inner loops. In particular, for a loop with
m program variables and r conditional branches we prove an upper bound of m*r
iterations. We implemented our approach in the Aligator software package.
Furthermore, we evaluated it on 18 programs with polynomial arithmetic and
compared it to existing methods in invariant generation. The results show the
efficiency of our approach
(Un)Solvable Loop Analysis
Automatically generating invariants, key to computer-aided analysis of
probabilistic and deterministic programs and compiler optimisation, is a
challenging open problem. Whilst the problem is in general undecidable, the
goal is settled for restricted classes of loops. For the class of solvable
loops, introduced by Kapur and Rodr\'iguez-Carbonell in 2004, one can
automatically compute invariants from closed-form solutions of recurrence
equations that model the loop behaviour. In this paper we establish a technique
for invariant synthesis for loops that are not solvable, termed unsolvable
loops. Our approach automatically partitions the program variables and
identifies the so-called defective variables that characterise unsolvability.
Herein we consider the following two applications. First, we present a novel
technique that automatically synthesises polynomials from defective monomials,
that admit closed-form solutions and thus lead to polynomial loop invariants.
Second, given an unsolvable loop, we synthesise solvable loops with the
following property: the invariant polynomials of the solvable loops are all
invariants of the given unsolvable loop. Our implementation and experiments
demonstrate both the feasibility and applicability of our approach to both
deterministic and probabilistic programs.Comment: Extended version of the conference paper `Solving Invariant
Generation for Unsolvable Loops' published at SAS 2022 (see also the preprint
arXiv:2206.06943). We extended both the text and results. 36 page
Exact Bayesian Inference for Loopy Probabilistic Programs
We present an exact Bayesian inference method for inferring posterior
distributions encoded by probabilistic programs featuring possibly unbounded
looping behaviors. Our method is built on an extended denotational semantics
represented by probability generating functions, which resolves semantic
intricacies induced by intertwining discrete probabilistic loops with
conditioning (for encoding posterior observations). We implement our method in
a tool called Prodigy; it augments existing computer algebra systems with the
theory of generating functions for the (semi-)automatic inference and
quantitative verification of conditioned probabilistic programs. Experimental
results show that Prodigy can handle various infinite-state loopy programs and
outperforms state-of-the-art exact inference tools over benchmarks of loop-free
programs
Templates and Recurrences: Better Together
This paper is the confluence of two streams of ideas in the literature on
generating numerical invariants, namely: (1) template-based methods, and (2)
recurrence-based methods. A template-based method begins with a template that
contains unknown quantities, and finds invariants that match the template by
extracting and solving constraints on the unknowns. A disadvantage of
template-based methods is that they require fixing the set of terms that may
appear in an invariant in advance. This disadvantage is particularly prominent
for non-linear invariant generation, because the user must supply maximum
degrees on polynomials, bases for exponents, etc. On the other hand,
recurrence-based methods are able to find sophisticated non-linear mathematical
relations, including polynomials, exponentials, and logarithms, because such
relations arise as the solutions to recurrences. However, a disadvantage of
past recurrence-based invariant-generation methods is that they are primarily
loop-based analyses: they use recurrences to relate the pre-state and
post-state of a loop, so it is not obvious how to apply them to a recursive
procedure, especially if the procedure is non-linearly recursive (e.g., a
tree-traversal algorithm). In this paper, we combine these two approaches and
obtain a technique that uses templates in which the unknowns are functions
rather than numbers, and the constraints on the unknowns are recurrences. The
technique synthesizes invariants involving polynomials, exponentials, and
logarithms, even in the presence of arbitrary control-flow, including any
combination of loops, branches, and (possibly non-linear) recursion. For
instance, it is able to show that (i) the time taken by merge-sort is , and (ii) the time taken by Strassen's algorithm is
.Comment: 20 pages, 3 figure
Q(sqrt(-3))-Integral Points on a Mordell Curve
We use an extension of quadratic Chabauty to number fields,recently developed by the author with Balakrishnan, Besser and M ̈uller,combined with a sieving technique, to determine the integral points overQ(√−3) on the Mordell curve y2 = x3 − 4
- …