2 (* Let f be a function over natural numbers such that, for all n
4 Show that f(n)=n for all n.
6 Inspired by a Dafny example (see http://searchco.de/codesearch/view/28108482)
9 Edsger W. Dijkstra: Heuristics for a Calculational Proof.
10 Inf. Process. Lett. (IPL) 53(3):141-143 (1995)
19 axiom H1: forall n: int. 0 <= n -> 0 <= f n
20 axiom H2: forall n: int. 0 <= n -> f (f n) < f (n+1)
24 theory Step1 (* k <= f(n+k) by induction over k *)
28 predicate p (k: int) = forall n: int. 0 <= n -> k <= f (n+k)
29 clone int.SimpleInduction as I1
30 with predicate p = p, lemma base, lemma induction_step
39 lemma L3: forall n: int. 0 <= n -> n <= f n && f n <= f (f n)
40 lemma L4: forall n: int. 0 <= n -> f n < f (n+1)
42 (* so f is increasing *)
43 predicate p' (k: int) = forall n m: int. 0 <= n <= m <= k -> f n <= f m
44 clone int.SimpleInduction as I2
45 with predicate p = p', lemma base, lemma induction_step
47 lemma L5: forall n m: int. 0 <= n <= m -> f n <= f m
48 lemma L6: forall n: int. 0 <= n -> f n < n+1
50 goal G: forall n: int. 0 <= n -> f n = n