1. In a computer system, a method of annotating computer program source code stored on a computer-readable medium, the method comprising: receiving the computer program source code, wherein the computer program source code comprises a plurality of program statements; receiving a specification, wherein the specification comprises one or more rules comprising a program statement pattern that specifies when to generate clauses, and a state values pattern that specifies clauses to generate; in a computer, applying the specification to the computer program source code, wherein the applying generates a plurality of clauses; based on the plurality of clauses, inferring one or more annotations for the computer program source code; and annotating the computer program source code with the one or more annotations; wherein the inferring comprises performing (a)-(d) on at least one given program statement for a given rule out of the one or more rules applied responsive to determining that the given program statement matches the program statement pattern of the given rule, wherein the given program statement comprises a branch statement, an assignment statement, or a function entry statement: (a) in the given program statement, finding one or more values for respective one or more free variables in the given rule according to matches between the given program statement and a program statement pattern of the given rule; (b) substituting the one or more values into a state values pattern of the given rule, wherein the substituting generates a clause; (c) in the clause, quantifying over any remaining free variables; and (d) adding the clause to the plurality of clauses.