hraness
Theme
Appearance

saved

Logic for Programmers by Hillel Wayne

by Hillel WayneTigerBeetlepublished

Hraness wrote this summary from a saved copy of the source. Quotations are taken word for word from the source.

gist

Hillel Wayne argues that a little formal logic helps programmers decide when a new function, API, or system can replace an old one without breaking callers. Using sets, predicates, and quantifiers, he shows that safe replacement means loosening or keeping preconditions and tightening or keeping postconditions—and that not every observable property is a postcondition worth guaranteeing.

ideas

  • Safe replacement is a logical relation, not a vibe. New can replace old when workflows that depended on old still succeed after the swap.
  • Preconditions may loosen; postconditions may tighten. Old preconditions must imply new ones, and new postconditions must imply old ones.
  • Not every observable property is a postcondition. Latency, incidental behavior, and other real-world expectations can break even when the stated contract holds.
  • Types and state fit the same story. Hillel sketches rather than works through the stateful case, pointing to Barbara Liskov's behavioral subtyping, whose rules add conditions for internal data and history beyond preconditions and postconditions.

quotes

“Everyone in this room is bald.”

Hillel Wayne, opening a quantified claim with a counterexample-friendly example

“New can replace old when workflows using old don't break with new.”

Hillel Wayne

“Not all properties are post conditions.”

Hillel Wayne, warning that contracts omit many breakage modes

“New can replace old when the old precondition implies the new precondition and the new post condition implies the old post condition.”

Hillel Wayne