1. A method for generating a set of ordering constraints that prevent executions of a program P violating a specification, said method comprising: identifying one or more incoming avoidable transitions for a state, wherein said one or more incoming avoidable transitions comprise a transition taken by the program that can be prohibited by a fence, wherein a given transition from a first state σ 1 t to a second state σ 1 is avoidable if there exists a label l 1 identifying a statement in said program P such that said label l 1 < σ,p l t , where a state σ executes a statement at said label l 1 before executing a statement at a label l 2 ; refining one or more ordering constraints for said state; and generating said set of ordering constraints by taking a logical conjunction of ordering constraints for all states that violate said specification.