Invariant Synthesis for Incomplete Verification Engines

We propose a framework for synthesizing inductive invariants for incomplete verification engines, which soundly reduce logical problems in undecidable theories to decidable theories. Our framework is based on the counter-example guided inductive synthesis principle (CEGIS) and allows verification engines to communicate non-provability information to guide invariant synthesis. We show precisely how the verification engine can compute such non-provability information and how to build effective learning algorithms when invariants are expressed as Boolean combinations of a fixed set of predicates. Moreover, we evaluate our framework in two verification settings, one in which verification engines need to handle quantified formulas and one in which verification engines have to reason about heap properties expressed in an expressive but undecidable separation logic. Our experiments show that our invariant synthesis framework based on non-provability information can both effectively synthesize inductive invariants and adequately strengthen contracts across a large suite of programs.


Introduction
The paradigm of deductive verification [22,31] combines manual annotations and semi-automated theorem proving to prove programs correct.Programmers annotate code they develop with contracts and inductive invariants, and use high-level directives to an underlying, mostly-automated logic engine to verify their programs correct.Several mature tools have emerged that support such verification, in particular tools based on the intermediate verification language Boogie [3] and the SMT solver Z3 [45] (e.g., Vcc [13] and Dafny [40]).Various applications that use such tools to prove systems correct using manual annotations have been developed, including Microsoft Hypervisor verification [14], reliable systems code such as Verve [56], ExpressOS [42], and Ironclad apps [30], as well as distributed systems in IronFleet [29].Fully automated use of such engines for shallow specifications have also emerged, such as Corral [38] for verifying device drivers, CST [10] to certify transactions in online services, and GPUVerify [4] to ensure race-freedom in GPU kernels.
Viewed through the lens of deductive verification, the primary challenges in automating verification are two-fold.First, even when strong annotations in terms of contracts and inductive invariants are given, the validity problem for the resulting verification conditions is often undecidable (e.g., in reasoning about the heap, reasoning with quantified logics, and reasoning with non-linear arithmetic).Second, the synthesis of loop invariants and strengthenings of contracts that prove a program correct needs to be automated so as to lift this burden currently borne by the programmer.
A standard technique to solve the first problem (i.e., intractability of validity checking of verification conditions) is to build automated, sound-but-incomplete verification engines for validating verification conditions, thus skirting the undecidability barrier.Several such techniques exist; for instance, for reasoning with quantified formulas, tactics such as E-matching [17,44], pattern-based quantifier instantiation [17], and model-based quantifier instantiation [26] are effective in practice, though they are not complete for most background theories.In the realm of heap verification, the so-called natural proof method explicitly aims to provide automated and sound-but-incomplete methods for checking validity of verification conditions with specifications in separation logic [50,48,12].This method searches for proofs based on induction on recursively defined data structures, which is reduced to validity problems in decidable logics with quantification that enables an efficient search for such proofs using SMT solvers.
Turning to the second problem of invariant generation, several techniques have emerged that can synthesize invariants automatically when validation of verification conditions fall in decidable classes.Prominent among these are interpolation [43] and IC3/PDR [6,19].These techniques generalize from information gathered in proving underapproximations of the program correct and are quite effective [5]-their efficacy in dealing with programs where the underlying logics are undecidable, however, is unclear.Moreover, a class of counterexample guided inductive synthesis (CEGIS) methods have emerged recently, including the ICE learning model [24] for which various instantiations exist [24,52,25,37].The key feature of the latter methods is a program-agnostic, data-driven learner that learns invariants in tandem with a verification engine that provides concrete program configurations as counterexamples to incorrect invariants.
Although classical invariant synthesis techniques, such as Houdini [21], are sometimes used with incomplete verification engines, to the best of our knowledge there is no fundamental argument as to why this should work in general.In fact, we are not aware of any systematic technique for synthesizing invariants when the underlying verification problem falls in an undecidable theory.When verification is undecidable and the engine resorts to sound but incomplete heuristics to check validity of verification conditions, it is unclear how to extend interpolation/IC3/PDR techniques to this setting.Data-driven learning of invariants is also hard to extend since the verification engine typically cannot generate a concrete model for the negation of verification conditions when verification fails.Hence, it cannot produce the concrete configurations that the learner needs.
The main contribution of this paper is a general, learning-based invariant synthesis framework that learns invariants using non-provability information provided by verification engines.Intuitively, when a conjectured invariant results in verification conditions that cannot be proven, the idea is that the verification engine must return information that generalizes the reason for non-provability, hence pruning the space of future conjectured invariants.Our framework assumes a verification engine for an undecidable theory U that reduces verification conditions to a decidable theory D (e.g., using heuristics such as bounded quantifier instantiation to remove universal quantifiers, function unfolding to remove recursive definitions, and so on) that permits producing models for satisfiable formulas.The translation is assumed to be conservative in the sense that if the translated formula in D is valid, then we are assured that the original verification condition is U-valid.If the verification condition is found to be not D-valid (i.e., its negation is satisfiable), on the other hand, our framework describes how to extract non-provability information from the D-model.This information is encoded as conjunctions and disjunctions in a Boolean theory B, called conjunctive/disjunctive non-provability information (CD-NPI), and communicated back to the learner.To complete our framework, we show how the formula-driven problem of learning expressions from CD-NPI constraints can be reduced to the data-driven ICE model.This reduction allows us to use a host of existing ICE learning algorithms and results in a robust invariant synthesis framework that guarantees to synthesize a provable invariant if one exists.We present the framwork in Section 2 in detail.
However, our CD-NPI learning framework has non-trivial requirements on the verification engine, and building (or adapting) appropriate engines is not straightforward.To show that our framework is indeed applicable and effective in practice, our second contribution is the application of our technique to two real-world verification settings.
The first setting, presented in Section 3, is the verification of dynamically manipulated data-structures against rich logics that combine properties of structure, separation, arithmetic, and data-an important problem where verification often falls in undecidable theories.We show how natural proof verification engines [48], which are essentially sound-but-incomplete verification engines that translate a powerful undecidable separation logic called Dryad to decidable logics, can be fit into our framework.We then implement a prototype of such a natural proof verification engines on top of the program verifier Boogie [3] and demonstrate that this prototype is able to fully automatically verify a large suite of benchmarks, containing standard algorithms for manipulating singly and doubly linked lists, sorted lists, as well as balanced and sorted trees.Automatically synthesizing invariants for this suite of heap manipulating programs against an expressive separation logic is very challenging, and we do not know of any other current technique that can automatically prove all of them.Thus, we have to leave a comparison to other approaches for future work.
The second setting is the verification of programs against specifications with universal quantification, which occur, for instance, when defining recursive properties.Again, we implement a prototype over Boogie and demonstrate its effectiveness on a series of benchmarks taken from verification competitions and real-world systems.We describe this application in Section 4 and conclude in Section 5.

Related Work
Techniques for invariant synthesis include abstract interpretation [16], interpolation [43], IC3 [6], predicate abstraction [2], abductive inference [18], as well as synthesis algorithms that rely on constraint solving [27,28,15].Complementing them are data-driven invariant synthesis techniques based on learning, such as Daikon [20] that learn likely invariants, and Houdini [21] and ICE [24] that learn inductive invariants.The latter typically requires a teacher that can generate counter-examples if the conjectured invariant is not adequate or inductive.Classicially, this is possible only when the verification conditions of the program fall in decidable logics.In this paper, we investigate data-driven invariant synthesis for incomplete verification engines and show that the problem can be reduced to ICE learning if the learning algorithm learns from non-provability information and produces hypotheses in a class that is restricted to positive Boolean formulas over a fixed set of predicates.Data-driven synthesis of invariants has regained recent interest [55,53,54,23,24,52,37,57,47,46] and our work addresses an important problem of synthesizing invariants for programs whose verifications conditions fall in undecidable fragments.
Our application to learning invariants for heap programs builds upon Dryad [50,48], and the natural proof technique line of work for heap verification developed by Qiu et al.Techniques, similar to Dryad, for automated reasoning of dynamically manipulated data structure programs have also been proposed in [12,11].However, unlike our current work, none of these works synthesize heap invariants.Given invariant annotations in their respective logics, they provide procedures to validate if the verification conditions are valid.There has also been a lot of work on synthesizing invariants for separation logic using shape analysis [51,9,39].However, most of them are tailored for memory safety and shallow properties rather than rich properties that check full functional correctness of data structures.Interpolation has also been suggested recently to synthesize invariants involving a combination of data and shape properties [1].It is, however, not clear how the technique can be applied to a more complicated heap structure, such as an AVL tree, where shape and data properties are not cleanly separated but are intricately connected.Recent work also includes synthesizing heap invariants in the logic from [32] by extending IC3 [33,34].
In this work, our learning algorithm synthesizes invariants over a fixed set of predicates.When all programs belong to a specific class, such as the class of programs manipulating data structures, these predicates can be uniformly chosen using templates.Investigating automated ways for discovering candidate predicates is a very interesting future direction.Related work in this direction includes recent works [47,46].

An Invariant Synthesis Framework for Incomplete Verification Engines
In this section, we develop our framework for synthesizing inductive invariants for incomplete verification engines, using a counter-example guided inductive synthesis approach.We do this in the setting where the hypothesis space consists of formulas that are Boolean combinations of a fixed set of predicates P, which need not be finite for the general framework-when developing concrete learning algorithms later, we will assume P is a finite set of predicates.For the rest of this section, let us fix a program P that is annotated with assertions (and possibly with some partial annotations describing pre-conditions, post-conditions, and assertions).Moreover, we refer to a formula α being weaker (or stronger) than β in a logic L, and by this we mean that L β ⇒ α (or L α ⇒ β), respectively, where L ϕ means that ϕ is valid in L.
Figure 1 (on Page 4) depicts our general framework of invariant synthesis when verification is undecidable.We fix several parameters for our verification effort.First, let us assume a uniform signature for logic, in terms of constant symbols, relation symbols, functions, and types.We will, for simplicity of exposition, use the same syntactic logic for the various logics U, D, B in our framework as well as for the logic H used to express invariants.
Let us fix U as the underlying theory that is ideally needed for validating the verification conditions that arise for the program; we presume validity of formulas in U is undecidable.Since U is an undecidable H -The hypothesis class of invariants U -The underlying theory of the program; undecidable D -The theory that the verification engine soundly reduces verification conditions to; decidable and can produce models B -The theory of propositional logic that the verification engine uses yo communicate to the invariant synthesis engine Fig. 1.A non-provability information (NPI) framework for invariant synthesis when the verification logic is undecidable theory, the engine will resort to sound approximations (e.g., using bounded quantifier instantiations using mechanisms such as triggers [44], bounded unfolding of recursive functions, or natural proofs [48]) to reduce this logical task to a decidable theory D. This reduction is assumed to be sound in the sense that if the resulting formulas in D are valid, then the verification conditions are valid in U as well.If a formula is found not valid in D, then we require that the logic solver for D returns a model for the negation of the formula. 4ote that this model may not be a model for the negation of the formula in U.
Moreover, we fix a hypothesis class H for invariants consisting of positive Boolean combination of predicates in a fixed set of predicates P. Note that restricting to positive formulas over P is not a restriction, as one can always add negations of predicates to P, thus effectively synthesizing any Boolean combination of predicates.The restriction to positive Boolean formulas is in fact desirable, as it allows restricting invariants to not negate certain predicates, which is useful when predicates have intuitionistic definitions (as several recursive definitions of heap properties do).
The invariant synthesis proceeds in rounds, where in each round the synthesizer proposes invariants in H.The verification engine generates verification conditions in accordance to these invariants in the underlying theory U.It then proceeds to translate them into the decidable theory D, and gives them to a solver that decides validity in the theory D. If the verification conditions are found to be D-valid, then by virtue of the fact that the verification engine reduced VCs in a sound fashion to D, we are done proving the program P .
However, if the formula is found not to be D-valid, the solver returns a D-model for the negation of the formula.The verification engine then extracts from this model certain non-provability information (NPI), expressed as Boolean formulas in a Boolean theory B, that captures more general reasons why the verification failed and eliminates not only the current conjectured invariant but also others that can be inferred to be incorrect from the current verification effort (the rest of this section is devoted to developing this notion of non-provability information).This non-provability information is communicated to the synthesizer, which then proceeds to synthesize a new conjecture invariant that satisfies the non-provability constraints provided in all previous rounds.The following example illustrates the logics involved in our framework in the context heap-manipulating programs.
Example 1.In a verification setting involving heaps, the logic U could be a rich separation logic with recursive definitions and D could be the quantifier-free theory of uninterpreted functions, arithmetic, and sets.The verification engine can reduce verification conditions in U to D by partially unfolding recursive definitions and expressing heaplets using sets, to obtain sound but incomplete automatic validity checking.
Futhermore, the theory B can be chosen to be the just the propositional theory over a set of predicates P. The verification engine will then communicate formulas over B to the synthesis engine that restrict the class of invariants such that the synthesis engine can generate in the future.
In order for the verification engine to extract meaningful non-provability information, we make the following natural assumption, called normality, which essentially states that the engine can do at least some minimal Boolean reasoning.Intuitively, Condition 1 of Definition 1 means that if an oracle cannot prove the validity of {α}s{γ}, then it cannot prove the validity of any strengthening δ of the postcondition γ.Similarly, Condition 2 means that if an oracle cannot prove the validity of {γ}s{β}, then it cannot prove the validity of any weakening δ of the precondition γ.
The remainder of this section is now structured as follows.In Section 2.1, we first develop an appropriate language to communicate non-provability constraints, which allow the learner to appropriately weaken or strengthen a future hypothesis.It turns out that pure conjunctions and pure disjunctions over P, which we term CD-NPI constraints (conjunctive/disjunctive non-provability information constraints), are sufficient for this purpose.We also describe concretely how the verification engine can extract this non-provability information from D-models that witness that negations of VCs are satisfiable.Then, in Section 2.2, we show how to build learners for CD-NPI constraints by reducing this learning problem to another, well-studied learning framework for invariants called ICE learning.We illustrate our framework with an example in Section 2.3 and finally argue in Section 2.4 that our framework is sound and guarantees to converge to a provable invariant if one exists.

Conjunctive/Disjunctive Non-provability Information
We assume that the underlying decidable theory D is stronger than propositional theory B, meaning that every valid statement in B is valid in D as well.The reader may want to keep the following as a running example where D is the decidable theory of uninterpreted functions and linear arithmetic, say.In this setting, a formula is B-valid if, when treating atomic formulas as Boolean variables, the formula is propositionally valid.For instance, To formally define CD-NPI constraints and their extraction from a failed verification attempt, let us first introduce the following notation.For any U-formula ϕ, let approx(ϕ) denote the D-formula that the verification engine generates such that the D-validity of approx(ϕ) implies the U-validity of ϕ.Moreover, for any Hoare triple {α}s{β}, let V C({α}s{β}) denote the verification condition corresponding to the Hoare triple that the verification engine generates.
Let us now assume, for the sake of a simpler exposition, that the program has a single annotation hole A where we need to synthesize an inductive invariant and prove the program correct.Further, suppose the learner conjectures an annotation γ as an inductive invariant for the annotation hole A, and the verification engine fails to prove the verification condition corresponding to a Hoare triple {α}s{β}, where either α, β, or both could involve the synthesized annotation.This means that the negation of approx(V C({α}s{γ})) is D-satisfiable and the verification engine needs to extract non-provability information from a model of it.To this end, we assume that every program snippet s has been augmented with a set of ghost variables g 1 , . . ., g n that track the predicates p 1 , . . ., p n mentioned in the invariant (i.e., these ghost variables are assigned the values of the predicates).The valuation v = v 1 , . . ., v n of the ghost variables in the model before the execution of s and the valuation v = v 1 , . . ., v n after the execution of s can then be used to derive non-provability information, as we describe shortly.
The type of non-provability information the verification engine extracts depends on where the annotation appears in a Hoare triple {α}s{β}.More specifically, the synthesized annotation might appear in α, in β, or in both.We now handle all three cases individually.
-Assume the verification of a Hoare triple of the form {α}s{γ} fails (i.e., the verification engine cannot prove a verification condition where the pre-condition α is a user-supplied annotation and the post-condition is the synthesized annotation γ).Then, approx(V C({α}s{γ})) is not D-valid, and the decision procedure for D would generate a model for its negation.
Since γ is a positive Boolean combination, the reason why v does not satisfy γ is due to the variables mapped to false by v , as any valuation extending this will not satisfy γ.Intuitively, this means that the D-solver is not able to prove the predicates in In other words, {α}s{ P false } is unprovable (a witness to this fact is the model of the negation of approx(V C({α}s{γ})) from which the values v are derived).Note that any invariant γ that is stronger than P false will result in an unprovable VC due to the verification engine being normal.Consequently we can choose χ = P false as the weakening constraint, demanding that future invariants should not be stronger than χ.
The verification engine now communicates χ to the synthesizer, asking it never to conjecture in future rounds invariants γ that are stronger than χ (i.e., such that B γ ⇒ χ).-The next case is when a Hoare triple of the form {γ}s{β} fails to be proven (i.e., the verification engine cannot prove a verification condition where the post-condition β is a user-supplied annotation and the pre-condition is the synthesized annotation γ).Using similar arguments as above, the conjunction η = {p i | v i = true} of the predicates mapped to true by v in the corresponding D-model gives a stronger precondition η such that {η}s{α} is not provable.Hence, η is a valid strengthening constraint.
The verification engine now communicates η to the synthesizer, asking it never to conjecture in future rounds invariants γ that are weaker than η (i.e., such that B η ⇒ γ ).-Finally, consider the case when the Hoare triple is of the form {γ}s{γ} and fails to be proven (i.e., the verification engine cannot prove a verification condition where the pre-and post-condition is the synthesized annotation γ).In this case, the verification engine can offer advice on how γ can be strengthened or weakened to avoid this model.Analogous to the two cases above, the verification engine extracts a pair of formulas (η, χ), called an inductivity constraint, based on the variables mapped to true by v and to false by v .The meaning of such a constraint is that the invariant synthesizer must conjecture in future rounds invariants γ such that either B η ⇒ γ or B γ ⇒ χ holds.
This leads to the following scheme, where γ denotes the conjectured invariant: -When a Hoare triple of the form {α}s{γ} fails, the verification engine returns the B-formula It is not hard to verify that the above formulas are proper strengthening and weakening constraints, in the sense that any inductive invariant must satisfy these constraints.This motivates the following form of non-provability information.
Definition 2 (CD-NPI Samples).Let P be a set of predicates.A CD-NPI sample (short for conjunctiondisjunction-NPI sample) is a triple S = (W, S, I) consisting of a finite set W of disjunctions over P (weakening constraints); a finite set S of conjunctions over P (strengthening constraints); and a finite set I of pairs, where the first element is a conjunction and the second is a disjunction over P (inductivity constraints).
An annotation γ is consistent with a CD-NPI sample S = (W, S, I) if A CD-NPI learner is an effective procedure that synthesizes, given an CD-NPI sample, an annotation γ consistent with the sample.In our framework, the process of proposing candidate annotations and checking them repeats until the learner proposes a valid annotation or it detects that no valid annotation exists (e.g., if the class of candidate annotations is finite and all annotations are exhausted).We comment on using an CD-NPI learner in this iterative fashion below.

Building CD-NPI Learners
Let us now turn to the problem of building efficient learning algorithms for CD-NPI constraints.To this end, we assume that the set of predicates P is finite.
Roughly speaking, the CD-NPI learning problem is to synthesize annotations that are positive Boolean combinations of predicates in P and that are consistent with given CD-NPI samples.Though this is a learning problem where samples are formulas, in this section we will reduce CD-NPI learning to a learning problem from data.In particular, we will show that CD-NPI learning reduces to the ICE learning framework for learning positive Boolean formulas.The latter is a well-studied framework, and the reduction allows us to use efficient learning algorithms developed for ICE learning in order to build CD-NPI learners.
We now first recap the ICE-learning framework and then reduce CD-NPI learning to ICE learning.Finally, we briefly sketch how the popular Houdini algorithm can be seen as an ICE learning algorithm, which, in turn, allows us to Houdini as an CD-NPI learning algorithm.
The ICE learning framework Although the ICE learning framework [24] is a general framework for learning inductive invariants, we consider here the case of learning Boolean formulas.To this end, let us fix a set B of Boolean variables, and let H be a subclass of positive Boolean formulas over B, called the hypothesis class, which specifies the admissible solutions to the learning task.
The objective of the (passive) ICE learning algorithm is to learn a formula in H from a sample of positive examples, negative examples, and implication examples.More formally, if V is the set of valuations v : B → {true, false} (mapping variables in B to true or false), then an ICE sample is a triple S = (S + , S − , S ⇒ ) where A formula ϕ is said to be consistent with an ICE sample S if it satisfies the following three conditions: In algorithmic learning theory, one distinguished between passive learning and iterative learning.The former refers to a learning setting in which a learning algorithm is confronted with a finite set of data and has to learn a concept that is consistent with this data.Using our terminology, the passive ICE learning problem for a hypothesis class H is then "given an ICE sample S, find a formula in H that is consistent with S".
Recall that we here require the learner to learn positive Boolean formulas, which is slightly stricter than the original definition [24].
Iterative learning, on the other hand, is the iteration of passive learning where new data is added to the sample from one iteration to the next.In a verification context, this new data is generated by the verification engine in response to incorrect annotations and used to guide the learning algorithm towards an annotation that is adequate to prove the program.To reduce our learning framework to ICE learning, it is therefore sufficient to reduce the (passive) CD-NPI learning problem described above to the passive ICE learning problem.We do this next.

Reduction of passive CD-NPI learning to passive ICE learning
Let H be a subclass of positive Boolean formulas.We reduce the CD-NPI learning problem for H to the ICE learning problem for H.The main idea is to (a) treat each predicate p ∈ P as a Boolean variable for the purpose of ICE learning and (b) to translate a CD-NPI sample G into an equi-consistent ICE sample S S , meaning that a positive Boolean formula is consistent with S if and only if it is consistent with S S .Then, learning a consistent formula in the CD-NPI framework for the hypothesis class H reduces to learning consistent formulas in H in the ICE learning framework.
The following lemma will help translate between the two frameworks.Its proof is straightforward, and follows from the fact that for any positive formula α, if a valuation v sets a larger subset of propositions to true than v does and v |= α, then v |= α as well.
Lemma 1.Let v be a valuation of P and α be a positive Boolean formula over P.Then, the following holds: - This motivates our translation, which relies on two functions, d and c.The function d translates a disjunction J, where J ⊆ P is a subset of propositions, into the valuation The function c translates a conjunction J, where J ⊆ P, into the valuation By substituting v in Lemma 1 with c( J) and d( J), respectively, one immediately obtains the following result.
By virtue of the lemma above, we can now establish the correctness of the reduction from the CD-NPI learning problem to the ICE learning problem.-Pick a weakening constraint J ∈ W , and let v ∈ S + with v = d( J) be the corresponding positive sample.Moreover, assume that γ is consistent with S and, thus, B γ ⇒ J.By Lemma -Following the definition of implication, we split the proof into two cases, depending on whether B J ⇒ γ or B γ ⇒ J (and v 1 |= γ or v 2 |= γ for the reserve direction).However, the proof in the former case is the same as the proof for strengthening constraints, while the proof of latter case is the same as the proof for weakening.Hence, combining both proofs immediately yields the claim.

ICE learners for Boolean formulas
The reduction above allows us to use any ICE learning algorithm in the literature that synthesizes positive Boolean formulas.As we mentioned earlier, we can add the negations of predicates as first-class predicates, and hence synthesize invariants over the class of all Boolean combinations of a finite set of predicates as well.
The problem of passive ICE learning for one round, synthesizing a formula that satisfies the ICE sample, can usually be achieved efficiently and in a variety of ways.However, the crucial aspect is not the complexity of learning in one round, but the number of rounds it takes to converge to an adequate invariant that proves the program correct.When the set P of candidate predicates is large (hundreds in our experiments), since the number of Boolean formulas over P is doubly exponential in n = |P|, building an effective learner is not easy.However, there is one class of formulas that are particularly amenable to efficient ICE learning-learning conjunctions of predicates over P. In this case, there are ICE learning algorithms that promise learning the invariant (provided one exists expressible as a conjunct over P) in n + 1 rounds.Note that this learning is essentially finding an invariant in a hypothesis class H of size 2 n in n + 1 rounds.
Houdini [21] is such a learning algorithm for conjunctive formulas.Though it is typically seen as a particular way to synthesize invariants, it is a prime example of an ICE learner for conjuncts, as described in the work by Garg et al. [24].In fact, Houdini is similar to the classical PAC learning algorithm for conjunctions [35], but extended to the ICE model by handling implication counterexamples.More precisely, given an ICE sample S = (S + , S − , S ⇒ ), Houdini computes the largest conjunctive formula ϕ in terms of the number of Boolean variables occurring in ϕ (i.e., the semantically strongest conjunctive formula) that is consistent with S in the following way.First, it computes the largest conjunction ϕ that is consistent with the positive examples (i.e., v |= ϕ for all v ∈ S + ); note that this conjunction is unique.Next, Houdini checks whether the implications are satisfied.If this is not the case, then we know for each non-satisfied implication i n t A [ ] , B [ ] ; i n t N; axiom ( N > 0 ) ; b o o l inImage ( i n t i ) { r e t u r n t r u e ; } p r o c e d u r e i n v e r s e ( ) r e q u i r e s ( ∀x, y. 0 ≤ x < y < N =⇒ A[x] = A[y] ) ; // A i s i n j e c t i v e r e q u i r e s ( ∀x. 0 ≤ x < N ∧ inImage(x) =⇒ (∃y.0 ≤ y < N ∧ A[y] = x) ) ; // A i s s u r j e c t i v e e n s u r e s ( ∀x, y. 0 ≤ x < y < N =⇒ B[x] = B[y] ) ; // B i s i n j e c t i v e { i n t i = 0 ; w h i l e ( i < N) S y n t h e s i z e I n v ( ∀x.
; // b3 r e t u r n ; } Fig. 2. Synthesizing invariants for the program that constructs an inverse B of an injective, surjective function A [36].
(v 1 , v 2 ) ∈ S ⇒ that v 2 has to be classified positively because v 1 belongs to every set that includes S + .Hence, Houdini adds all such v 2 to S + , resulting in a new set S + .Subsequently, it constructs the largest conjunction ϕ that is consistent with the positive examples in S + (i.e., v |= ϕ for all v ∈ S + ).Houdini repeats this procedure until it arrives at the largest conjunctive formula ϕ * that is consistent with S + and S ⇒ (again, note that this set is unique).Finally, Houdini checks whether each negative example violates ϕ * (i.e., v |= ϕ * for all v ∈ S − ).If this is the case, ϕ * is the largest conjunctive formula over B that is consistent with S; otherwise, no consistent conjunctive formula exists.The time Houdini spends in each round is polynomial and, furthermore, when used in an iterative setting, is guaranteed to converge in at most n + 1 rounds or report that no conjunctive invariant over P exists.We use this ICE learner to build a CD-NPI learner for conjunctions.

An Illustrative Example
Figure 2 illustrates an example program of the verified software competition [36] that given an injective, surjective function A returns the inverse B of the function A. The post-condition of this program expresses that the function B is injective.To prove this program correct, one needs to specify adequate invariants at the loop header and before the return statement in the function inverse in the program.We wish to synthesize these invariants.For simplicity, let us assume we are provided a small set of predicates as building blocks of the invariants to synthesize-b 1 for the loop invariant and b 2 , b 3 for the invariant at the return statement.Our task, therefore, is to synthesize adequate invariants for this program over these predicates. 6learly, the verification conditions of this program are undecidable.In fact, the constant Boolean function inImage is crucially required to validate certain verification conditions in Boogie because it triggers appropriate quantifier instantiations in the surjectivity condition.Now, suppose the learner conjectures the loop invariant γ L = b 1 and the invariant at the return statement γ R = b 2 ∧ b 3 .Moreover, suppose that the verification condition along the path from the loop exit to the return statement, though valid in the undecidable theory U (cf. Figure 1), is not provable in the decidable theory D (one that has instantiated quantifiers with ground terms).The D-solver returns a model for the negation of the verification condition that captures this non-provability information.The verification engine gleans this model-it looks for the values assigned to the predicate variables in the model, and from this information constructs, in general, a CD-NPI constraint for the learner to learn from.For this particular verification, the verification engine extracts a pair of formulas (η, χ) where η = b 1 and χ = b 2 , and communicates this as an inductivity constraint to the learner.Intuitively, this constraint means that the verification condition obtained by substituting γ L with η and γ R with χ is itself not provable.Hence, in subsequent rounds, the learner needs to conjecture only such invariants where γ L is not weaker than η (i.e., B b 1 ⇒ γ L ) or γ R is not stronger than χ (i.e., B γ R ⇒ b 2 ).
The learner works by reducing the CD-NPI passive learning problem to ICE learning over a sample over the given set of predicates.Concretely, the inductivity constraint (b 1 , b 2 ) is reduced to an implication constraint ((1, 0, 0), (1, 0, 1)) in the ICE setting, where each datapoint in the ICE sample has values for the predicates b 1 , b 2 , and b 3 , respectively.In the next round, let us assume the learner conjectures the invariants γ L = b 1 and γ R = b 3 .Note these conjectures satisfy both the ICE constraints and the CD-NPI constraints.In this case, it turns out that the verification conditions along all program paths using these invariants can be proved valid in the theory D. As a result, our invariant synthesis procedure terminates with γ L and γ R as adequate inductive invariants.

Main Result
To state the main result of this paper, let us assume that the set P of predicates is finite.We comment on the case of infinitely many predicates below.

Theorem 2. Assume a normal verification engine for a program P to be given. Moreover, let P be a finite set of predicates over the variables in P and H a hypothesis class consisting of positive Boolean combinations of predicates in P. If there exists an annotation in H that the verification engine can use to prove P correct, then the CD-NPI framework described in Section 2.1 is guaranteed to converge to such an annotation in finite time.
Proof (Proof of Theorem 2).The proof proceeds in two steps.First, we show that a normal verification engine is honest, meaning that the non-provability information returned by such an engine does not rule out any adequate and provable annotation.Second, we show that any consistent learner (i.e., a learner that only produces consistent hypotheses), when paired with an honest verification engine, makes progress from one round to another.Finally, we combine both results to show that the framework eventually converges to an adequate and provable annotation.

Honesty of the verification engine
We show honesty of the verification engine individually for each type of constraint by contradiction.
-Suppose that the verification replies to a candidate invariant γ proposed by the learner with a weakening constraint χ because it could not prove the validity of the Hoare triple {α}s{γ}.This effectively forces any future conjecture γ to satisfy B γ ⇒ χ.Now, suppose that there exists an invariant δ such that B δ ⇒ χ and the verification engine can prove the validity of {α}s{δ} (in other words, the adequate invariant δ is ruled out by the weakening constraint χ).Due to the fact that the verification engine is normal (in particular, by contraposition of Part 1 of Definition 1), this implies that the verification engine can also prove the validity of {α}s{χ}.However, this is a contradiction to χ being a weakening constraint.-Suppose that the verification engine replies to a candidate invariant γ proposed by the learner with a strengthening constraint η because it could not prove the validity of the Hoare triple {γ}s{β}.This effectively forces any future conjecture γ to satisfy B η ⇒ γ .Now, suppose that there exists an invariant δ such that B η ⇒ δ and the verification engine can prove the validity of {δ}s{β} (in other words, the adequate invariant δ is ruled out by the weakening constraint η).Due to the fact that the verification engine is normal (in particular, by contraposition of Part 2 of Definition 1), this implies that the verification engine can also prove the validity of {η}s{β}.However, this is a contradiction to η being a strengthening constraint.-Combining the arguments for weakening and strengthening constraints immediately results in a contradiction for the case of inductivity constraints as well.
Progress of the learner Now suppose that the learning algorithm is consistent, meaning that it always produces an annotation that is consistent with the current sample.Moreover, assume that the sample in iteration i ∈ N is S i and the learner produces the annotation γ i .If γ i is inadequate to prove the program correct, the verification engine returns a constraint c.The learner adds this constraint to the sample, obtaining the sample S i+1 of the next iteration.Since verification with γ i failed, which is witnessed by c, we know that γ i is not consistent with c.The next conjecture γ i+1 , however, is guaranteed to be consistent with S i+1 (which contains c) because the learner is consistent.Hence, γ i and γ i+1 are semantically different.Using this argument repeatedly shows that each annotation γ i that a consistent learner has produced is semantically different from any previous annotation γ j for j < i.
Convergence We first make two observations.1.The number of semantically different hypotheses in the hypothesis space H is finite because the set P is finite.Recall that H is the class of all positive Boolean combinations of predicates in P.

Due to the honesty of the verification engine, every annotation that the verification engine can use to
prove the program correct is guaranteed to be consistent with any sample produced during the learning process.Now, suppose that there exists an annotation that the verification engine can use to prove the program correct.Since the learner is consistent, all conjectures produced during the learning process are semantically different.Thus, the learner will at some point have exhausted all incorrect annotations in H (due to Observation 1).By assumption, however, there exists at least one annotation that the verification engine can use to prove the program correct.Moreover, any such annotation is guaranteed to be consistent with the current sample (due to Observation 2).Thus, the annotation conjectured next is necessarily one that the verification engine can use to prove the program correct.
Under certain, realistic assumptions on the CD-NPI learning algorithm, Theorem 2 remains true even if the number of predicates is infinite.An example of such an assumption is that the learning algorithm always conjectures a smallest consistent annotation with respect to some fixed total order on H.In this case, one can show that such a learner will at some point have proposed all inadequate annotation up to the smallest annotation the verification engine can use to prove the program correct.It will then conjecture this annotation in the next iteration.We refer the reader to Löding, Madhusudan, and Neider [41] for details on further strategies that ensure convergence.

Application: Learning Invariants that Aid Natural Proofs for Heap Reasoning
We now develop an implementation of our learning framework for verification engines based on natural proofs for heap reasoning [50,48].We first provide some background on the separation logic Dryad and natural proofs, which is a sound but incomplete verification procedure.Then, we describe how to implement our verification framework using a natrual proofs verification engine.In particular, we describe how to automatically generate suitable predicates for these programs, which serve as the building blocks of the invariants we seek to synthesize.Finally, we present an empirical evaluation of our implementation on an extensive set of standard algorithms on dynamic data structures, such as searching, inserting, or deleting items in lists and trees.
Background: Natural Proofs and Dryad Dryad [50,48] is a dialect of separation logic that comes with a heaplet semantics and allows expressing second order properties such as pointing to a list (or list segment) using recursive functions and predicates.The syntax of Dryad is a standard separation logic syntax with a few restrictions, such as disallowing negations inside recursive definitions and in sub-formulas connected by spatial conjunction (see [48] for more details about the Dryad syntax).Dryad is expressive enough to state a variety of data-structures (singly and doubly linked lists, sorted lists, binary search trees, AVL trees, maxheaps, treaps, etc.), recursive definitions over them that map to numbers (length, height, etc.), as well as data stored within the heap (the multiset of keys stored in lists, trees, etc.).
Natural proofs [50,48] is a sound but incomplete strategy for deciding satisfiability of Dryad formulas.The first step of the natural proof verifier is to convert all predicates and functions in a Dryad-annotated program to classical logic.This translation introduces heaplets (modeled as sets of locations) explicitly in the logic.Furthermore, it introduces assertions that demand that the accesses of each method are contained in the heaplet implicitly defined by its precondition (taking into account newly allocated or freed nodes), and that at the end of the program, the modified heaplet precisely matches the implicit heaplet defined by the post-condition.
The second step of the natural proof verifier is to perform transformations on the program and translate it to Boogie [21], an intermediate verification language that handles proof obligations using automatic theorem provers (typically SMT solvers).This transformation essentially performs three tasks: (a) it abstracts all recursive definitions on the heap using uninterpreted functions and introduces finite-depth unfoldings of recursive definitions at every place in the code where locations are dereferenced, (b) it models heaplets and other sets using a decidable theory of maps, and (c) it inserts frame reasoning explicitly in the code that allows the verifier to derive that certain properties continue to hold across a heap update (or function call) using the heaplet that is modified.The resulting Boogie program is a program with no recursive definitions, where all verification conditions are in decidable logics, and where the logic engine can return models when formulas are satisfiable.The program can be verified if supplied with correct inductive loop-invariants and adequate pre/post conditions.
The described procedure has been implemented in a fully automatic tool, called VCDryad.VCDryad extends VCC [13] and converts C programs annotated in Dryad to Boogie programs via the natural proof transformations described above.It is important to note, however, that VCC introduces some quantification to define the memory model and semantics of C, but this does not typically derail decidable reasoning.We refer the reader to [50,48] for more details.

Learning Heap Invariants
We have implemented a prototype of our CD-NPI framework over VCDryad and the Boogie program verifier.This prototype takes a C program annotated in Dryad as input and uses VCDryad to convert it to a Boogie program.Then, it applies our transformation to the ICE learning framework and automatically generates a set P of predicates (as described shortly), which serve as the basic building blocks of our invariants.Finally, it pairs the Boogie verifier with an invariant synthesis engine, Houdini in our case, to learn an inductive invariant.Note that after the VCDryad-transformation, Boogie satisfies the requirements on verification engines of our framework.
The set P of predicates is generated from generic templates, shown in Figure 3, which are instantiated using all combinations of program variables that occur in the program being verified.The templates define a fairly exhaustive set of predicates, including properties of the store (equality of pointer variables, equality and inequalities between integer variables, etc.), shape properties (singly and doubly linked lists and list segments, sorted lists, trees, BST, AVL, treaps, etc.), and recursive definitions that map data structures to numbers (keys/data stored in a structure, lengths of lists and list segments, height of trees) involving arithmetic relationships and set relationships.
In addition, there are also predicates describing heaplets of various structures (with suffix _heaplet), involving set operations, disjointness, and equalities.The structures and predicates are extensible, of course, to any recursive definition expressed in Dryad.
x, y ∈ PointerVars Templates for generating predicates.The operator ≤set denotes comparison between integer sets, where A ≤set B if and only if ∀x ∈ A.∀y ∈ B. x ≤ y.The operator ≥set is similarly defined.Shape properties such as LinkedList, AVLtree, etc., are recursively defined in Dryad, separately, and is extensible to any class of Dryad defined shapes.
Similarly, the definitions related to keys stored in a datastructure and the sizes of datastructures also stem from recursive definitions of them in Dryad.
The predicates are grouped into three categories, roughly in increasing complexity.Category 1 predicates involve shape-related properties, Category 2 involves properties related to the keys stored in the data-structure, and Category 3 predicates involve size-predicates on data structures (lengths of lists and heights of trees).Given a program to verify and its annotations, we choose the category of predicates depending on whether the specification refers to shape only, shapes and keys, or shapes, keys, and sizes (choosing a category includes the predicates of lower category as well).Then, predicates are automatically generated by instantiating the templates with all (combinations of) program variables.This approach allows for a fine-grained control over the predicates that are generated for a specific program and prevents the set of predicates from growing too large.

Evaluation
We have evaluated our prototype on ten benchmark suits (82 routines in total) that contain standard algorithms on dynamic data structures, such as searching, inserting, or deleting items in lists and trees.These benchmarks were taken from the following sources: (1) GNU C Library(glibc) singly/sorted linked lists, (2) GNU C Library(glibc) doubly linked lists, (3) OpenBSD SysQueue, (4) GRASShopper [49] singly linked lists, (5) GRASShopper [49] doubly linked lists, (6) GRASShopper [49] sorted linked lists, (7) VCDryad [48] sorted linked lists, (8) VCDryad [48] binary search trees, AVL trees, and treaps, (9) AFWP [32] singly/sorted linked lists, and (10) ExpressOS [42] MemoryRegion.The specifications for these programs are generally checks for their full functional correctness, such as preserving or altering shapes of data structures, inserting or deleting keys, filtering or finding elements, and sortedness of elements.The specifications hence involve separation logic with arithmetic as well as recursive definitions that compute numbers (like lengths and heights), data-aggregating recursive functions (such as multisets of keys stored in data-structures), and complex combinations of these properties (e.g., to specify binary search trees, AVL trees and treaps).All programs are annotated in Dryad, and checking validity of the resulting verification conditions is undecidable.
To create our benchmarks, we first picked all programs that contained iterative loops, erased the userprovided loop invariants, and used our framework to synthesize adequate inductive invariants (our tool can synthesize multiple invariants for a program).We also selected some programs that were purely recursive, where the contract for the function had been strengthened to make the verification succeed.We weakened these contracts to only state the specification (typically by removing formulas in the post-conditions of recursivelycalled functions) and introduced annotation holes instead.The goal was to synthesize strengthenings of these contracts that allow proving the program correct.We also chose five straight-line programs, deleted their post-conditions, and evaluated whether we can learn post-conditions for them.Since our conjunctive learner learns the strongest invariant expressible as a conjunct, we can use our framework to synthesize post-conditions as well.
After removing annotations from the benchmarks, we automatically inserted appropriate predicates over which to build invariants and contracts as described above.For all benchmark suits, conjunctions of these predicates were sufficient to prove the program correct.

Experimental Results
We performed all experiments in a virtual machine running Ubuntu 16.04.1 on a single core of an Intel Core i7-7820 HK 2.9 GHz CPU with 2 GB memory.The box plots in Figure 4 summarize the results of this empirical evaluation aggregated by benchmark suite, specifically the time required to verify the programs, the number of base predicates, and the number iterations in the learning process (see Appendix A for full details).Each box in the diagrams shows the lower and upper quartile (left and right border of the box, respectively), the median (line within the box), as well as the minimum and maximum (left and right whisker, respectively).
Our prototype was successful in learning invariants and contracts for all 82 benchmarks.Moreover, the fact that the median time for a great majority of benchmarks suits is less than 10 s shows that our technique is extremely effective in finding inductive Dryad invariants.We also observe that despite many examples having hundreds of base predicates, which in turn suggests a worst-case complexity of hundreds of iterations, the learner was able to learn with much fewer iterations and the number of predicates in the final invariant is small.This shows that the non-provability information provided by the natural proof engine provides much more information than what the worst-case suggests.
To the best of our knowledge, our prototype is the only tool currently able of fully automatically verifying this challenging benchmark set.We must emphasize, however, that there are subsets of our benchmarks that can be solved by reformulating verification in decidable fragments of separation logic studied-we refer the reader to the related work in Section 1 for a survey of such work.Our goal in this evaluation, however, is not to compete with other, mature tools on a subset of benchmarks, but to measure the efficacy of our proposed CD-NPI based invariant synthesis framework on the whole benchmark set.

Application: Learning Invariants in the Presence of Bounded Quantifier Instantiation
Software verification of numerous applications must deal with quantification.For instance, quantifiers are often needed for axiomatizing theories that are not already equipped with decision procedures, for specifying properties of unbounded data structures and dynamically allocated memory, as well as for defining recursive properties of programs.For instance, the power of two function can be defined recursively using quantifiers as Despite the fact that various important first-order theories are undecidable (e.g., the first-order theory of arithmetic with uninterpreted functions), modern SMT solvers implement a host of heuristics to cope with quantifier reasoning.Quantifier instantiation, including pattern-based quantifier instantiation (e.g., E-matching [17]) and model-based quantifier instantiation [26], are particularly effective heuristics in this context.The key idea of instantiation-based heuristics is to instantiate universally quantified formulas with a finite number of ground terms and then check for validity of the resulting quantifier-free formulas (whose theory needs to be decidable).The exact instantiation of ground terms varies from method to method, but most instantiation-based heuristics are necessarily incomplete in general due to the undecidability of the underlying decision problems.
We can apply invariant synthesis framework for verification engines that employ quantifier instantiation in the following way.Assume that U is an undecidable first-order theory allowing uninterpreted functions and that D is its decidable quantifier-free fragment.Then, quantifier instantiation can be seen as a transformation of a U-formula ϕ (potentially containing quantifiers) into a D-formula approx(ϕ) in which all existential quantifiers have been eliminated (e.g., using skolemization) and all universal quantifiers have been replaced by finite conjunctions over ground terms. 7This means that if the D-formula approx(ϕ) is valid, then the U-formula ϕ is valid as well.On the other hand, if approx(ϕ) is not valid, one cannot deduce the validity of ϕ.However, a D-model of approx(ϕ) can be used to derive non-provability information as described in Section 2.1.
We have implemented our learning framework for synthesizing invariants based on bounded quantifier instantiation.Our prototype is based on Boogie/Z3 as the verification engine and uses Houdini to learn conjunctive invariants.In the remainder of this section, we present empirical results of this implementation on benchmarks taken from competitions and verified systems such as IronFleet [29].
Evaluation We collected a benchmarks suite of twelve programs, which we obtained by simplifying programs found in IronFleet [29] (provably correct distributed systems), VSComp (Verified Software Competition) benchmarks [36], ExpressOS [42] (a secure operating system for mobile devices), and sparse matrix multiplication programs [8].In these programs, quantifiers are used in specifying recursively defined predicates such as power(n, m) and sum(n), and various array properties such as minimum/maximum elements, existence of specific elements, no duplicate elements, permutations of array elements, relations between two arrays, periodic properties of array elements, and bijective (injective and surjective) maps.The specifications hence are undecidable and fall outside of the decidable array property fragment [7].In particular, the array specifications involve strict comparison (<) between universally quantified index variables, array accesses in the index guard, nested array accesses (e.g., a 1 [a 2 [i]]), arithmetic expressions over universally quantified index variables, and alternation of universal and existential quantifiers.
From this benchmark suite, we erased the user-defined loop invariants and used our framework to find adequate inductive invariants.We generated a set of predicates that serve as the building blocks of our invariants.To this end, we used the pre-/post-conditions of the program being verified as templates from which the actual predicates are generated; the templates are instantiated using all combinations of program variables that occur in the program.We also generated predicates for octagonal constraints, (i.e., relations between two integer variables of the form, ±x ± y ≤ c).For a few programs, we also generated the octagonal predicates over array access expressions that appear in the program.

Experimental Results
We performed all experiments in a virtual machine running Ubuntu 16.04.1 on a single core of an Intel Core i7-7820 HK 2.9 GHz CPU with 2 GB memory.The results of these experiments are listed in Table 1.As can be seen from the table, our framework is effective in finding inductive invariants that result in proving the programs correct (with an average of less than a minute per routine).Despite having hundreds of candidate predicates in many examples, which in turn suggests a worst-case complexity of hundreds of rounds, the learner was able to learn with much fewer rounds.Again, the non-provability information provided by the verification engine provides much more information than the worst-case suggests.

Conclusion
We have presented learning-based framework for invariant synthesis in the presence of sound but incomplete verification engines.To prove that our technique is effective in practice, we have implemented our framework for two types of specifications: an expressive and undecidable dialect of separation logic called Dryad for specifying heap properties and specifications involving universal quantification.In both cases, our prototype turned out to be extremely effective in learning inductive invariants and pre/post-conditions.In particular, the benchmark suite for Dryad-annotated programs is extremely challenging, containing an extensive list of standard algorithms on dynamic data structures, and we are not aware of any other technique that can handle this benchmark suite.
Several future research directions are interesting.First, the framework we have developed is based on CEGIS where the invariant synthesizer synthesizes invariants using non-provability information but does not directly work on the program's structure.It would be interesting to extend white-box invariant generation techniques such as interpolation/IC3/PDR, working using D (or B) abstractions of the program directly in order to synthesize invariants for them.Second, in the NPI learning framework we have put forth, it would be interesting to change the underlying logic of communication B to a richer logic, say the theory of arithmetic and uninterpreted functions.The challenge here would be to extract non-provability information from the models to the richer theory, and pairing them with synthesis engines that synthesize expressions against constraints in B. Finally, we think invariant learning should also include experience gained in verifying other programs in the past, both manually and automatically.A learning algorithm that combines logic-based synthesis with experience gained from repositories of verified programs can be more effective.

A Detailed Results of the Heap Invariants Benchmarks
i|v i =false p i as a weakening constraint.-When a Hoare triple of the form {γ}s{β} fails, the verification engine returns the B-formula i|vi=true p i as a strengthening constraint.-When a Hoare triple of the form {γ}s{γ} fails, the verification engine returns the pair ( i|vi=true p i , i|v i =false p i ) of B-formulas as an inductivity constraint.
Note that positive and negative examples are concrete valuations of the variables B, and the implication examples are pairs of such concrete valuations.

Lemma 2 .Definition 3 .
Let J ⊆ P and α be a positive Boolean formula over P.Then, the following holds: (a) c J |= α if and only if B J ⇒ α, and (b) d J |= α if and only if B α ⇒ J. Based on the functions c and d, the translation of a CD-NPI sample into an equi-consistent ICE sample is as follows.Given a CD-NPI sample S = (W, S, I), the ICE sample S S = (S + , S − , S ⇒ ) is defined by

Theorem 1 .
Let S = (W, S, I) be a CD-NPI sample, S S = (S + , S − , S ⇒ ) the ICE sample as in Definition 3, γ a positive Boolean formula over P.Then, γ is consistent with S if and only if γ is consistent with S S .Proof.Let S = (W, S, I) be an CD-NPI sample, and let S S = (S + , S − , S ⇒ ) the ICE sample as in Definition 3.Moreover, let γ be a positive Boolean formula.We prove Theorem 1 by considering each weakening, strengthening, and inductivity constraint together with their corresponding positive, negative, and implication examples individually.

Fig. 4 .
Fig. 4. Experimental evaluation of our prototype.The numbers in italic brackets shows the total number or programs in the suite (first number) and the maximum predicate category used (second number).

Definition 1. A verification
engine is normal if it satisfies two properties: 1. if the engine cannot prove the validity of the Hoare triple {α}s{γ} and B δ ⇒ γ, then it cannot prove the validity of the Hoare triple {α}s{δ}; and 2. if the engine cannot prove the validity of the Hoare triple {γ}s{β} and B γ ⇒ δ, then it cannot prove the validity of the Hoare triple {δ}s{β}.
2, this is true if and only if d J |= γ.Hence, v |= γ.Conversely, assume that γ is consistent with S. Thus, v |= γ, which means d J |= γ.By Lemma 2, this is true if and only if B γ ⇒ J.
-Pick a strengthening constraint J ∈ S, and let v ∈ S − with v = c( J) be the corresponding negative sample.Moreover, assume that γ is consistent with S and, thus, B J ⇒ γ.By Lemma 2, this is true if and only if c J |= γ.Hence, v |= γ.Conversely, assume that γ is consistent with S. Thus, v |= γ, which means c J |= γ.By Lemma 2, this is true if and only if B J ⇒ γ.

Table 1 .
Experimental results of the quantifier instantiation benchmarks.The column |P| refer to the number of candidate predicates, the column # Iterations to the number of iterations of the teacher and learner, and the column |Inv| to the number of predicates in the inferred invariant.

Table 2 :
Experimental results of the heap invariants benchmarks.The column |P| refer to the number of candidate predicates, the column Cat.corresponds to the category of predicates used, the column # Iterations to the number of iterations of the teacher and learner, and the column |Inv| to the number of predicates in the inferred invariant.A † indicates contract strengthening, while a * indicates post condition learning.(1)GNU C Library(glibc) Singly and Sorted Linked-List