Are invariants, tautologies?

227 views Asked by At

So I've come across the term invariants while reading the Assertions Java API. After I read the other articles on the net in my understanding invariants are tautologies. Did I misunderstand it?

3

There are 3 answers

4
Raedwald On BEST ANSWER

Consider the difference between what a program ought to do, and what it actually does. If the program is correct, all the assertions are tautologies. If the program is faulty, they are not.

3
Mitch Wheat On

In logic, a tautology is a statement which is true by its own definition, and is therefore fundamentally uninformative. Logical tautologies use circular reasoning within an argument or statement.

An invariant is simply something that won't change.

0
MattClarke On

Tautologies are statements that are always true. Invariants are statements that are intended to be true within a specific context.

Some invariants are not tautologies. For instance, in a programmed loop that adds 1 to i each iteration and terminates when i=max, you might declare an invariant like i < max at the top of the loop. That is not a tautology because the condition is not universally true: there is no logical necessity about i being less than max. The intention is that it will be true each time a specific point is reached in the context of a specific computation.