- An invariant is a condition or relation that is always true
In OOP, an invariant is a set of assertions that must always hold true during the life of an object for the program to be valid.
- An invariant is any logical rule that must be obeyed throughout the execution of your program that can be communicated to a human, but not to your compiler.
- This is the design by contract principle.
So 1 is like an assertion; 2 is like a tool for proving correctness, performance, or other properties