src/ZF/Nat.ML
author wenzelm
Tue, 16 Oct 2001 00:32:01 +0200
changeset 11790 42393a11642d
parent 10216 e928bdf62014
child 12552 d2d2ab3f1f37
permissions -rw-r--r--
simplified resolveq_cases_tac for cases, separate version for induct; divinate instantiation of induct rules; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9492
72e429c66608 used natify with div and mod; also put in the divide-by-zero trick
paulson
parents: 9180
diff changeset
     1
(*  Title:      ZF/Nat.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 829
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
5505
paulson
parents: 5479
diff changeset
     6
Natural numbers in Zermelo-Fraenkel Set Theory 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
     9
Goal "bnd_mono(Inf, %X. {0} Un {succ(i). i:X})";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
by (rtac bnd_monoI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
by (REPEAT (ares_tac [subset_refl, RepFun_mono, Un_mono] 2)); 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
by (cut_facts_tac [infinity] 1);
4243
d7b8dd960514 Speeded up the proof of succ_lt_induct_lemma
paulson
parents: 4091
diff changeset
    13
by (Blast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    14
qed "nat_bnd_mono";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
(* nat = {0} Un {succ(x). x:nat} *)
10216
e928bdf62014 renamed fp_Tarski to fp_unfold
paulson
parents: 9907
diff changeset
    17
bind_thm ("nat_unfold", nat_bnd_mono RS (nat_def RS def_lfp_unfold));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
(** Type checking of 0 and successor **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
    21
Goal "0 : nat";
2033
639de962ded4 Ran expandshort; used stac instead of ssubst
paulson
parents: 1956
diff changeset
    22
by (stac nat_unfold 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
by (rtac (singletonI RS UnI1) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    24
qed "nat_0I";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
    26
Goal "n : nat ==> succ(n) : nat";
2033
639de962ded4 Ran expandshort; used stac instead of ssubst
paulson
parents: 1956
diff changeset
    27
by (stac nat_unfold 1);
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
    28
by (etac (RepFunI RS UnI2) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    29
qed "nat_succI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
    31
Goal "1 : nat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
by (rtac (nat_0I RS nat_succI) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    33
qed "nat_1I";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
    35
Goal "2 : nat";
829
ba28811c3496 natE0: deleted, since unused
lcp
parents: 760
diff changeset
    36
by (rtac (nat_1I RS nat_succI) 1);
ba28811c3496 natE0: deleted, since unused
lcp
parents: 760
diff changeset
    37
qed "nat_2I";
ba28811c3496 natE0: deleted, since unused
lcp
parents: 760
diff changeset
    38
9492
72e429c66608 used natify with div and mod; also put in the divide-by-zero trick
paulson
parents: 9180
diff changeset
    39
AddIffs [nat_0I, nat_1I, nat_2I];
72e429c66608 used natify with div and mod; also put in the divide-by-zero trick
paulson
parents: 9180
diff changeset
    40
AddSIs  [nat_succI];
72e429c66608 used natify with div and mod; also put in the divide-by-zero trick
paulson
parents: 9180
diff changeset
    41
AddTCs  [nat_0I, nat_1I, nat_2I, nat_succI];
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    42
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
    43
Goal "bool <= nat";
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6070
diff changeset
    44
by (blast_tac (claset() addSEs [boolE]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    45
qed "bool_subset_nat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
9907
473a6604da94 tuned ML code (the_context, bind_thms(s));
wenzelm
parents: 9842
diff changeset
    47
bind_thm ("bool_into_nat", bool_subset_nat RS subsetD);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
(** Injectivity properties and induction **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
(*Mathematical induction*)
9180
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
    53
val major::prems = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
    "[| n: nat;  P(0);  !!x. [| x: nat;  P(x) |] ==> P(succ(x)) |] ==> P(n)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
by (rtac ([nat_def, nat_bnd_mono, major] MRS def_induct) 1);
4243
d7b8dd960514 Speeded up the proof of succ_lt_induct_lemma
paulson
parents: 4091
diff changeset
    56
by (blast_tac (claset() addIs prems) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    57
qed "nat_induct";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
(*Perform induction on n, then prove the n:nat subgoal using prems. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
fun nat_ind_tac a prems i = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
    EVERY [res_inst_tac [("n",a)] nat_induct i,
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 829
diff changeset
    62
           rename_last_tac a ["1"] (i+2),
6bcb44e4d6e5 expanded tabs
clasohm
parents: 829
diff changeset
    63
           ares_tac prems i];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
9180
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
    65
val major::prems = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
    "[| n: nat;  n=0 ==> P;  !!x. [| x: nat; n=succ(x) |] ==> P |] ==> P";
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
    67
by (rtac (major RS (nat_unfold RS equalityD1 RS subsetD) RS UnE) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
by (DEPTH_SOLVE (eresolve_tac [singletonE,RepFunE] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
          ORELSE ares_tac prems 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    70
qed "natE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
9180
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
    72
Goal "n: nat ==> Ord(n)";
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
    73
by (nat_ind_tac "n" [] 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
by (REPEAT (ares_tac [Ord_0, Ord_succ] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    75
qed "nat_into_Ord";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
8127
68c6159440f1 new lemmas for Ntree recursor example; more simprules; more lemmas borrowed
paulson
parents: 6153
diff changeset
    77
Addsimps [nat_into_Ord];
68c6159440f1 new lemmas for Ntree recursor example; more simprules; more lemmas borrowed
paulson
parents: 6153
diff changeset
    78
1610
60ab5844fe81 Updated comments
paulson
parents: 1461
diff changeset
    79
(* i: nat ==> 0 le i; same thing as 0<succ(i)  *)
60ab5844fe81 Updated comments
paulson
parents: 1461
diff changeset
    80
bind_thm ("nat_0_le", nat_into_Ord RS Ord_0_le);
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    81
1610
60ab5844fe81 Updated comments
paulson
parents: 1461
diff changeset
    82
(* i: nat ==> i le i; same thing as i<succ(i)  *)
60ab5844fe81 Updated comments
paulson
parents: 1461
diff changeset
    83
bind_thm ("nat_le_refl", nat_into_Ord RS le_refl);
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
    84
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
    85
Goal "Ord(nat)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
by (rtac OrdI 1);
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    87
by (etac (nat_into_Ord RS Ord_is_Transset) 2);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
by (rewtac Transset_def);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
by (rtac ballI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
by (etac nat_induct 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
by (REPEAT (ares_tac [empty_subsetI,succ_subsetI] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    92
qed "Ord_nat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
    94
Goalw [Limit_def] "Limit(nat)";
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
    95
by (safe_tac (claset() addSIs [ltI, Ord_nat]));
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    96
by (etac ltD 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
    97
qed "Limit_nat";
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    98
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
    99
(* succ(i): nat ==> i: nat *)
9907
473a6604da94 tuned ML code (the_context, bind_thms(s));
wenzelm
parents: 9842
diff changeset
   100
bind_thm ("succ_natD", [succI1, asm_rl, Ord_nat] MRS Ord_trans);
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   101
AddSDs   [succ_natD];
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   102
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   103
Goal "succ(n): nat <-> n: nat";
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   104
by (Blast_tac 1);
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   105
qed "nat_succ_iff";
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   106
9492
72e429c66608 used natify with div and mod; also put in the divide-by-zero trick
paulson
parents: 9180
diff changeset
   107
AddIffs [Ord_nat, Limit_nat, nat_succ_iff];
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   108
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   109
Goal "Limit(i) ==> nat le i";
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 829
diff changeset
   110
by (rtac subset_imp_le 1);
484
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   111
by (rtac subsetI 1);
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 829
diff changeset
   112
by (etac nat_induct 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2929
diff changeset
   113
by (blast_tac (claset() addIs [Limit_has_succ RS ltD, ltI, Limit_is_Ord]) 2);
9492
72e429c66608 used natify with div and mod; also put in the divide-by-zero trick
paulson
parents: 9180
diff changeset
   114
by (REPEAT (ares_tac [Limit_has_0 RS ltD, Ord_nat, Limit_is_Ord] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   115
qed "nat_le_Limit";
484
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   116
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   117
(* [| succ(i): k;  k: nat |] ==> i: k *)
9907
473a6604da94 tuned ML code (the_context, bind_thms(s));
wenzelm
parents: 9842
diff changeset
   118
bind_thm ("succ_in_naturalD", [succI1, asm_rl, nat_into_Ord] MRS Ord_trans);
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   119
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   120
Goal "[| m<n;  n: nat |] ==> m: nat";
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   121
by (etac ltE 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   122
by (etac (Ord_nat RSN (3,Ord_trans)) 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   123
by (assume_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   124
qed "lt_nat_in_nat";
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   125
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5147
diff changeset
   126
Goal "[| m le n; n:nat |] ==> m:nat";
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5147
diff changeset
   127
by (blast_tac (claset() addSDs [lt_nat_in_nat]) 1);
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5147
diff changeset
   128
qed "le_in_nat";
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5147
diff changeset
   129
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   130
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
(** Variations on mathematical induction **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
(*complete induction*)
9907
473a6604da94 tuned ML code (the_context, bind_thms(s));
wenzelm
parents: 9842
diff changeset
   134
bind_thm ("complete_induct", Ord_nat RSN (2, Ord_induct));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
9180
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
   136
val prems = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
    "[| m: nat;  n: nat;  \
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   138
\       !!x. [| x: nat;  m le x;  P(x) |] ==> P(succ(x)) \
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   139
\    |] ==> m le n --> P(m) --> P(n)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
by (nat_ind_tac "n" prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
by (ALLGOALS
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   142
    (asm_simp_tac
5529
4a54acae6a15 tidying
paulson
parents: 5505
diff changeset
   143
     (simpset() addsimps prems @ distrib_simps @ [le0_iff, le_succ_iff])));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   144
qed "nat_induct_from_lemma";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
(*Induction starting from m rather than 0*)
9180
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
   147
val prems = Goal
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   148
    "[| m le n;  m: nat;  n: nat;  \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
\       P(m);  \
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   150
\       !!x. [| x: nat;  m le x;  P(x) |] ==> P(succ(x)) \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
\    |] ==> P(n)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
by (rtac (nat_induct_from_lemma RS mp RS mp) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
by (REPEAT (ares_tac prems 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   154
qed "nat_induct_from";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
(*Induction suitable for subtraction and less-than*)
9180
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
   157
val prems = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
    "[| m: nat;  n: nat;  \
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   159
\       !!x. x: nat ==> P(x,0);  \
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   160
\       !!y. y: nat ==> P(0,succ(y));  \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   161
\       !!x y. [| x: nat;  y: nat;  P(x,y) |] ==> P(succ(x),succ(y))  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
\    |] ==> P(m,n)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
by (res_inst_tac [("x","m")] bspec 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   164
by (resolve_tac prems 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
by (nat_ind_tac "n" prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
by (rtac ballI 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
by (nat_ind_tac "x" [] 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
by (REPEAT (ares_tac (prems@[ballI]) 1 ORELSE etac bspec 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   169
qed "diff_induct";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   171
(** Induction principle analogous to trancl_induct **)
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   172
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   173
Goal "m: nat ==> P(m,succ(m)) --> (ALL x: nat. P(m,x) --> P(m,succ(x))) --> \
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   174
\                 (ALL n:nat. m<n --> P(m,n))";
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   175
by (etac nat_induct 1);
5479
5a5dfb0f0d7d fixed PROOF FAILED
paulson
parents: 5325
diff changeset
   176
by (ALLGOALS   
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   177
    (EVERY' [rtac (impI RS impI), rtac (nat_induct RS ballI), assume_tac,
5479
5a5dfb0f0d7d fixed PROOF FAILED
paulson
parents: 5325
diff changeset
   178
             blast_tac le_cs, blast_tac le_cs])); 
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   179
qed "succ_lt_induct_lemma";
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   180
9180
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
   181
val prems = Goal
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 829
diff changeset
   182
    "[| m<n;  n: nat;                                   \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 829
diff changeset
   183
\       P(m,succ(m));                                   \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 829
diff changeset
   184
\       !!x. [| x: nat;  P(m,x) |] ==> P(m,succ(x))     \
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   185
\    |] ==> P(m,n)";
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   186
by (res_inst_tac [("P4","P")] 
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   187
     (succ_lt_induct_lemma RS mp RS mp RS bspec RS mp) 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   188
by (REPEAT (ares_tac (prems @ [ballI, impI, lt_nat_in_nat]) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   189
qed "succ_lt_induct";
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   190
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
(** nat_case **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
   193
Goalw [nat_case_def] "nat_case(a,b,0) = a";
5505
paulson
parents: 5479
diff changeset
   194
by (Blast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   195
qed "nat_case_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
   197
Goalw [nat_case_def] "nat_case(a,b,succ(m)) = b(m)";
5505
paulson
parents: 5479
diff changeset
   198
by (Blast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   199
qed "nat_case_succ";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   201
Addsimps [nat_case_0, nat_case_succ];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   202
9180
3bda56c0d70d tidying and unbatchifying
paulson
parents: 8127
diff changeset
   203
val major::prems = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
    "[| n: nat;  a: C(0);  !!m. m: nat ==> b(m): C(succ(m))  \
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   205
\    |] ==> nat_case(a,b,n) : C(n)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
by (rtac (major RS nat_induct) 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2929
diff changeset
   207
by (ALLGOALS (asm_simp_tac (simpset() addsimps prems)));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   208
qed "nat_case_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   211
(** nat_rec -- used to define eclose and transrec, then obsolete;
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   212
    rec, from arith.ML, has fewer typing conditions **)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 5529
diff changeset
   214
val lemma = wf_Memrel RS (nat_rec_def RS def_wfrec RS trans);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4243
diff changeset
   216
Goal "nat_rec(0,a,b) = a";
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 5529
diff changeset
   217
by (rtac lemma 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
by (rtac nat_case_0 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   219
qed "nat_rec_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 5529
diff changeset
   221
Goal "m: nat ==> nat_rec(succ(m),a,b) = b(m, nat_rec(m,a,b))";
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 5529
diff changeset
   222
by (rtac lemma 1);
9842
58d8335cc40c new AddIffs (especially Memrel_iff)
paulson
parents: 9492
diff changeset
   223
by (asm_simp_tac (simpset() addsimps [vimage_singleton_iff]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   224
qed "nat_rec_succ";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
(** The union of two natural numbers is a natural number -- their maximum **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   227
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   228
Goal "[| i: nat; j: nat |] ==> i Un j: nat";
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   229
by (rtac (Un_least_lt RS ltD) 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   230
by (REPEAT (ares_tac [ltI, Ord_nat] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   231
qed "Un_nat_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   233
Goal "[| i: nat; j: nat |] ==> i Int j: nat";
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   234
by (rtac (Int_greatest_lt RS ltD) 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   235
by (REPEAT (ares_tac [ltI, Ord_nat] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 484
diff changeset
   236
qed "Int_nat_type";