src/HOL/Nat.thy
author paulson
Wed, 04 Jul 2007 13:56:26 +0200
changeset 23563 42f2f90b51a6
parent 23476 839db6346cc8
child 23740 d7f18c837ce7
permissions -rw-r--r--
simplified a proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title:      HOL/Nat.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
21243
afffe1f72143 removed theory NatArith (now part of Nat);
wenzelm
parents: 21191
diff changeset
     3
    Author:     Tobias Nipkow and Lawrence C Paulson and Markus Wenzel
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
9436
62bb04ab4b01 rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents: 7702
diff changeset
     5
Type "nat" is a linear order, and a datatype; arithmetic operators + -
62bb04ab4b01 rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents: 7702
diff changeset
     6
and * (for div, mod and dvd, see theory Divides).
923
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
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
     9
header {* Natural numbers *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    10
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14740
diff changeset
    11
theory Nat
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
    12
imports Wellfounded_Recursion Ring_and_Field
23263
0c227412b285 tuned boostrap
haftmann
parents: 23001
diff changeset
    13
uses
0c227412b285 tuned boostrap
haftmann
parents: 23001
diff changeset
    14
  "~~/src/Tools/rat.ML"
0c227412b285 tuned boostrap
haftmann
parents: 23001
diff changeset
    15
  "~~/src/Provers/Arith/fast_lin_arith.ML"
0c227412b285 tuned boostrap
haftmann
parents: 23001
diff changeset
    16
  "~~/src/Provers/Arith/cancel_sums.ML"
0c227412b285 tuned boostrap
haftmann
parents: 23001
diff changeset
    17
  ("arith_data.ML")
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14740
diff changeset
    18
begin
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    19
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    20
subsection {* Type @{text ind} *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    21
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    22
typedecl ind
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    23
19573
340c466c9605 axiomatization;
wenzelm
parents: 18702
diff changeset
    24
axiomatization
340c466c9605 axiomatization;
wenzelm
parents: 18702
diff changeset
    25
  Zero_Rep :: ind and
340c466c9605 axiomatization;
wenzelm
parents: 18702
diff changeset
    26
  Suc_Rep :: "ind => ind"
340c466c9605 axiomatization;
wenzelm
parents: 18702
diff changeset
    27
where
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    28
  -- {* the axiom of infinity in 2 parts *}
19573
340c466c9605 axiomatization;
wenzelm
parents: 18702
diff changeset
    29
  inj_Suc_Rep:          "inj Suc_Rep" and
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
    30
  Suc_Rep_not_Zero_Rep: "Suc_Rep x \<noteq> Zero_Rep"
19573
340c466c9605 axiomatization;
wenzelm
parents: 18702
diff changeset
    31
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    32
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    33
subsection {* Type nat *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    34
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    35
text {* Type definition *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    36
22262
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    37
inductive2 Nat :: "ind \<Rightarrow> bool"
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    38
where
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    39
    Zero_RepI: "Nat Zero_Rep"
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    40
  | Suc_RepI: "Nat i ==> Nat (Suc_Rep i)"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    41
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    42
global
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    43
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    44
typedef (open Nat)
22262
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    45
  nat = "Collect Nat"
21243
afffe1f72143 removed theory NatArith (now part of Nat);
wenzelm
parents: 21191
diff changeset
    46
proof
22262
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    47
  from Nat.Zero_RepI
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    48
  show "Zero_Rep : Collect Nat" ..
21243
afffe1f72143 removed theory NatArith (now part of Nat);
wenzelm
parents: 21191
diff changeset
    49
qed
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    50
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    51
text {* Abstract constants and syntax *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    52
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    53
consts
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    54
  Suc :: "nat => nat"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    55
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    56
local
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    57
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    58
defs
18648
22f96cd085d5 tidied, and giving theorems names
paulson
parents: 17702
diff changeset
    59
  Suc_def:      "Suc == (%n. Abs_Nat (Suc_Rep (Rep_Nat n)))"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    60
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    61
definition
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    62
  pred_nat :: "(nat * nat) set" where
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    63
  "pred_nat = {(m, n). n = Suc m}"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    64
21456
1c2b9df41e98 cleanup
haftmann
parents: 21411
diff changeset
    65
instance nat :: "{ord, zero, one}"
1c2b9df41e98 cleanup
haftmann
parents: 21411
diff changeset
    66
  Zero_nat_def: "0 == Abs_Nat Zero_Rep"
1c2b9df41e98 cleanup
haftmann
parents: 21411
diff changeset
    67
  One_nat_def [simp]: "1 == Suc 0"
22262
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    68
  less_def: "m < n == (m, n) : pred_nat^+"
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22718
diff changeset
    69
  le_def:   "m \<le> (n::nat) == ~ (n < m)" ..
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22718
diff changeset
    70
22845
5f9138bcb3d7 changed code generator invocation syntax
haftmann
parents: 22744
diff changeset
    71
lemmas [code func del] = less_def le_def
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    72
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    73
text {* Induction *}
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    75
lemma Rep_Nat': "Nat (Rep_Nat x)"
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    76
  by (rule Rep_Nat [simplified mem_Collect_eq])
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    77
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    78
lemma Abs_Nat_inverse': "Nat y \<Longrightarrow> Rep_Nat (Abs_Nat y) = y"
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    79
  by (rule Abs_Nat_inverse [simplified mem_Collect_eq])
22262
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    80
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    81
theorem nat_induct: "P 0 ==> (!!n. P n ==> P (Suc n)) ==> P n"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    82
  apply (unfold Zero_nat_def Suc_def)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    83
  apply (rule Rep_Nat_inverse [THEN subst]) -- {* types force good instantiation *}
22262
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    84
  apply (erule Rep_Nat' [THEN Nat.induct])
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    85
  apply (iprover elim: Abs_Nat_inverse' [THEN subst])
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    86
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    87
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    88
text {* Distinctness of constructors *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    89
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
    90
lemma Suc_not_Zero [iff]: "Suc m \<noteq> 0"
22262
96ba62dff413 Adapted to new inductive definition package.
berghofe
parents: 22191
diff changeset
    91
  by (simp add: Zero_nat_def Suc_def Abs_Nat_inject Rep_Nat' Suc_RepI Zero_RepI
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
    92
                Suc_Rep_not_Zero_Rep)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    93
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
    94
lemma Zero_not_Suc [iff]: "0 \<noteq> Suc m"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    95
  by (rule not_sym, rule Suc_not_Zero not_sym)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    96
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    97
lemma Suc_neq_Zero: "Suc m = 0 ==> R"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    98
  by (rule notE, rule Suc_not_Zero)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
    99
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   100
lemma Zero_neq_Suc: "0 = Suc m ==> R"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   101
  by (rule Suc_neq_Zero, erule sym)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   102
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   103
text {* Injectiveness of @{term Suc} *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   104
16733
236dfafbeb63 linear arithmetic now takes "&" in assumptions apart.
nipkow
parents: 16635
diff changeset
   105
lemma inj_Suc[simp]: "inj_on Suc N"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   106
  by (simp add: Suc_def inj_on_def Abs_Nat_inject Rep_Nat' Suc_RepI
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   107
                inj_Suc_Rep [THEN inj_eq] Rep_Nat_inject)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   108
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   109
lemma Suc_inject: "Suc x = Suc y ==> x = y"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   110
  by (rule inj_Suc [THEN injD])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   111
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   112
lemma Suc_Suc_eq [iff]: "(Suc m = Suc n) = (m = n)"
15413
901d1bfedf09 removal of archaic Abs/Rep proofs
paulson
parents: 15341
diff changeset
   113
  by (rule inj_Suc [THEN inj_eq])
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   114
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   115
lemma nat_not_singleton: "(\<forall>x. x = (0::nat)) = False"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   116
  by auto
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   117
21411
a9671d4f7c03 power is now a class
haftmann
parents: 21252
diff changeset
   118
text {* size of a datatype value *}
21243
afffe1f72143 removed theory NatArith (now part of Nat);
wenzelm
parents: 21191
diff changeset
   119
22473
753123c89d72 explizit "type" superclass
haftmann
parents: 22348
diff changeset
   120
class size = type +
21411
a9671d4f7c03 power is now a class
haftmann
parents: 21252
diff changeset
   121
  fixes size :: "'a \<Rightarrow> nat"
21243
afffe1f72143 removed theory NatArith (now part of Nat);
wenzelm
parents: 21191
diff changeset
   122
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   123
text {* @{typ nat} is a datatype *}
9436
62bb04ab4b01 rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents: 7702
diff changeset
   124
5188
633ec5f6c155 Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents: 4640
diff changeset
   125
rep_datatype nat
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   126
  distinct  Suc_not_Zero Zero_not_Suc
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   127
  inject    Suc_Suc_eq
21411
a9671d4f7c03 power is now a class
haftmann
parents: 21252
diff changeset
   128
  induction nat_induct
a9671d4f7c03 power is now a class
haftmann
parents: 21252
diff changeset
   129
a9671d4f7c03 power is now a class
haftmann
parents: 21252
diff changeset
   130
declare nat.induct [case_names 0 Suc, induct type: nat]
a9671d4f7c03 power is now a class
haftmann
parents: 21252
diff changeset
   131
declare nat.exhaust [case_names 0 Suc, cases type: nat]
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   132
21672
29c346b165d4 added aliases for nat_recs/cases;
wenzelm
parents: 21456
diff changeset
   133
lemmas nat_rec_0 = nat.recs(1)
29c346b165d4 added aliases for nat_recs/cases;
wenzelm
parents: 21456
diff changeset
   134
  and nat_rec_Suc = nat.recs(2)
29c346b165d4 added aliases for nat_recs/cases;
wenzelm
parents: 21456
diff changeset
   135
29c346b165d4 added aliases for nat_recs/cases;
wenzelm
parents: 21456
diff changeset
   136
lemmas nat_case_0 = nat.cases(1)
29c346b165d4 added aliases for nat_recs/cases;
wenzelm
parents: 21456
diff changeset
   137
  and nat_case_Suc = nat.cases(2)
29c346b165d4 added aliases for nat_recs/cases;
wenzelm
parents: 21456
diff changeset
   138
29c346b165d4 added aliases for nat_recs/cases;
wenzelm
parents: 21456
diff changeset
   139
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   140
lemma n_not_Suc_n: "n \<noteq> Suc n"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   141
  by (induct n) simp_all
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   142
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   143
lemma Suc_n_not_n: "Suc t \<noteq> t"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   144
  by (rule not_sym, rule n_not_Suc_n)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   145
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   146
text {* A special form of induction for reasoning
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   147
  about @{term "m < n"} and @{term "m - n"} *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   148
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   149
theorem diff_induct: "(!!x. P x 0) ==> (!!y. P 0 (Suc y)) ==>
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   150
    (!!x y. P x y ==> P (Suc x) (Suc y)) ==> P m n"
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   151
  apply (rule_tac x = m in spec)
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15140
diff changeset
   152
  apply (induct n)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   153
  prefer 2
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   154
  apply (rule allI)
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 16796
diff changeset
   155
  apply (induct_tac x, iprover+)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   156
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   157
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   158
subsection {* Basic properties of "less than" *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   159
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   160
lemma wf_pred_nat: "wf pred_nat"
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   161
  apply (unfold wf_def pred_nat_def, clarify)
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   162
  apply (induct_tac x, blast+)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   163
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   164
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   165
lemma wf_less: "wf {(x, y::nat). x < y}"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   166
  apply (unfold less_def)
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   167
  apply (rule wf_pred_nat [THEN wf_trancl, THEN wf_subset], blast)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   168
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   169
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   170
lemma less_eq: "((m, n) : pred_nat^+) = (m < n)"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   171
  apply (unfold less_def)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   172
  apply (rule refl)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   173
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   174
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   175
subsubsection {* Introduction properties *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   176
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   177
lemma less_trans: "i < j ==> j < k ==> i < (k::nat)"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   178
  apply (unfold less_def)
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   179
  apply (rule trans_trancl [THEN transD], assumption+)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   180
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   181
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   182
lemma lessI [iff]: "n < Suc n"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   183
  apply (unfold less_def pred_nat_def)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   184
  apply (simp add: r_into_trancl)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   185
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   186
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   187
lemma less_SucI: "i < j ==> i < Suc j"
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   188
  apply (rule less_trans, assumption)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   189
  apply (rule lessI)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   190
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   191
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   192
lemma zero_less_Suc [iff]: "0 < Suc n"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   193
  apply (induct n)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   194
  apply (rule lessI)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   195
  apply (erule less_trans)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   196
  apply (rule lessI)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   197
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   198
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   199
subsubsection {* Elimination properties *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   200
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   201
lemma less_not_sym: "n < m ==> ~ m < (n::nat)"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   202
  apply (unfold less_def)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   203
  apply (blast intro: wf_pred_nat wf_trancl [THEN wf_asym])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   204
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   205
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   206
lemma less_asym:
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   207
  assumes h1: "(n::nat) < m" and h2: "~ P ==> m < n" shows P
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   208
  apply (rule contrapos_np)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   209
  apply (rule less_not_sym)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   210
  apply (rule h1)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   211
  apply (erule h2)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   212
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   213
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   214
lemma less_not_refl: "~ n < (n::nat)"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   215
  apply (unfold less_def)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   216
  apply (rule wf_pred_nat [THEN wf_trancl, THEN wf_not_refl])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   217
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   218
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   219
lemma less_irrefl [elim!]: "(n::nat) < n ==> R"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   220
  by (rule notE, rule less_not_refl)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   221
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   222
lemma less_not_refl2: "n < m ==> m \<noteq> (n::nat)" by blast
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   223
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   224
lemma less_not_refl3: "(s::nat) < t ==> s \<noteq> t"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   225
  by (rule not_sym, rule less_not_refl2)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   226
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   227
lemma lessE:
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   228
  assumes major: "i < k"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   229
  and p1: "k = Suc i ==> P" and p2: "!!j. i < j ==> k = Suc j ==> P"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   230
  shows P
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   231
  apply (rule major [unfolded less_def pred_nat_def, THEN tranclE], simp_all)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   232
  apply (erule p1)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   233
  apply (rule p2)
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   234
  apply (simp add: less_def pred_nat_def, assumption)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   235
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   236
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   237
lemma not_less0 [iff]: "~ n < (0::nat)"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   238
  by (blast elim: lessE)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   239
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   240
lemma less_zeroE: "(n::nat) < 0 ==> R"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   241
  by (rule notE, rule not_less0)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   242
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   243
lemma less_SucE: assumes major: "m < Suc n"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   244
  and less: "m < n ==> P" and eq: "m = n ==> P" shows P
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   245
  apply (rule major [THEN lessE])
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   246
  apply (rule eq, blast)
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   247
  apply (rule less, blast)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   248
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   249
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   250
lemma less_Suc_eq: "(m < Suc n) = (m < n | m = n)"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   251
  by (blast elim!: less_SucE intro: less_trans)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   252
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   253
lemma less_one [iff]: "(n < (1::nat)) = (n = 0)"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   254
  by (simp add: less_Suc_eq)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   255
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   256
lemma less_Suc0 [iff]: "(n < Suc 0) = (n = 0)"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   257
  by (simp add: less_Suc_eq)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   258
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   259
lemma Suc_mono: "m < n ==> Suc m < Suc n"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   260
  by (induct n) (fast elim: less_trans lessE)+
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   261
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   262
text {* "Less than" is a linear ordering *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   263
lemma less_linear: "m < n | m = n | n < (m::nat)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15140
diff changeset
   264
  apply (induct m)
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15140
diff changeset
   265
  apply (induct n)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   266
  apply (rule refl [THEN disjI1, THEN disjI2])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   267
  apply (rule zero_less_Suc [THEN disjI1])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   268
  apply (blast intro: Suc_mono less_SucI elim: lessE)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   269
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   270
14302
6c24235e8d5d *** empty log message ***
nipkow
parents: 14267
diff changeset
   271
text {* "Less than" is antisymmetric, sort of *}
6c24235e8d5d *** empty log message ***
nipkow
parents: 14267
diff changeset
   272
lemma less_antisym: "\<lbrakk> \<not> n < m; n < Suc m \<rbrakk> \<Longrightarrow> m = n"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   273
  apply(simp only:less_Suc_eq)
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   274
  apply blast
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   275
  done
14302
6c24235e8d5d *** empty log message ***
nipkow
parents: 14267
diff changeset
   276
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   277
lemma nat_neq_iff: "((m::nat) \<noteq> n) = (m < n | n < m)"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   278
  using less_linear by blast
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   279
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   280
lemma nat_less_cases: assumes major: "(m::nat) < n ==> P n m"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   281
  and eqCase: "m = n ==> P n m" and lessCase: "n<m ==> P n m"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   282
  shows "P n m"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   283
  apply (rule less_linear [THEN disjE])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   284
  apply (erule_tac [2] disjE)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   285
  apply (erule lessCase)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   286
  apply (erule sym [THEN eqCase])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   287
  apply (erule major)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   288
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   289
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   290
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   291
subsubsection {* Inductive (?) properties *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   292
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   293
lemma Suc_lessI: "m < n ==> Suc m \<noteq> n ==> Suc m < n"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   294
  apply (simp add: nat_neq_iff)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   295
  apply (blast elim!: less_irrefl less_SucE elim: less_asym)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   296
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   297
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   298
lemma Suc_lessD: "Suc m < n ==> m < n"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   299
  apply (induct n)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   300
  apply (fast intro!: lessI [THEN less_SucI] elim: less_trans lessE)+
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   301
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   302
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   303
lemma Suc_lessE: assumes major: "Suc i < k"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   304
  and minor: "!!j. i < j ==> k = Suc j ==> P" shows P
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   305
  apply (rule major [THEN lessE])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   306
  apply (erule lessI [THEN minor])
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   307
  apply (erule Suc_lessD [THEN minor], assumption)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   308
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   309
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   310
lemma Suc_less_SucD: "Suc m < Suc n ==> m < n"
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   311
  by (blast elim: lessE dest: Suc_lessD)
4104
84433b1ab826 nat datatype_info moved to Nat.thy;
wenzelm
parents: 3370
diff changeset
   312
16635
bf7de5723c60 Moved some code lemmas from Main to Nat.
berghofe
parents: 15921
diff changeset
   313
lemma Suc_less_eq [iff, code]: "(Suc m < Suc n) = (m < n)"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   314
  apply (rule iffI)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   315
  apply (erule Suc_less_SucD)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   316
  apply (erule Suc_mono)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   317
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   318
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   319
lemma less_trans_Suc:
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   320
  assumes le: "i < j" shows "j < k ==> Suc i < k"
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   321
  apply (induct k, simp_all)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   322
  apply (insert le)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   323
  apply (simp add: less_Suc_eq)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   324
  apply (blast dest: Suc_lessD)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   325
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   326
16635
bf7de5723c60 Moved some code lemmas from Main to Nat.
berghofe
parents: 15921
diff changeset
   327
lemma [code]: "((n::nat) < 0) = False" by simp
bf7de5723c60 Moved some code lemmas from Main to Nat.
berghofe
parents: 15921
diff changeset
   328
lemma [code]: "(0 < Suc n) = True" by simp
bf7de5723c60 Moved some code lemmas from Main to Nat.
berghofe
parents: 15921
diff changeset
   329
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   330
text {* Can be used with @{text less_Suc_eq} to get @{term "n = m | n < m"} *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   331
lemma not_less_eq: "(~ m < n) = (n < Suc m)"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   332
  by (induct m n rule: diff_induct) simp_all
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   333
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   334
text {* Complete induction, aka course-of-values induction *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   335
lemma nat_less_induct:
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   336
  assumes prem: "!!n. \<forall>m::nat. m < n --> P m ==> P n" shows "P n"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   337
  apply (induct n rule: wf_induct [OF wf_pred_nat [THEN wf_trancl]])
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   338
  apply (rule prem)
14208
144f45277d5a misc tidying
paulson
parents: 14193
diff changeset
   339
  apply (unfold less_def, assumption)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   340
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   341
14131
a4fc8b1af5e7 declarations moved from PreList.thy
paulson
parents: 13596
diff changeset
   342
lemmas less_induct = nat_less_induct [rule_format, case_names less]
a4fc8b1af5e7 declarations moved from PreList.thy
paulson
parents: 13596
diff changeset
   343
21243
afffe1f72143 removed theory NatArith (now part of Nat);
wenzelm
parents: 21191
diff changeset
   344
14131
a4fc8b1af5e7 declarations moved from PreList.thy
paulson
parents: 13596
diff changeset
   345
subsection {* Properties of "less than or equal" *}
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   346
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   347
text {* Was @{text le_eq_less_Suc}, but this orientation is more useful *}
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   348
lemma less_Suc_eq_le: "(m < Suc n) = (m \<le> n)"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   349
  unfolding le_def by (rule not_less_eq [symmetric])
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   350
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   351
lemma le_imp_less_Suc: "m \<le> n ==> m < Suc n"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   352
  by (rule less_Suc_eq_le [THEN iffD2])
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   353
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   354
lemma le0 [iff]: "(0::nat) \<le> n"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   355
  unfolding le_def by (rule not_less0)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   356
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   357
lemma Suc_n_not_le_n: "~ Suc n \<le> n"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   358
  by (simp add: le_def)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   359
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   360
lemma le_0_eq [iff]: "((i::nat) \<le> 0) = (i = 0)"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   361
  by (induct i) (simp_all add: le_def)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   362
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   363
lemma le_Suc_eq: "(m \<le> Suc n) = (m \<le> n | m = Suc n)"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   364
  by (simp del: less_Suc_eq_le add: less_Suc_eq_le [symmetric] less_Suc_eq)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   365
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   366
lemma le_SucE: "m \<le> Suc n ==> (m \<le> n ==> R) ==> (m = Suc n ==> R) ==> R"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 16796
diff changeset
   367
  by (drule le_Suc_eq [THEN iffD1], iprover+)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   368
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   369
lemma Suc_leI: "m < n ==> Suc(m) \<le> n"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   370
  apply (simp add: le_def less_Suc_eq)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   371
  apply (blast elim!: less_irrefl less_asym)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   372
  done -- {* formerly called lessD *}
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   373
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   374
lemma Suc_leD: "Suc(m) \<le> n ==> m \<le> n"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   375
  by (simp add: le_def less_Suc_eq)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   376
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   377
text {* Stronger version of @{text Suc_leD} *}
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   378
lemma Suc_le_lessD: "Suc m \<le> n ==> m < n"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   379
  apply (simp add: le_def less_Suc_eq)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   380
  using less_linear
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   381
  apply blast
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   382
  done
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   383
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   384
lemma Suc_le_eq: "(Suc m \<le> n) = (m < n)"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   385
  by (blast intro: Suc_leI Suc_le_lessD)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   386
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   387
lemma le_SucI: "m \<le> n ==> m \<le> Suc n"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   388
  by (unfold le_def) (blast dest: Suc_lessD)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   389
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   390
lemma less_imp_le: "m < n ==> m \<le> (n::nat)"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   391
  by (unfold le_def) (blast elim: less_asym)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   392
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   393
text {* For instance, @{text "(Suc m < Suc n) = (Suc m \<le> n) = (m < n)"} *}
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   394
lemmas le_simps = less_imp_le less_Suc_eq_le Suc_le_eq
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   395
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   396
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   397
text {* Equivalence of @{term "m \<le> n"} and @{term "m < n | m = n"} *}
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   398
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   399
lemma le_imp_less_or_eq: "m \<le> n ==> m < n | m = (n::nat)"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   400
  unfolding le_def
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   401
  using less_linear
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   402
  by (blast elim: less_irrefl less_asym)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   403
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   404
lemma less_or_eq_imp_le: "m < n | m = n ==> m \<le> (n::nat)"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   405
  unfolding le_def
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   406
  using less_linear
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   407
  by (blast elim!: less_irrefl elim: less_asym)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   408
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   409
lemma le_eq_less_or_eq: "(m \<le> (n::nat)) = (m < n | m=n)"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 16796
diff changeset
   410
  by (iprover intro: less_or_eq_imp_le le_imp_less_or_eq)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   411
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   412
text {* Useful with @{text blast}. *}
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   413
lemma eq_imp_le: "(m::nat) = n ==> m \<le> n"
22718
936f7580937d tuned proofs;
wenzelm
parents: 22483
diff changeset
   414
  by (rule less_or_eq_imp_le) (rule disjI2)
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   415
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents: 14266
diff changeset
   416
lemma le_refl: "n \<le> (n::nat)"
13449
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   417
  by (simp add: le_eq_less_or_eq)
43c9ec498291 - Converted to new theory format
berghofe
parents: 12338
diff changeset
   418
14267
b963e9cee2a0 More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas