src/ZF/Nat.ML
author lcp
Tue, 26 Jul 1994 13:21:20 +0200
changeset 484 70b789956bd3
parent 435 ca5356bd315a
child 760 f0200e91b272
permissions -rw-r--r--
Axiom of choice, cardinality results, etc.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     1
(*  Title: 	ZF/nat.ML
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
For nat.thy.  Natural numbers in Zermelo-Fraenkel Set Theory 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
open Nat;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
goal Nat.thy "bnd_mono(Inf, %X. {0} Un {succ(i). i:X})";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
by (rtac bnd_monoI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
by (REPEAT (ares_tac [subset_refl, RepFun_mono, Un_mono] 2)); 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
by (cut_facts_tac [infinity] 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
by (fast_tac ZF_cs 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
val nat_bnd_mono = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
(* nat = {0} Un {succ(x). x:nat} *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
val nat_unfold = nat_bnd_mono RS (nat_def RS def_lfp_Tarski);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
(** Type checking of 0 and successor **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
goal Nat.thy "0 : nat";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
by (rtac (nat_unfold RS ssubst) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
by (rtac (singletonI RS UnI1) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
val nat_0I = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
val prems = goal Nat.thy "n : nat ==> succ(n) : nat";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
by (rtac (nat_unfold RS ssubst) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
by (rtac (RepFunI RS UnI2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
by (resolve_tac prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
val nat_succI = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
    34
goal Nat.thy "1 : nat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
by (rtac (nat_0I RS nat_succI) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
val nat_1I = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
goal Nat.thy "bool <= nat";
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 30
diff changeset
    39
by (REPEAT (ares_tac [subsetI,nat_0I,nat_1I] 1
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 30
diff changeset
    40
	    ORELSE eresolve_tac [boolE,ssubst] 1));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
val bool_subset_nat = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
val bool_into_nat = bool_subset_nat RS subsetD;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
(** Injectivity properties and induction **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
(*Mathematical induction*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
val major::prems = goal Nat.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
    "[| n: nat;  P(0);  !!x. [| x: nat;  P(x) |] ==> P(succ(x)) |] ==> P(n)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
by (rtac ([nat_def, nat_bnd_mono, major] MRS def_induct) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
by (fast_tac (ZF_cs addIs prems) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
val nat_induct = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
(*Perform induction on n, then prove the n:nat subgoal using prems. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
fun nat_ind_tac a prems i = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
    EVERY [res_inst_tac [("n",a)] nat_induct i,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
	   rename_last_tac a ["1"] (i+2),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
	   ares_tac prems i];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
val major::prems = goal Nat.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
    "[| 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
    63
by (rtac (major RS (nat_unfold RS equalityD1 RS subsetD) RS UnE) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
by (DEPTH_SOLVE (eresolve_tac [singletonE,RepFunE] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
          ORELSE ares_tac prems 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
val natE = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
val prems = goal Nat.thy "n: nat ==> Ord(n)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
by (nat_ind_tac "n" prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
by (REPEAT (ares_tac [Ord_0, Ord_succ] 1));
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    71
val nat_into_Ord = result();
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
    73
(* i: nat ==> 0 le i *)
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    74
val nat_0_le = nat_into_Ord RS Ord_0_le;
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    75
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    76
val 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
    77
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
goal Nat.thy "!!n. n: nat ==> n=0 | 0:n";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
by (etac nat_induct 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
by (fast_tac ZF_cs 1);
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
    81
by (fast_tac (ZF_cs addIs [nat_0_le]) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
val natE0 = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
goal Nat.thy "Ord(nat)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
by (rtac OrdI 1);
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    86
by (etac (nat_into_Ord RS Ord_is_Transset) 2);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
by (rewtac Transset_def);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
by (rtac ballI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
by (etac nat_induct 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
by (REPEAT (ares_tac [empty_subsetI,succ_subsetI] 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
val Ord_nat = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    93
goalw Nat.thy [Limit_def] "Limit(nat)";
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    94
by (safe_tac (ZF_cs addSIs [ltI, nat_0I, nat_1I, nat_succI, Ord_nat]));
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    95
by (etac ltD 1);
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    96
val Limit_nat = result();
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
    97
484
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
    98
goal Nat.thy "!!i. Limit(i) ==> nat le i";
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
    99
by (resolve_tac [subset_imp_le] 1);
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   100
by (rtac subsetI 1);
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   101
by (eresolve_tac [nat_induct] 1);
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   102
by (fast_tac (ZF_cs addIs [Limit_has_succ RS ltD, ltI, Limit_is_Ord]) 2);
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   103
by (REPEAT (ares_tac [Limit_has_0 RS ltD,
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   104
		      Ord_nat, Limit_is_Ord] 1));
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   105
val nat_le_Limit = result();
70b789956bd3 Axiom of choice, cardinality results, etc.
lcp
parents: 435
diff changeset
   106
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   107
(* succ(i): nat ==> i: nat *)
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   108
val succ_natD = [succI1, asm_rl, Ord_nat] MRS Ord_trans;
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   109
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   110
(* [| succ(i): k;  k: nat |] ==> i: k *)
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 120
diff changeset
   111
val 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
   112
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   113
goal Nat.thy "!!m n. [| m<n;  n: nat |] ==> m: nat";
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   114
by (etac ltE 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   115
by (etac (Ord_nat RSN (3,Ord_trans)) 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   116
by (assume_tac 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   117
val lt_nat_in_nat = result();
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   118
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   119
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
(** Variations on mathematical induction **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
(*complete induction*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
val complete_induct = Ord_nat RSN (2, Ord_induct);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
val prems = goal Nat.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
    "[| m: nat;  n: nat;  \
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   127
\       !!x. [| x: nat;  m le x;  P(x) |] ==> P(succ(x)) \
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   128
\    |] ==> m le n --> P(m) --> P(n)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
by (nat_ind_tac "n" prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
by (ALLGOALS
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   131
    (asm_simp_tac
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   132
     (ZF_ss addsimps (prems@distrib_rews@[le0_iff, le_succ_iff]))));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
val nat_induct_from_lemma = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
(*Induction starting from m rather than 0*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
val prems = goal Nat.thy
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   137
    "[| m le n;  m: nat;  n: nat;  \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
\       P(m);  \
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   139
\       !!x. [| x: nat;  m le x;  P(x) |] ==> P(succ(x)) \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
\    |] ==> P(n)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
by (rtac (nat_induct_from_lemma RS mp RS mp) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
by (REPEAT (ares_tac prems 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   143
val nat_induct_from = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
(*Induction suitable for subtraction and less-than*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
val prems = goal Nat.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
    "[| m: nat;  n: nat;  \
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   148
\       !!x. x: nat ==> P(x,0);  \
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   149
\       !!y. y: nat ==> P(0,succ(y));  \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
\       !!x y. [| x: nat;  y: nat;  P(x,y) |] ==> P(succ(x),succ(y))  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
\    |] ==> P(m,n)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
by (res_inst_tac [("x","m")] bspec 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
by (resolve_tac prems 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
by (nat_ind_tac "n" prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
by (rtac ballI 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
by (nat_ind_tac "x" [] 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   157
by (REPEAT (ares_tac (prems@[ballI]) 1 ORELSE etac bspec 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
val diff_induct = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   160
(** 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
   161
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   162
goal Nat.thy
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   163
 "!!m. 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
   164
\                 (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
   165
by (etac nat_induct 1);
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   166
by (ALLGOALS
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   167
    (EVERY' [rtac (impI RS impI), rtac (nat_induct RS ballI), assume_tac,
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   168
	     fast_tac lt_cs, fast_tac lt_cs]));
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   169
val succ_lt_induct_lemma = result();
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   170
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   171
val prems = goal Nat.thy
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   172
    "[| m<n;  n: nat;  					\
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   173
\       P(m,succ(m));  					\
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   174
\       !!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
   175
\    |] ==> P(m,n)";
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   176
by (res_inst_tac [("P4","P")] 
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   177
     (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
   178
by (REPEAT (ares_tac (prems @ [ballI, impI, lt_nat_in_nat]) 1));
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   179
val succ_lt_induct = result();
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   180
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   181
(** nat_case **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   183
goalw Nat.thy [nat_case_def] "nat_case(a,b,0) = a";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
by (fast_tac (ZF_cs addIs [the_equality]) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   185
val nat_case_0 = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   186
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   187
goalw Nat.thy [nat_case_def] "nat_case(a,b,succ(m)) = b(m)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   188
by (fast_tac (ZF_cs addIs [the_equality]) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   189
val nat_case_succ = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   190
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
val major::prems = goal Nat.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
    "[| 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
   193
\    |] ==> nat_case(a,b,n) : C(n)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
by (rtac (major RS nat_induct) 1);
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   195
by (ALLGOALS 
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   196
    (asm_simp_tac (ZF_ss addsimps (prems @ [nat_case_0, nat_case_succ]))));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
val nat_case_type = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   199
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   200
(** nat_rec -- used to define eclose and transrec, then obsolete;
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   201
    rec, from arith.ML, has fewer typing conditions **)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
val nat_rec_trans = wf_Memrel RS (nat_rec_def RS def_wfrec RS trans);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
goal Nat.thy "nat_rec(0,a,b) = a";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
by (rtac nat_rec_trans 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
by (rtac nat_case_0 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   208
val nat_rec_0 = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
val [prem] = goal Nat.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
    "m: nat ==> nat_rec(succ(m),a,b) = b(m, nat_rec(m,a,b))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
by (rtac nat_rec_trans 1);
15
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   213
by (simp_tac (ZF_ss addsimps [prem, nat_case_succ, nat_succI, Memrel_iff, 
6c6d2f6e3185 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
   214
			      vimage_singleton_iff]) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
val nat_rec_succ = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
(** The union of two natural numbers is a natural number -- their maximum **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   219
goal Nat.thy "!!i j. [| i: nat; j: nat |] ==> i Un j: nat";
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   220
by (rtac (Un_least_lt RS ltD) 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   221
by (REPEAT (ares_tac [ltI, Ord_nat] 1));
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   222
val Un_nat_type = result();
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
30
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   224
goal Nat.thy "!!i j. [| i: nat; j: nat |] ==> i Int j: nat";
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   225
by (rtac (Int_greatest_lt RS ltD) 1);
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   226
by (REPEAT (ares_tac [ltI, Ord_nat] 1));
d49df4181f0d Retrying yet again after network problems
lcp
parents: 15
diff changeset
   227
val Int_nat_type = result();