1 header {* An old chestnut *}
7 text_raw {* \footnote{A question from ``Bundeswettbewerb Mathematik''.
8 Original pen-and-paper proof due to Herbert Ehler; Isabelle tactic
9 script by Tobias Nipkow.} *}
11 text {* \textbf{Problem.} Given some function $f\colon \Nat \to \Nat$
12 such that $f \ap (f \ap n) < f \ap (\idt{Suc} \ap n)$ for all $n$.
13 Demonstrate that $f$ is the identity. *}
16 assumes f_ax: "\<And>n. f (f n) < f (Suc n)"
18 proof (rule order_antisym)
20 fix n show "n \<le> f n"
21 proof (induct "f n" arbitrary: n rule: less_induct)
26 from f_ax have "f (f m) < f n" by (simp only: Suc)
27 with less have "f m \<le> f (f m)" .
28 also from f_ax have "\<dots> < f n" by (simp only: Suc)
29 finally have "f m < f n" .
30 with less have "m \<le> f m" .
31 also note `\<dots> < f n`
32 finally have "m < f n" .
33 then have "n \<le> f n" by (simp only: Suc)
37 then show ?thesis by simp
45 then have "f m \<le> f n"
48 then have "m = 0" by simp
49 then show ?case by simp
52 from Suc.prems show "f m \<le> f (Suc n)"
55 with Suc.hyps have "f m \<le> f n" .
56 also from ge f_ax have "\<dots> < f (Suc n)"
57 by (rule le_less_trans)
58 finally show ?thesis by simp
61 then show ?thesis by simp
71 then have "Suc n \<le> f n" by simp
72 then have "f (Suc n) \<le> f (f n)" by (rule mono)
73 also have "\<dots> < f (Suc n)" by (rule f_ax)
74 finally have "\<dots> < \<dots>" . then show False ..
76 then show ?thesis by simp