Python Programming

Contracts, Property Tests, and Proofs

3:30

Plays from YouTube. Watch on YouTube

Can passing a thousand tests prove that a Python function is correct?

Meet contracts, property-based testing and mathematical proof: three different tools for trustworthy software.

We start with preconditions and postconditions, then compare example tests with automatically generated properties.

From there, we use the definition of divisibility to prove a general theorem and disprove a different claim with a counterexample.

Finally, we connect a primality algorithm to the mathematics that justifies its search boundary.

The big idea: tests observe behavior, while proofs establish universal guarantees under explicit assumptions.

Software correctness explained visually, one concept at a time.