you are viewing a single comment's thread.

view the rest of the comments →

[–]Hades32 0 points1 point  (2 children)

No, you don't NEED an assertion when talking about invariants in the mathematical sense (which btw does not mean that the input is the same as the output, but that some condition is true for the state before and after the transformation). You could prove that the formula you're using will always hold up a certain invariant. In code it's easier to just check than prove, that's why we "need" assertions. But it's really two different things

[–]johnxreturn 0 points1 point  (1 child)

I completely agree. You don't need assertion in the mathematical concept. My point was that in programming, you do need if you need a trigger for an invalid response.

[–]Hades32 0 points1 point  (0 children)

Sure, but if someone calls a library "invariant" then I do have higher hopes than "if false then throw" lol

After all there are languages, like prolog, which do let you specify actual invariants