src/HOL/Nat.ML
author clasohm
Tue, 30 Jan 1996 15:24:36 +0100
changeset 1465 5d7a7e439cec
parent 1327 6c29cfab679c
child 1475 7f5a4cd08209
permissions -rw-r--r--
expanded tabs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
     1
(*  Title:      HOL/nat
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
For nat.thy.  Type nat is defined as a set (Nat) over the type ind.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
open Nat;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
goal Nat.thy "mono(%X. {Zero_Rep} Un (Suc_Rep``X))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
by (REPEAT (ares_tac [monoI, subset_refl, image_mono, Un_mono] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
qed "Nat_fun_mono";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
val Nat_unfold = Nat_fun_mono RS (Nat_def RS def_lfp_Tarski);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
(* Zero is a natural number -- this also justifies the type definition*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
goal Nat.thy "Zero_Rep: Nat";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
by (rtac (Nat_unfold RS ssubst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
by (rtac (singletonI RS UnI1) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
qed "Zero_RepI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
val prems = goal Nat.thy "i: Nat ==> Suc_Rep(i) : Nat";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
by (rtac (Nat_unfold RS ssubst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
by (rtac (imageI RS UnI2) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
qed "Suc_RepI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
(*** Induction ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
val major::prems = goal Nat.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
    "[| i: Nat;  P(Zero_Rep);   \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
\       !!j. [| j: Nat; P(j) |] ==> P(Suc_Rep(j)) |]  ==> P(i)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
by (rtac ([Nat_def, Nat_fun_mono, major] MRS def_induct) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
by (fast_tac (set_cs addIs prems) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
qed "Nat_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
val prems = goalw Nat.thy [Zero_def,Suc_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
    "[| P(0);   \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
\       !!k. P(k) ==> P(Suc(k)) |]  ==> P(n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
by (rtac (Rep_Nat_inverse RS subst) 1);   (*types force good instantiation*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
by (rtac (Rep_Nat RS Nat_induct) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
by (REPEAT (ares_tac prems 1
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
     ORELSE eresolve_tac [Abs_Nat_inverse RS subst] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
qed "nat_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
(*Perform induction on n. *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
fun nat_ind_tac a i = 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
    EVERY [res_inst_tac [("n",a)] nat_induct i,
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
    50
           rename_last_tac a ["1"] (i+1)];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
(*A special form of induction for reasoning about m<n and m-n*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
val prems = goal Nat.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
    "[| !!x. P x 0;  \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
\       !!y. P 0 (Suc y);  \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
\       !!x y. [| P x y |] ==> P (Suc x) (Suc y)  \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
\    |] ==> P m n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
by (res_inst_tac [("x","m")] spec 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
by (rtac allI 2);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
by (nat_ind_tac "x" 2);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
by (REPEAT (ares_tac (prems@[allI]) 1 ORELSE etac spec 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
qed "diff_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
(*Case analysis on the natural numbers*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
val prems = goal Nat.thy 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
    "[| n=0 ==> P;  !!x. n = Suc(x) ==> P |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
by (subgoal_tac "n=0 | (EX x. n = Suc(x))" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
by (fast_tac (HOL_cs addSEs prems) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
by (rtac (refl RS disjI1) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
by (fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
qed "natE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
(*** Isomorphisms: Abs_Nat and Rep_Nat ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
(*We can't take these properties as axioms, or take Abs_Nat==Inv(Rep_Nat),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
  since we assume the isomorphism equations will one day be given by Isabelle*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
goal Nat.thy "inj(Rep_Nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
by (rtac inj_inverseI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
by (rtac Rep_Nat_inverse 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
qed "inj_Rep_Nat";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
goal Nat.thy "inj_onto Abs_Nat Nat";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
by (rtac inj_onto_inverseI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
by (etac Abs_Nat_inverse 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
qed "inj_onto_Abs_Nat";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
(*** Distinctness of constructors ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
goalw Nat.thy [Zero_def,Suc_def] "Suc(m) ~= 0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
by (rtac (inj_onto_Abs_Nat RS inj_onto_contraD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
by (rtac Suc_Rep_not_Zero_Rep 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
by (REPEAT (resolve_tac [Rep_Nat, Suc_RepI, Zero_RepI] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
qed "Suc_not_Zero";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
bind_thm ("Zero_not_Suc", (Suc_not_Zero RS not_sym));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   100
Addsimps [Suc_not_Zero,Zero_not_Suc];
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   101
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
bind_thm ("Suc_neq_Zero", (Suc_not_Zero RS notE));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
val Zero_neq_Suc = sym RS Suc_neq_Zero;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
(** Injectiveness of Suc **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
goalw Nat.thy [Suc_def] "inj(Suc)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
by (rtac injI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
by (dtac (inj_onto_Abs_Nat RS inj_ontoD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
by (REPEAT (resolve_tac [Rep_Nat, Suc_RepI] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
by (dtac (inj_Suc_Rep RS injD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
by (etac (inj_Rep_Nat RS injD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
qed "inj_Suc";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   115
val Suc_inject = inj_Suc RS injD;
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   116
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
goal Nat.thy "(Suc(m)=Suc(n)) = (m=n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
by (EVERY1 [rtac iffI, etac Suc_inject, etac arg_cong]); 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
qed "Suc_Suc_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
goal Nat.thy "n ~= Suc(n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
by (nat_ind_tac "n" 1);
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   123
by (ALLGOALS(asm_simp_tac (!simpset addsimps [Suc_Suc_eq])));
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   124
qed "n_not_Suc_n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
val Suc_n_not_n = n_not_Suc_n RS not_sym;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   127
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
(*** nat_case -- the selection operator for nat ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
goalw Nat.thy [nat_case_def] "nat_case a f 0 = a";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
by (fast_tac (set_cs addIs [select_equality] addEs [Zero_neq_Suc]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
qed "nat_case_0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
goalw Nat.thy [nat_case_def] "nat_case a f (Suc k) = f(k)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
by (fast_tac (set_cs addIs [select_equality] 
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
   136
                       addEs [make_elim Suc_inject, Suc_neq_Zero]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
qed "nat_case_Suc";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
(** Introduction rules for 'pred_nat' **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 962
diff changeset
   141
goalw Nat.thy [pred_nat_def] "(n, Suc(n)) : pred_nat";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
by (fast_tac set_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   143
qed "pred_natI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
val major::prems = goalw Nat.thy [pred_nat_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 962
diff changeset
   146
    "[| p : pred_nat;  !!x n. [| p = (n, Suc(n)) |] ==> R \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   147
\    |] ==> R";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
by (rtac (major RS CollectE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   149
by (REPEAT (eresolve_tac ([asm_rl,exE]@prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
qed "pred_natE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
goalw Nat.thy [wf_def] "wf(pred_nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
by (strip_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
by (nat_ind_tac "x" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   155
by (fast_tac (HOL_cs addSEs [mp, pred_natE, Pair_inject, 
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
   156
                             make_elim Suc_inject]) 2);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   157
by (fast_tac (HOL_cs addSEs [mp, pred_natE, Pair_inject, Zero_neq_Suc]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   158
qed "wf_pred_nat";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   159
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   160
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   161
(*** nat_rec -- by wf recursion on pred_nat ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   162
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   163
bind_thm ("nat_rec_unfold", (wf_pred_nat RS (nat_rec_def RS def_wfrec)));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   164
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   165
(** conversion rules **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   166
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   167
goal Nat.thy "nat_rec 0 c h = c";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   168
by (rtac (nat_rec_unfold RS trans) 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   169
by (simp_tac (!simpset addsimps [nat_case_0]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   170
qed "nat_rec_0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   171
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   172
goal Nat.thy "nat_rec (Suc n) c h = h n (nat_rec n c h)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   173
by (rtac (nat_rec_unfold RS trans) 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   174
by (simp_tac (!simpset addsimps [nat_case_Suc, pred_natI, cut_apply]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   175
qed "nat_rec_Suc";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   176
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   177
(*These 2 rules ease the use of primitive recursion.  NOTE USE OF == *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   178
val [rew] = goal Nat.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   179
    "[| !!n. f(n) == nat_rec n c h |] ==> f(0) = c";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   180
by (rewtac rew);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
by (rtac nat_rec_0 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
qed "def_nat_rec_0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
val [rew] = goal Nat.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   185
    "[| !!n. f(n) == nat_rec n c h |] ==> f(Suc(n)) = h n (f n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   186
by (rewtac rew);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   187
by (rtac nat_rec_Suc 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
qed "def_nat_rec_Suc";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   190
fun nat_recs def =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   191
      [standard (def RS def_nat_rec_0),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   192
       standard (def RS def_nat_rec_Suc)];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   193
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   194
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   195
(*** Basic properties of "less than" ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   196
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   197
(** Introduction properties **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   198
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   199
val prems = goalw Nat.thy [less_def] "[| i<j;  j<k |] ==> i<(k::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   200
by (rtac (trans_trancl RS transD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   201
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   202
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   203
qed "less_trans";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   204
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   205
goalw Nat.thy [less_def] "n < Suc(n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   206
by (rtac (pred_natI RS r_into_trancl) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   207
qed "lessI";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   208
Addsimps [lessI];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   209
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 962
diff changeset
   210
(* i(j ==> i(Suc(j) *)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   211
val less_SucI = lessI RSN (2, less_trans);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   212
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   213
goal Nat.thy "0 < Suc(n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   214
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   215
by (rtac lessI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   216
by (etac less_trans 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   217
by (rtac lessI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   218
qed "zero_less_Suc";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   219
Addsimps [zero_less_Suc];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   220
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   221
(** Elimination properties **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   222
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   223
val prems = goalw Nat.thy [less_def] "n<m ==> ~ m<(n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   224
by(fast_tac (HOL_cs addIs ([wf_pred_nat, wf_trancl RS wf_asym]@prems))1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   225
qed "less_not_sym";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   226
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 962
diff changeset
   227
(* [| n(m; m(n |] ==> R *)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   228
bind_thm ("less_asym", (less_not_sym RS notE));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   229
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   230
goalw Nat.thy [less_def] "~ n<(n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   231
by (rtac notI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   232
by (etac (wf_pred_nat RS wf_trancl RS wf_anti_refl) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   233
qed "less_not_refl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   234
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 962
diff changeset
   235
(* n(n ==> R *)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   236
bind_thm ("less_anti_refl", (less_not_refl RS notE));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   237
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   238
goal Nat.thy "!!m. n<m ==> m ~= (n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   239
by(fast_tac (HOL_cs addEs [less_anti_refl]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   240
qed "less_not_refl2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   241
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   242
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   243
val major::prems = goalw Nat.thy [less_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   244
    "[| i<k;  k=Suc(i) ==> P;  !!j. [| i<j;  k=Suc(j) |] ==> P \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   245
\    |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   246
by (rtac (major RS tranclE) 1);
1024
b86042000035 ROOT.ML: installed new hyp_subst_tac
nipkow
parents: 972
diff changeset
   247
by (REPEAT_FIRST (bound_hyp_subst_tac ORELSE'
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
   248
                  eresolve_tac (prems@[pred_natE, Pair_inject])));
1024
b86042000035 ROOT.ML: installed new hyp_subst_tac
nipkow
parents: 972
diff changeset
   249
by (rtac refl 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   250
qed "lessE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   251
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   252
goal Nat.thy "~ n<0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   253
by (rtac notI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   254
by (etac lessE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   255
by (etac Zero_neq_Suc 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   256
by (etac Zero_neq_Suc 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   257
qed "not_less0";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   258
Addsimps [not_less0];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   259
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   260
(* n<0 ==> R *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   261
bind_thm ("less_zeroE", (not_less0 RS notE));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   262
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   263
val [major,less,eq] = goal Nat.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   264
    "[| m < Suc(n);  m<n ==> P;  m=n ==> P |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   265
by (rtac (major RS lessE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   266
by (rtac eq 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   267
by (fast_tac (HOL_cs addSDs [Suc_inject]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   268
by (rtac less 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   269
by (fast_tac (HOL_cs addSDs [Suc_inject]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   270
qed "less_SucE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   271
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   272
goal Nat.thy "(m < Suc(n)) = (m < n | m = n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   273
by (fast_tac (HOL_cs addSIs [lessI]
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
   274
                     addEs  [less_trans, less_SucE]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   275
qed "less_Suc_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   276
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   277
val prems = goal Nat.thy "m<n ==> n ~= 0";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   278
by(res_inst_tac [("n","n")] natE 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   279
by(cut_facts_tac prems 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   280
by(ALLGOALS Asm_full_simp_tac);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   281
qed "gr_implies_not0";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   282
Addsimps [gr_implies_not0];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   283
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   284
(** Inductive (?) properties **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   285
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   286
val [prem] = goal Nat.thy "Suc(m) < n ==> m<n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   287
by (rtac (prem RS rev_mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   288
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   289
by (rtac impI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   290
by (etac less_zeroE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   291
by (fast_tac (HOL_cs addSIs [lessI RS less_SucI]
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
   292
                     addSDs [Suc_inject]
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
   293
                     addEs  [less_trans, lessE]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   294
qed "Suc_lessD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   295
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   296
val [major,minor] = goal Nat.thy 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   297
    "[| Suc(i)<k;  !!j. [| i<j;  k=Suc(j) |] ==> P \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   298
\    |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   299
by (rtac (major RS lessE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   300
by (etac (lessI RS minor) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   301
by (etac (Suc_lessD RS minor) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   302
by (assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   303
qed "Suc_lessE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   304
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   305
val [major] = goal Nat.thy "Suc(m) < Suc(n) ==> m<n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   306
by (rtac (major RS lessE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   307
by (REPEAT (rtac lessI 1
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   308
     ORELSE eresolve_tac [make_elim Suc_inject, ssubst, Suc_lessD] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   309
qed "Suc_less_SucD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   310
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   311
val prems = goal Nat.thy "m<n ==> Suc(m) < Suc(n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   312
by (subgoal_tac "m<n --> Suc(m) < Suc(n)" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   313
by (fast_tac (HOL_cs addIs prems) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   314
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   315
by (rtac impI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   316
by (etac less_zeroE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   317
by (fast_tac (HOL_cs addSIs [lessI]
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
   318
                     addSDs [Suc_inject]
5d7a7e439cec expanded tabs
clasohm
parents: 1327
diff changeset
   319
                     addEs  [less_trans, lessE]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   320
qed "Suc_mono";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   321
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   322
goal Nat.thy "(Suc(m) < Suc(n)) = (m<n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   323
by (EVERY1 [rtac iffI, etac Suc_less_SucD, etac Suc_mono]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   324
qed "Suc_less_eq";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   325
Addsimps [Suc_less_eq];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   326
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   327
goal Nat.thy "~(Suc(n) < n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   328
by(fast_tac (HOL_cs addEs [Suc_lessD RS less_anti_refl]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   329
qed "not_Suc_n_less_n";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   330
Addsimps [not_Suc_n_less_n];
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   331
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   332
goal Nat.thy "!!i. i<j ==> j<k --> Suc i < k";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   333
by(nat_ind_tac "k" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   334
by(ALLGOALS (asm_simp_tac (!simpset addsimps [less_Suc_eq])));
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   335
by(fast_tac (HOL_cs addDs [Suc_lessD]) 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   336
bind_thm("less_trans_Suc",result() RS mp);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   337
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   338
(*"Less than" is a linear ordering*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   339
goal Nat.thy "m<n | m=n | n<(m::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   340
by (nat_ind_tac "m" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   341
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   342
by (rtac (refl RS disjI1 RS disjI2) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   343
by (rtac (zero_less_Suc RS disjI1) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   344
by (fast_tac (HOL_cs addIs [lessI, Suc_mono, less_SucI] addEs [lessE]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   345
qed "less_linear";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   346
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   347
(*Can be used with less_Suc_eq to get n=m | n<m *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   348
goal Nat.thy "(~ m < n) = (n < Suc(m))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   349
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   350
by(ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   351
qed "not_less_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   352
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   353
(*Complete induction, aka course-of-values induction*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   354
val prems = goalw Nat.thy [less_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   355
    "[| !!n. [| ! m::nat. m<n --> P(m) |] ==> P(n) |]  ==>  P(n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   356
by (wf_ind_tac "n" [wf_pred_nat RS wf_trancl] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   357
by (eresolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   358
qed "less_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   359
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   360
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   361
(*** Properties of <= ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   362
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   363
goalw Nat.thy [le_def] "0 <= n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   364
by (rtac not_less0 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   365
qed "le0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   366
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   367
goalw Nat.thy [le_def] "~ Suc n <= n";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   368
by(Simp_tac 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   369
qed "Suc_n_not_le_n";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   370
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   371
goalw Nat.thy [le_def] "(i <= 0) = (i = 0)";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   372
by(nat_ind_tac "i" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   373
by(ALLGOALS Asm_simp_tac);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   374
qed "le_0";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   375
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   376
Addsimps [less_not_refl,
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   377
          less_Suc_eq, le0, le_0,
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   378
          Suc_Suc_eq, Suc_n_not_le_n,
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   379
          n_not_Suc_n, Suc_n_not_n,
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   380
          nat_case_0, nat_case_Suc, nat_rec_0, nat_rec_Suc];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   381
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   382
(*Prevents simplification of f and g: much faster*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   383
qed_goal "nat_case_weak_cong" Nat.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   384
  "m=n ==> nat_case a f m = nat_case a f n"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   385
  (fn [prem] => [rtac (prem RS arg_cong) 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   386
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   387
qed_goal "nat_rec_weak_cong" Nat.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   388
  "m=n ==> nat_rec m a f = nat_rec n a f"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   389
  (fn [prem] => [rtac (prem RS arg_cong) 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   390
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   391
val prems = goalw Nat.thy [le_def] "~(n<m) ==> m<=(n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   392
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   393
qed "leI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   394
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   395
val prems = goalw Nat.thy [le_def] "m<=n ==> ~(n<(m::nat))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   396
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   397
qed "leD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   398
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   399
val leE = make_elim leD;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   400
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   401
goalw Nat.thy [le_def] "!!m. ~ m <= n ==> n<(m::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   402
by (fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   403
qed "not_leE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   404
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   405
goalw Nat.thy [le_def] "!!m. m < n ==> Suc(m) <= n";
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   406
by(Simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   407
by (fast_tac (HOL_cs addEs [less_anti_refl,less_asym]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   408
qed "lessD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   409
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   410
goalw Nat.thy [le_def] "!!m. Suc(m) <= n ==> m <= n";
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   411
by(Asm_full_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   412
by(fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   413
qed "Suc_leD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   414
1327
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   415
goalw Nat.thy [le_def] "!!m. m <= n ==> m <= Suc n";
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   416
by (fast_tac (HOL_cs addDs [Suc_lessD]) 1);
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   417
qed "le_SucI";
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   418
Addsimps[le_SucI];
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   419
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   420
goalw Nat.thy [le_def] "!!m. m < n ==> m <= (n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   421
by (fast_tac (HOL_cs addEs [less_asym]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   422
qed "less_imp_le";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   423
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   424
goalw Nat.thy [le_def] "!!m. m <= n ==> m < n | m=(n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   425
by (cut_facts_tac [less_linear] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   426
by (fast_tac (HOL_cs addEs [less_anti_refl,less_asym]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   427
qed "le_imp_less_or_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   428
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   429
goalw Nat.thy [le_def] "!!m. m<n | m=n ==> m <=(n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   430
by (cut_facts_tac [less_linear] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   431
by (fast_tac (HOL_cs addEs [less_anti_refl,less_asym]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   432
by (flexflex_tac);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   433
qed "less_or_eq_imp_le";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   434
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   435
goal Nat.thy "(x <= (y::nat)) = (x < y | x=y)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   436
by (REPEAT(ares_tac [iffI,less_or_eq_imp_le,le_imp_less_or_eq] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   437
qed "le_eq_less_or_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   438
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   439
goal Nat.thy "n <= (n::nat)";
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   440
by(simp_tac (!simpset addsimps [le_eq_less_or_eq]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   441
qed "le_refl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   442
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   443
val prems = goal Nat.thy "!!i. [| i <= j; j < k |] ==> i < (k::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   444
by (dtac le_imp_less_or_eq 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   445
by (fast_tac (HOL_cs addIs [less_trans]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   446
qed "le_less_trans";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   447
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   448
goal Nat.thy "!!i. [| i < j; j <= k |] ==> i < (k::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   449
by (dtac le_imp_less_or_eq 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   450
by (fast_tac (HOL_cs addIs [less_trans]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   451
qed "less_le_trans";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   452
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   453
goal Nat.thy "!!i. [| i <= j; j <= k |] ==> i <= (k::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   454
by (EVERY1[dtac le_imp_less_or_eq, dtac le_imp_less_or_eq,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   455
          rtac less_or_eq_imp_le, fast_tac (HOL_cs addIs [less_trans])]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   456
qed "le_trans";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   457
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   458
val prems = goal Nat.thy "!!m. [| m <= n; n <= m |] ==> m = (n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   459
by (EVERY1[dtac le_imp_less_or_eq, dtac le_imp_less_or_eq,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   460
          fast_tac (HOL_cs addEs [less_anti_refl,less_asym])]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   461
qed "le_anti_sym";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   462
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   463
goal Nat.thy "(Suc(n) <= Suc(m)) = (n <= m)";
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   464
by (simp_tac (!simpset addsimps [le_eq_less_or_eq]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   465
qed "Suc_le_mono";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   466
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1024
diff changeset
   467
Addsimps [le_refl,Suc_le_mono];