1 (* ======== translation of "The shortest?" from Examples/forster.ml ======== *)
5 let FORSTER_PUZZLE_1 = thm `;
7 thus (!n. f(n + 1) > f(f(n))) ==> !n. f(n) = n
9 assume !n. f(n + 1) > f(f(n));
10 !n. f(f(n)) < f(SUC n) [1] by -,GT,ADD1;
11 !m n. m <= f(n + m) [2]
13 !n. 0 <= f(n + 0) [3] by LE_0,ADD_CLAUSES,LE_SUC_LT;
15 assume !n. m <= f(n + m);
16 !n. m < f(SUC (n + m)) by -,1,LET_TRANS,SUB_ADD;
17 thus !n. SUC m <= f(n + SUC m) by -,LE_0,ADD_CLAUSES,LE_SUC_LT;
19 qed by INDUCT_TAC,-,3;
20 !n. f(n) < f(SUC n) [4] by -,1,LET_TRANS,LE_TRANS,ADD_CLAUSES;
21 !m n. f(m) < f(n) ==> m < n
23 !n. f(0) < f(n) ==> 0 < n [5] by LT_LE,LE_0,LTE_TRANS,LE_SUC_LT;
25 assume !n. f(m) < f(n) ==> m < n;
26 thus !n. f(SUC m) < f(n) ==> SUC m < n
27 by -,4,LT_LE,LE_0,LTE_TRANS,LE_SUC_LT;
29 qed by INDUCT_TAC,-,5;
30 qed by -,1,2,LE_ANTISYM,ADD_CLAUSES,LT_SUC_LE`;;
32 (* ======== long-winded informal proof ===================================== *)
36 Suppose that f(f(n)) < f(n + 1) for all n. We want to
37 show that f has to be the identity. We will do this by
38 successively establishing two properties of f (both in a
39 certain sense being "monotonicity of f"):
45 The first is the harder one to prove. The second is easy,
46 but the proof uses the first. Once we know the second
47 property we know so much about f that the result easily
50 To prove the first, suppose by contradiction that there is a
51 counterexample, so there is an n with f "going backwards",
52 i.e., with f(n) < n. Take such a counterexample with f(n)
53 minimal. (That this minimality is the right one to focus
54 on is the key to the whole proof for me. Of course one can
55 present this proof the other way around -- as an induction --
56 but the intuition of a descending chain of counterexamples
57 I find much easier to remember.) Now from the relation
61 it seems reasonable to look for an n' with f going backwards
62 that has an image less than f(n). So look at
64 n - 1 |-> f(n - 1) |-> f(f(n - 1))
66 and distinguish how f(n - 1) compares to f(n). If it's less,
67 then the left mapping goes backward to an image < f(n).
68 (To see that it goes backward, use that f(n) < n, so that
69 f(n) <= n - 1.) If it's not less, then the right mapping
70 goes backward to an image < f(n). In both cases we have
71 a contradiction with the minimality of our choice of n.
73 The second kind of monoticity now follows using a trivial
76 f(n) <= f(f(n)) < f(n + 1)
78 This shows that f(n) < f(n + 1) for all n, from with the
79 monotonicity of the whole function directly follows.
81 Finally to show that f has to be the identity, notice that
82 a strictly monotonic function always has the property that
86 (Of course we knew this already, but I like to just think
87 about the strict monotonicity of f at this point.)
89 However we also can get an upper bound on f(n). A strictly
90 monototic function always has a strictly monotonic inverse,
91 and so from the key property
99 Together this means that we have to have that f(n) = n.
103 (* ======== formal proof sketch of this proof ============================== *)
106 sketch_mode := true;;
108 let FORSTER_PUZZLE_SKETCH = ref None;;
110 FORSTER_PUZZLE_SKETCH := Some `;
112 assume !n. f(f(n)) < f(n + 1);
119 consider n such that f(n) < n /\
120 !m. f(m) < m ==> f(n) <= f(m);
122 suppose f(n - 1) < f(n);
123 f(n - 1) < n - 1 /\ f(n - 1) < f(n)
130 suppose f(n) <= f(n - 1);
131 f(f(n - 1)) < f(n - 1) /\ f(f(n - 1)) < f(n);
135 !m n. m < n ==> f(m) < f(n)
139 f(n) <= f(f(n)) /\ f(f(n)) < f(n + 1);
140 thus f(n) < f(n + 1);
145 !m n. f(m) < f(n) ==> m < n;
151 sketch_mode := false;;
153 (* ======== formalization from this formal proof sketch ==================== *)
157 let FORSTER_PUZZLE_2 = thm `;
159 assume !n. f(f(n)) < f(n + 1) [1];
165 ?n. f(n) < n by NOT_LE;
166 ?fn n. f(n) = fn /\ f(n) < n;
167 consider fn such that (?n. f(n) = fn /\ f(n) < n) /\
168 !fm. fm < fn ==> ~(?m. f(m) = fm /\ f(m) < m) [3]
169 by REWRITE_TAC,GSYM num_WOP;
170 consider n such that f(n) = fn /\ f(n) < n;
171 f(n) < n /\ !m. f(m) < m ==> f(n) <= f(m) [4] by 3,NOT_LE;
173 suppose f(n - 1) < f(n) [5];
174 f(n - 1) < n - 1 /\ f(n - 1) < f(n)
177 f(n) <= n - 1 by ARITH_TAC;
181 suppose f(n) <= f(n - 1) [6];
182 0 < n by ARITH_TAC,4;
183 (n - 1) + 1 = n by ARITH_TAC;
184 f(f(n - 1)) < f(n) by 1;
185 f(f(n - 1)) < f(n - 1) /\ f(f(n - 1)) < f(n) by ARITH_TAC,6;
189 !m n. m < n ==> f(m) < f(n) [7]
193 f(n) <= f(f(n)) /\ f(f(n)) < f(n + 1) by 1,2;
194 thus f(n) < f(SUC n) by ARITH_TAC; // modified from f(n) < f(n + 1)
197 SPEC (parse_term "\\m n. (f:num->num)(m) < f(n)") TRANSITIVE_STEPWISE_LT;
199 n <= f(n) [8] by 2; // really should be an induction proof from 7
200 !m n. f(m) < f(n) ==> m < n [9] by 7,LE_LT,NOT_LE;
201 f(f(n)) < f(n + 1) by 1;
203 thus f(n) = n by ARITH_TAC,8;
206 (* ======== ... and a slightly compressed version ========================== *)
210 let FORSTER_PUZZLE_3 = thm `;
212 assume !n. f(f(n)) < f(n + 1) [1];
216 ?fn n. f(n) = fn /\ f(n) < n by NOT_LE;
217 consider fn such that (?n. f(n) = fn /\ f(n) < n) /\
218 !fm. fm < fn ==> ~(?m. f(m) = fm /\ f(m) < m) [3]
219 by REWRITE_TAC,GSYM num_WOP;
220 consider n such that f(n) = fn /\ f(n) < n [4];
222 suppose f(n - 1) < f(n) [5];
223 f(n - 1) < n - 1 by ARITH_TAC,4;
226 suppose f(n) <= f(n - 1) [6];
227 (n - 1) + 1 = n by ARITH_TAC,4;
228 thus F by 1,3,4,6,LTE_TRANS;
231 !n. f(n) < f(SUC n) by 1,2,ADD1,LET_TRANS;
232 !m n. m < n ==> f(m) < f(n) by LT_TRANS,
233 SPEC (parse_term "\\m n. (f:num->num)(m) < f(n)") TRANSITIVE_STEPWISE_LT;
234 !m n. f(m) < f(n) ==> m < n by LE_LT,NOT_LE;
235 thus !n. f(n) = n by 1,2,ADD1,LE_ANTISYM,LT_SUC_LE`;;
237 (* ======== Mizar formalization from the formal proof sketch =============== *)
242 vocabularies RELAT_1, FUNCT_1, ARYTM, ARYTM_1, ORDINAL2;
243 notations ORDINAL1, RELSET_1, FUNCT_2, NUMBERS, XCMPLX_0, XXREAL_0, NAT_1,
245 constructors XXREAL_0, INT_1, PARTFUN1, VALUED_0, MEMBERED, RELSET_1;
246 registrations XBOOLE_0, RELAT_1, FUNCT_1, ORDINAL1, XXREAL_0, XREAL_0,
247 NAT_1, INT_1, VALUED_0, MEMBERED;
248 requirements NUMERALS, REAL, SUBSET, ARITHM;
249 theorems XXREAL_0, XREAL_1, INT_1, NAT_1, VALUED_0, VALUED_1, FUNCT_2,
254 reserve n,m,fn,fm for natural number;
255 reserve f for Function of NAT,NAT;
258 (for n holds f.(f.n) < f.(n + 1)) implies for n holds f.n = n
261 A1: for n holds f.(f.n) < f.(n + 1);
262 A2: for n holds n <= f.n
266 defpred P[Nat] means ex n st f.n < n & f.n = $1;
267 A4: ex fn st P[fn] by A3;
268 consider fn being Nat such that
269 A5: P[fn] & for fm being Nat st P[fm] holds fn <= fm from NAT_1:sch 5(A4);
271 A6: f.n < n & f.n = fn by A5;
272 n >= 0 + 1 by A6,NAT_1:13;
273 then n - 1 >= 0 by XREAL_1:21;
274 then n - 1 in NAT by INT_1:16;
275 then reconsider m = n - 1 as natural number;
280 then f.n <= m by NAT_1:13;
281 then f.m < m by A7,XXREAL_0:2;
282 hence contradiction by A5,A6,A7;
286 A9: f.(f.m) < f.(m + 1) by A1;
287 then f.(f.m) < f.m by A8,XXREAL_0:2;
288 hence contradiction by A5,A6,A9;
293 f.n <= f.(f.n) & f.(f.n) < f.(n + 1) by A1,A2;
294 hence f.n < f.(n + 1) by XXREAL_0:2;
296 then reconsider f as increasing Function of NAT,NAT by VALUED_1:def 13;
299 dom f = NAT & m in NAT & n in NAT by FUNCT_2:def 1,ORDINAL1:def 13;
300 hence f.m < f.n implies m < n by VALUED_0:def 15;
303 f.(f.n) < f.(n + 1) by A1;
304 then f.n < n + 1 by A10;
305 then n <= f.n & f.n <= n by A2,NAT_1:13;
306 hence thesis by XXREAL_0:1;
311 (* ======== miz3 formalization close to the Mizar formalization ============ *)
315 let FORSTER_PUZZLE_4 = thm `;
316 !f. (!n. f(f(n)) < f(n + 1)) ==> !n. f(n) = n
319 assume !n. f(f(n)) < f(n + 1) [1];
323 set P = \fn. ?n. f(n) < n /\ f(n) = fn [P];
324 ?fn. P(fn) [4] by 3,P,NOT_LE;
325 consider fn such that P(fn) /\ !fm. P(fm) ==> fn <= fm [5]
327 consider n such that f(n) < n /\ f(n) = fn [6] by P,5;
329 n = m + 1 [m] by ARITH_TAC,6; // replaces the reconsider
331 suppose f(m) < f(n) [7];
332 f(n) < m + 1 by ARITH_TAC,6;
333 f(n) <= m by ARITH_TAC,-;
334 f(m) < m by ARITH_TAC,-,7;
335 f(n) <= f(m) by -,P,5,6; // extra step
336 thus F by ARITH_TAC,-,7;
338 suppose f(n) <= f(m) [8];
339 f(f(m)) < f(m + 1) [9] by 1;
340 f(f(m)) < f(m) by -,m,8,LTE_TRANS;
341 f(n) <= f(f(m)) by -,P,5,6; // extra step
342 thus F by -,m,9,NOT_LE;
347 f(n) <= f(f(n)) /\ f(f(n)) < f(n + 1) by 1,2;
348 thus f(n) < f(n + 1) by ARITH_TAC,-;
350 !n. f(n) < f(SUC n) by -,ADD1; // extra step
351 !m n. m < n ==> f(m) < f(n) by -,LT_TRANS,
352 SPEC (parse_term "\\m n. (f:num->num)(m) < f(n)") TRANSITIVE_STEPWISE_LT;
353 // replaces the reconsider
356 thus f(m) < f(n) ==> m < n by -,LE_LT,NOT_LE;
359 f(f(n)) < f(n + 1) by 1;
360 f(n) < n + 1 by -,10;
361 n <= f(n) /\ f(n) <= n by -,2,ADD1,LT_SUC_LE;
362 thus thesis by ARITH_TAC,-;
365 (* ======== formalization following Tobias & Sean's version ================ *)
369 let num_MONO_LT_SUC = thm `;
371 assume !n. f(n) < f(SUC n);
372 !n m. m < n ==> f(m) < f(n) by LT_TRANS,
373 SPEC (parse_term "\\m n. (f:num->num)(m) < f(n)") TRANSITIVE_STEPWISE_LT;
374 thus !n m. m < n <=> f(m) < f(n) by LE_LT,NOT_LE`;;
376 let FORSTER_PUZZLE_5 = thm `;
378 assume !n. f(f(n)) < f(SUC(n));
379 !n m. n <= m ==> n <= f(m)
381 now let n be num; assume !m. n <= m ==> n <= f(m);
382 !m. SUC n <= m ==> ?k. m = SUC k by num_CASES,LT,LE_SUC_LT;
383 thus !m. SUC n <= m ==> SUC n <= f(m) by LE_SUC,LET_TRANS,LE_SUC_LT;
385 !m. 0 <= m ==> 0 <= f(m);
387 !n. f(n) < f(SUC n) by LE_REFL,LET_TRANS;
388 thus !n. f(n) = n by num_MONO_LT_SUC,LT_SUC_LE,LE_ANTISYM`;;