In 1969 Tony Hoare, a British computer scientist, published "An Axiomatic Basis for Computer Programming", building on work by Robert Floyd. Its central idea was simple: to prove a loop correct, find a statement that is true before the loop starts and stays true after every pass. When the loop stops, that statement, together with the stopping condition, gives the answer. This loop invariant 循环不变量 turns tracing a program into a short proof. Hoare later received the Turing Award.
GRE Mathematics counting and algorithm questions ask you to:
- Count each weak composition 弱组合分拆 with stars and bars.
- Handle lower bounds by shifting and upper bounds by inclusion–exclusion.
- Trace loops and flowcharts, counting iterations.
- State and use a loop invariant.