| author | blanchet | 
| Mon, 13 Sep 2010 15:01:31 +0200 | |
| changeset 39340 | 3998dc0bf82b | 
| parent 32960 | 69916a850301 | 
| child 45602 | 2a858377c3d2 | 
| permissions | -rw-r--r-- | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
26056 
diff
changeset
 | 
1  | 
(* Title: ZF/Nat_ZF.thy  | 
| 
26056
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
2  | 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
3  | 
Copyright 1994 University of Cambridge  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
4  | 
*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
5  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
6  | 
header{*The Natural numbers As a Least Fixed Point*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
7  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
8  | 
theory Nat_ZF imports OrdQuant Bool begin  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
9  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
10  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
11  | 
nat :: i where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
12  | 
    "nat == lfp(Inf, %X. {0} Un {succ(i). i:X})"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
13  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
14  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
15  | 
quasinat :: "i => o" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
16  | 
"quasinat(n) == n=0 | (\<exists>m. n = succ(m))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
17  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
18  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
19  | 
(*Has an unconditional succ case, which is used in "recursor" below.*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
20  | 
nat_case :: "[i, i=>i, i]=>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
21  | 
"nat_case(a,b,k) == THE y. k=0 & y=a | (EX x. k=succ(x) & y=b(x))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
22  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
23  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
24  | 
nat_rec :: "[i, i, [i,i]=>i]=>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
25  | 
"nat_rec(k,a,b) ==  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
26  | 
wfrec(Memrel(nat), k, %n f. nat_case(a, %m. b(m, f`m), n))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
27  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
28  | 
(*Internalized relations on the naturals*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
29  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
30  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
31  | 
Le :: i where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
32  | 
    "Le == {<x,y>:nat*nat. x le y}"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
33  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
34  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
35  | 
Lt :: i where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
36  | 
    "Lt == {<x, y>:nat*nat. x < y}"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
37  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
38  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
39  | 
Ge :: i where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
40  | 
    "Ge == {<x,y>:nat*nat. y le x}"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
41  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
42  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
43  | 
Gt :: i where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
44  | 
    "Gt == {<x,y>:nat*nat. y < x}"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
45  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
46  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
47  | 
greater_than :: "i=>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
48  | 
    "greater_than(n) == {i:nat. n < i}"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
49  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
50  | 
text{*No need for a less-than operator: a natural number is its list of
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
51  | 
predecessors!*}  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
52  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
53  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
54  | 
lemma nat_bnd_mono: "bnd_mono(Inf, %X. {0} Un {succ(i). i:X})"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
55  | 
apply (rule bnd_monoI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
56  | 
apply (cut_tac infinity, blast, blast)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
57  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
58  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
59  | 
(* nat = {0} Un {succ(x). x:nat} *)
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
60  | 
lemmas nat_unfold = nat_bnd_mono [THEN nat_def [THEN def_lfp_unfold], standard]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
61  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
62  | 
(** Type checking of 0 and successor **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
63  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
64  | 
lemma nat_0I [iff,TC]: "0 : nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
65  | 
apply (subst nat_unfold)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
66  | 
apply (rule singletonI [THEN UnI1])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
67  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
68  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
69  | 
lemma nat_succI [intro!,TC]: "n : nat ==> succ(n) : nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
70  | 
apply (subst nat_unfold)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
71  | 
apply (erule RepFunI [THEN UnI2])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
72  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
73  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
74  | 
lemma nat_1I [iff,TC]: "1 : nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
75  | 
by (rule nat_0I [THEN nat_succI])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
76  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
77  | 
lemma nat_2I [iff,TC]: "2 : nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
78  | 
by (rule nat_1I [THEN nat_succI])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
79  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
80  | 
lemma bool_subset_nat: "bool <= nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
81  | 
by (blast elim!: boolE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
82  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
83  | 
lemmas bool_into_nat = bool_subset_nat [THEN subsetD, standard]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
84  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
85  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
86  | 
subsection{*Injectivity Properties and Induction*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
87  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
88  | 
(*Mathematical induction*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
89  | 
lemma nat_induct [case_names 0 succ, induct set: nat]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
90  | 
"[| n: nat; P(0); !!x. [| x: nat; P(x) |] ==> P(succ(x)) |] ==> P(n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
91  | 
by (erule def_induct [OF nat_def nat_bnd_mono], blast)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
92  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
93  | 
lemma natE:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
94  | 
"[| n: nat; n=0 ==> P; !!x. [| x: nat; n=succ(x) |] ==> P |] ==> P"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
95  | 
by (erule nat_unfold [THEN equalityD1, THEN subsetD, THEN UnE], auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
96  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
97  | 
lemma nat_into_Ord [simp]: "n: nat ==> Ord(n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
98  | 
by (erule nat_induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
99  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
100  | 
(* i: nat ==> 0 le i; same thing as 0<succ(i) *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
101  | 
lemmas nat_0_le = nat_into_Ord [THEN Ord_0_le, standard]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
102  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
103  | 
(* i: nat ==> i le i; same thing as i<succ(i) *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
104  | 
lemmas nat_le_refl = nat_into_Ord [THEN le_refl, standard]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
105  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
106  | 
lemma Ord_nat [iff]: "Ord(nat)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
107  | 
apply (rule OrdI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
108  | 
apply (erule_tac [2] nat_into_Ord [THEN Ord_is_Transset])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
109  | 
apply (unfold Transset_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
110  | 
apply (rule ballI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
111  | 
apply (erule nat_induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
112  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
113  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
114  | 
lemma Limit_nat [iff]: "Limit(nat)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
115  | 
apply (unfold Limit_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
116  | 
apply (safe intro!: ltI Ord_nat)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
117  | 
apply (erule ltD)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
118  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
119  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
120  | 
lemma naturals_not_limit: "a \<in> nat ==> ~ Limit(a)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
121  | 
by (induct a rule: nat_induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
122  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
123  | 
lemma succ_natD: "succ(i): nat ==> i: nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
124  | 
by (rule Ord_trans [OF succI1], auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
125  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
126  | 
lemma nat_succ_iff [iff]: "succ(n): nat <-> n: nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
127  | 
by (blast dest!: succ_natD)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
128  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
129  | 
lemma nat_le_Limit: "Limit(i) ==> nat le i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
130  | 
apply (rule subset_imp_le)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
131  | 
apply (simp_all add: Limit_is_Ord)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
132  | 
apply (rule subsetI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
133  | 
apply (erule nat_induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
134  | 
apply (erule Limit_has_0 [THEN ltD])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
135  | 
apply (blast intro: Limit_has_succ [THEN ltD] ltI Limit_is_Ord)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
136  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
137  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
138  | 
(* [| succ(i): k; k: nat |] ==> i: k *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
139  | 
lemmas succ_in_naturalD = Ord_trans [OF succI1 _ nat_into_Ord]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
140  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
141  | 
lemma lt_nat_in_nat: "[| m<n; n: nat |] ==> m: nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
142  | 
apply (erule ltE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
143  | 
apply (erule Ord_trans, assumption, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
144  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
145  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
146  | 
lemma le_in_nat: "[| m le n; n:nat |] ==> m:nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
147  | 
by (blast dest!: lt_nat_in_nat)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
148  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
149  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
150  | 
subsection{*Variations on Mathematical Induction*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
151  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
152  | 
(*complete induction*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
153  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
154  | 
lemmas complete_induct = Ord_induct [OF _ Ord_nat, case_names less, consumes 1]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
155  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
156  | 
lemmas complete_induct_rule =  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
26056 
diff
changeset
 | 
157  | 
complete_induct [rule_format, case_names less, consumes 1]  | 
| 
26056
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
158  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
159  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
160  | 
lemma nat_induct_from_lemma [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
161  | 
"[| n: nat; m: nat;  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
162  | 
!!x. [| x: nat; m le x; P(x) |] ==> P(succ(x)) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
163  | 
==> m le n --> P(m) --> P(n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
164  | 
apply (erule nat_induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
165  | 
apply (simp_all add: distrib_simps le0_iff le_succ_iff)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
166  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
167  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
168  | 
(*Induction starting from m rather than 0*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
169  | 
lemma nat_induct_from:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
170  | 
"[| m le n; m: nat; n: nat;  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
171  | 
P(m);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
172  | 
!!x. [| x: nat; m le x; P(x) |] ==> P(succ(x)) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
173  | 
==> P(n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
174  | 
apply (blast intro: nat_induct_from_lemma)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
175  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
176  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
177  | 
(*Induction suitable for subtraction and less-than*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
178  | 
lemma diff_induct [case_names 0 0_succ succ_succ, consumes 2]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
179  | 
"[| m: nat; n: nat;  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
180  | 
!!x. x: nat ==> P(x,0);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
181  | 
!!y. y: nat ==> P(0,succ(y));  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
182  | 
!!x y. [| x: nat; y: nat; P(x,y) |] ==> P(succ(x),succ(y)) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
183  | 
==> P(m,n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
184  | 
apply (erule_tac x = m in rev_bspec)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
185  | 
apply (erule nat_induct, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
186  | 
apply (rule ballI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
187  | 
apply (rename_tac i j)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
188  | 
apply (erule_tac n=j in nat_induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
189  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
190  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
191  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
192  | 
(** Induction principle analogous to trancl_induct **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
193  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
194  | 
lemma succ_lt_induct_lemma [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
195  | 
"m: nat ==> P(m,succ(m)) --> (ALL x: nat. P(m,x) --> P(m,succ(x))) -->  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
196  | 
(ALL n:nat. m<n --> P(m,n))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
197  | 
apply (erule nat_induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
198  | 
apply (intro impI, rule nat_induct [THEN ballI])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
199  | 
prefer 4 apply (intro impI, rule nat_induct [THEN ballI])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
200  | 
apply (auto simp add: le_iff)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
201  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
202  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
203  | 
lemma succ_lt_induct:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
204  | 
"[| m<n; n: nat;  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
205  | 
P(m,succ(m));  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
206  | 
!!x. [| x: nat; P(m,x) |] ==> P(m,succ(x)) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
207  | 
==> P(m,n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
208  | 
by (blast intro: succ_lt_induct_lemma lt_nat_in_nat)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
209  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
210  | 
subsection{*quasinat: to allow a case-split rule for @{term nat_case}*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
211  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
212  | 
text{*True if the argument is zero or any successor*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
213  | 
lemma [iff]: "quasinat(0)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
214  | 
by (simp add: quasinat_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
215  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
216  | 
lemma [iff]: "quasinat(succ(x))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
217  | 
by (simp add: quasinat_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
218  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
219  | 
lemma nat_imp_quasinat: "n \<in> nat ==> quasinat(n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
220  | 
by (erule natE, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
221  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
222  | 
lemma non_nat_case: "~ quasinat(x) ==> nat_case(a,b,x) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
223  | 
by (simp add: quasinat_def nat_case_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
224  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
225  | 
lemma nat_cases_disj: "k=0 | (\<exists>y. k = succ(y)) | ~ quasinat(k)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
226  | 
apply (case_tac "k=0", simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
227  | 
apply (case_tac "\<exists>m. k = succ(m)")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
228  | 
apply (simp_all add: quasinat_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
229  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
230  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
231  | 
lemma nat_cases:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
232  | 
"[|k=0 ==> P; !!y. k = succ(y) ==> P; ~ quasinat(k) ==> P|] ==> P"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
233  | 
by (insert nat_cases_disj [of k], blast)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
234  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
235  | 
(** nat_case **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
236  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
237  | 
lemma nat_case_0 [simp]: "nat_case(a,b,0) = a"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
238  | 
by (simp add: nat_case_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
239  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
240  | 
lemma nat_case_succ [simp]: "nat_case(a,b,succ(n)) = b(n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
241  | 
by (simp add: nat_case_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
242  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
243  | 
lemma nat_case_type [TC]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
244  | 
"[| n: nat; a: C(0); !!m. m: nat ==> b(m): C(succ(m)) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
245  | 
==> nat_case(a,b,n) : C(n)";  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
246  | 
by (erule nat_induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
247  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
248  | 
lemma split_nat_case:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
249  | 
"P(nat_case(a,b,k)) <->  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
250  | 
((k=0 --> P(a)) & (\<forall>x. k=succ(x) --> P(b(x))) & (~ quasinat(k) \<longrightarrow> P(0)))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
251  | 
apply (rule nat_cases [of k])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
252  | 
apply (auto simp add: non_nat_case)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
253  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
254  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
255  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
256  | 
subsection{*Recursion on the Natural Numbers*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
257  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
258  | 
(** nat_rec is used to define eclose and transrec, then becomes obsolete.  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
259  | 
The operator rec, from arith.thy, has fewer typing conditions **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
260  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
261  | 
lemma nat_rec_0: "nat_rec(0,a,b) = a"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
262  | 
apply (rule nat_rec_def [THEN def_wfrec, THEN trans])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
263  | 
apply (rule wf_Memrel)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
264  | 
apply (rule nat_case_0)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
265  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
266  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
267  | 
lemma nat_rec_succ: "m: nat ==> nat_rec(succ(m),a,b) = b(m, nat_rec(m,a,b))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
268  | 
apply (rule nat_rec_def [THEN def_wfrec, THEN trans])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
269  | 
apply (rule wf_Memrel)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
270  | 
apply (simp add: vimage_singleton_iff)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
271  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
272  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
273  | 
(** The union of two natural numbers is a natural number -- their maximum **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
274  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
275  | 
lemma Un_nat_type [TC]: "[| i: nat; j: nat |] ==> i Un j: nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
276  | 
apply (rule Un_least_lt [THEN ltD])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
277  | 
apply (simp_all add: lt_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
278  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
279  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
280  | 
lemma Int_nat_type [TC]: "[| i: nat; j: nat |] ==> i Int j: nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
281  | 
apply (rule Int_greatest_lt [THEN ltD])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
282  | 
apply (simp_all add: lt_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
283  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
284  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
285  | 
(*needed to simplify unions over nat*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
286  | 
lemma nat_nonempty [simp]: "nat ~= 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
287  | 
by blast  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
288  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
289  | 
text{*A natural number is the set of its predecessors*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
290  | 
lemma nat_eq_Collect_lt: "i \<in> nat ==> {j\<in>nat. j<i} = i"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
291  | 
apply (rule equalityI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
292  | 
apply (blast dest: ltD)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
293  | 
apply (auto simp add: Ord_mem_iff_lt)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
294  | 
apply (blast intro: lt_trans)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
295  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
296  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
297  | 
lemma Le_iff [iff]: "<x,y> : Le <-> x le y & x : nat & y : nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
298  | 
by (force simp add: Le_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
299  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
300  | 
end  |