In one embodiment, a computer system performs a method for verifying the
validity or invalidity of a software routine by learning appropriate
invariants at each program point. A computer system chooses an abstract
domain that is sufficiently precise to express the appropriate
invariants. The computer system associates an inconsistency measure with
any two abstract elements of the abstract domain. The computer system
searches for a set of local invariants configured to optimize a total
inconsistency measure which includes a sum of local inconsistency
measures. The computer system optimizes the total inconsistency measure
for all input/output pairs of the software routine. In one embodiment,
the optimization of total inconsistency is achieved by the computer
system which repeatedly replaces a locally inconsistent invariant with a
new invariant, randomly selected among the possible invariants which are
locally less inconsistent with the current invariants at the neighboring
program points.