Remix.run Logo
▲ hedora 2 hours ago

This.

Now, write a theorem describing a non-trivial piece of software. Is your theorem longer or shorter than the source code? Easier or harder to read?

▲miloignis an hour ago | parent | next [-]

The nice thing is that a theorem doesn't have to completely describe the software, it can just describe some property you care about.

Say, no crashes, no dead or livelocks, O(n log n) in the size of the input, same number of instructions executed & memory accessed no matter what the encryption key is, etc etc.

These type of theorems are significantly smaller than the source code, pretty re-usable across different applications, and extremely useful properties.

▲konart 44 minutes ago | parent | prev [-]

Well, property tests exist and in some cases they are better soslution than other types of test.

Obviously you don't write "a theorem" describing a big piece, but just a fuinction, for example.

Say you have a function that takes in 3 Points (x,y coords) and returns a Triangle (T) object. Than you can have a property test that will confirm that T is actually a triangle and not something else.