Every time you run a program, something could go wrong: you might add a number to a string, call a method on null, or read a field that does not exist. Type checking is a static analysis that flags exactly those mistakes — before the program ever runs.
But a type checker is only useful if it means something. The question is: if the type checker is happy, does that really guarantee the program won't crash? The answer is captured in a theorem called type soundness, first stated cleanly by Wright and Felleisen in 1994.
It rests on two lemmas that together say: "a well-typed program never gets stuck." Progress says every well-typed program can always take a step (or is already finished). Preservation says that step doesn't break the typing. Together, they turn type annotations from documentation into a runtime guarantee.
Comments
Loading comments...