Procedures
Preconditions
Files: [Slides] [Code examples]
Postconditions
Files: [Slides with solutions] [Code examples with solutions]
Notice that some slides have been corrected after class.
What you should have learned after completing chapter 4.2:
- The semantics of recursive procedures can be formalized in turns of higher-order fixed points.
- We reason modularly about procedure calls, that is, we rely solely on the procedure contract without inspecting its implementation.
- For partial correctness reasoning, this yields a simple approach: try to proof the specification for the procedure and use the contracts whenever we encounter a procedure call.
- In contrast to loops, we cannot strengthen procedure contracts whenever we encounter a new client. It is thus very important to support framing: properties that are not affected by a call should be preserved.
- Similarly to loops, we use variants to prove that a procedure terminates.
- You should be able to automate modular reasoning about procedures and termination proofs with variants by encoding these concepts into
PL0
.