src/HOL/ex/Puzzle.thy
author paulson
Fri, 29 Oct 2004 15:16:02 +0200
changeset 15270 8b3f707a78a7
parent 14126 28824746d046
child 16417 9bc16273c2d4
permissions -rw-r--r--
fixed reference to renamed theorem
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2222
a3fb552f10e3 Added Lagrang. Modified comment.
nipkow
parents: 1476
diff changeset
     1
(*  Title:      HOL/ex/Puzzle.thy
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
     3
    Author:     Tobias Nipkow
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993 TU Muenchen
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     5
2222
a3fb552f10e3 Added Lagrang. Modified comment.
nipkow
parents: 1476
diff changeset
     6
A question from "Bundeswettbewerb Mathematik"
13116
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
     7
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
     8
Proof due to Herbert Ehler
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
13116
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    11
theory Puzzle = Main:
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    12
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    13
consts f :: "nat => nat"
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    14
14126
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13116
diff changeset
    15
specification (f)
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13116
diff changeset
    16
  f_ax [intro!]: "f(f(n)) < f(Suc(n))"
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13116
diff changeset
    17
    by (rule exI [of _ id], simp)
13116
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    18
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    19
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    20
lemma lemma0 [rule_format]: "\<forall>n. k=f(n) --> n <= f(n)"
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    21
apply (induct_tac "k" rule: nat_less_induct)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    22
apply (rule allI)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    23
apply (rename_tac "i")
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    24
apply (case_tac "i")
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    25
 apply simp
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    26
apply (blast intro!: Suc_leI intro: le_less_trans)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    27
done
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    28
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    29
lemma lemma1: "n <= f(n)"
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    30
by (blast intro: lemma0)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    31
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    32
lemma lemma2: "f(n) < f(Suc(n))"
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    33
by (blast intro: le_less_trans lemma1)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    34
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    35
lemma f_mono [rule_format (no_asm)]: "m <= n --> f(m) <= f(n)"
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    36
apply (induct_tac "n")
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    37
 apply simp
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    38
apply (rule impI)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    39
apply (erule le_SucE)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    40
 apply (cut_tac n = n in lemma2, auto) 
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    41
done
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    42
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    43
lemma f_id: "f(n) = n"
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    44
apply (rule order_antisym)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    45
apply (rule_tac [2] lemma1) 
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    46
apply (blast intro: leI dest: leD f_mono Suc_leI)
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    47
done
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    48
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    49
end
13116
baabb0fd2ccf converted to Isar
paulson
parents: 8018
diff changeset
    50