:: The Fundamental Properties of Natural Numbers
:: by Grzegorz Bancerek
::
:: Received January 11, 1989
:: Copyright (c) 1990-2011 Association of Mizar Users


begin

definition
mode Nat is natural number ;
end;

theorem Th1: :: NAT_1:1
for X being Subset of REAL st 0 in X & ( for x being Real st x in X holds
x + 1 in X ) holds
for n being Nat holds n in X
proof end;

registration
let n, k be Nat;
cluster n + k -> natural ;
coherence
n + k is natural
proof end;
end;

definition
let n be Nat;
let k be Element of NAT ;
:: original: +
redefine func n + k -> Element of NAT ;
coherence
n + k is Element of NAT
by ORDINAL1:def 13;
end;

definition
let n be Element of NAT ;
let k be Nat;
:: original: +
redefine func n + k -> Element of NAT ;
coherence
n + k is Element of NAT
by ORDINAL1:def 13;
end;

scheme :: NAT_1:sch 1
Ind{ P1[ Nat] } :
for k being Element of NAT holds P1[k]
provided
A1: P1[ 0 ] and
A2: for k being Element of NAT st P1[k] holds
P1[k + 1]
proof end;

scheme :: NAT_1:sch 2
NatInd{ P1[ Nat] } :
for k being Nat holds P1[k]
provided
A1: P1[ 0 ] and
A2: for k being Nat st P1[k] holds
P1[k + 1]
proof end;

registration
let n, k be Nat;
cluster n * k -> natural ;
coherence
n * k is natural
proof end;
end;

definition
let n be Nat;
let k be Element of NAT ;
:: original: *
redefine func n * k -> Element of NAT ;
coherence
n * k is Element of NAT
by ORDINAL1:def 13;
end;

definition
let n be Element of NAT ;
let k be Nat;
:: original: *
redefine func n * k -> Element of NAT ;
coherence
n * k is Element of NAT
by ORDINAL1:def 13;
end;

theorem Th2: :: NAT_1:2
for i being Nat holds 0 <= i
proof end;

theorem :: NAT_1:3
for i being Nat st 0 <> i holds
0 < i by Th2;

theorem :: NAT_1:4
for i, j, h being Nat st i <= j holds
i * h <= j * h
proof end;

theorem :: NAT_1:5
for i being Nat holds 0 < i + 1
proof end;

theorem Th6: :: NAT_1:6
for i being Nat holds
( i = 0 or ex k being Nat st i = k + 1 )
proof end;

theorem Th7: :: NAT_1:7
for i, j being Nat st i + j = 0 holds
( i = 0 & j = 0 )
proof end;

registration
cluster non zero epsilon-transitive epsilon-connected ordinal natural complex ext-real real finite cardinal set ;
existence
not for b1 being Nat holds b1 is empty
proof end;
end;

registration
let m be Nat;
let n be non zero Nat;
cluster m + n -> non zero ;
coherence
not m + n is empty
by Th7;
cluster n + m -> non zero ;
coherence
not n + m is empty
;
end;

scheme :: NAT_1:sch 3
DefbyInd{ F1() -> Nat, F2( Nat, Nat) -> Nat, P1[ Nat, Nat] } :
( ( for k being Nat ex n being Nat st P1[k,n] ) & ( for k, n, m being Nat st P1[k,n] & P1[k,m] holds
n = m ) )
provided
A1: for k, n being Nat holds
( P1[k,n] iff ( ( k = 0 & n = F1() ) or ex m, l being Nat st
( k = m + 1 & P1[m,l] & n = F2(k,l) ) ) )
proof end;

theorem Th8: :: NAT_1:8
for i, j being Nat holds
( not i <= j + 1 or i <= j or i = j + 1 )
proof end;

theorem :: NAT_1:9
for i, j being Nat st i <= j & j <= i + 1 & not i = j holds
j = i + 1
proof end;

theorem Th10: :: NAT_1:10
for i, j being Nat st i <= j holds
ex k being Nat st j = i + k
proof end;

theorem Th11: :: NAT_1:11
for i, j being Nat holds i <= i + j
proof end;

scheme :: NAT_1:sch 4
CompInd{ P1[ Nat] } :
for k being Nat holds P1[k]
provided
A1: for k being Nat st ( for n being Nat st n < k holds
P1[n] ) holds
P1[k]
proof end;

scheme :: NAT_1:sch 5
Min{ P1[ Nat] } :
ex k being Nat st
( P1[k] & ( for n being Nat st P1[n] holds
k <= n ) )
provided
A1: ex k being Nat st P1[k]
proof end;

scheme :: NAT_1:sch 6
Max{ P1[ Nat], F1() -> Nat } :
ex k being Nat st
( P1[k] & ( for n being Nat st P1[n] holds
n <= k ) )
provided
A1: for k being Nat st P1[k] holds
k <= F1() and
A2: ex k being Nat st P1[k]
proof end;

theorem Th12: :: NAT_1:12
for i, j, h being Nat st i <= j holds
i <= j + h
proof end;

theorem Th13: :: NAT_1:13
for i, j being Nat holds
( i < j + 1 iff i <= j )
proof end;

theorem Th14: :: NAT_1:14
for j being Nat st j < 1 holds
j = 0
proof end;

theorem :: NAT_1:15
for i, j being Nat st i * j = 1 holds
i = 1
proof end;

theorem Th16: :: NAT_1:16
for k, n being Nat st k <> 0 holds
n < n + k
proof end;

scheme :: NAT_1:sch 7
Regr{ P1[ Nat] } :
P1[ 0 ]
provided
A1: ex k being Nat st P1[k] and
A2: for k being Nat st k <> 0 & P1[k] holds
ex n being Nat st
( n < k & P1[n] )
proof end;

theorem :: NAT_1:17
for m being Nat st 0 < m holds
for n being Nat ex k, t being Nat st
( n = (m * k) + t & t < m )
proof end;

theorem :: NAT_1:18
for n, m, k, t, k1, t1 being Nat st n = (m * k) + t & t < m & n = (m * k1) + t1 & t1 < m holds
( k = k1 & t = t1 )
proof end;

registration
cluster natural -> ordinal set ;
coherence
for b1 being Nat holds b1 is ordinal
;
end;

registration
cluster non empty ordinal Element of K6(REAL);
existence
ex b1 being Subset of REAL st
( not b1 is empty & b1 is ordinal )
proof end;
end;

theorem :: NAT_1:19
for k, n being Nat holds
( k < k + n iff 1 <= n )
proof end;

theorem :: NAT_1:20
for k, n being Nat st k < n holds
n - 1 is Element of NAT
proof end;

theorem :: NAT_1:21
for k, n being Nat st k <= n holds
n - k is Element of NAT
proof end;

begin

theorem Th22: :: NAT_1:22
for m, n being Nat holds
( not m < n + 1 or m < n or m = n )
proof end;

theorem :: NAT_1:23
for k being Nat holds
( not k < 2 or k = 0 or k = 1 )
proof end;

registration
cluster non zero epsilon-transitive epsilon-connected ordinal natural complex ext-real real finite cardinal Element of NAT ;
existence
not for b1 being Element of NAT holds b1 is empty
proof end;
end;

registration
cluster -> non negative Element of NAT ;
coherence
for b1 being Element of NAT holds not b1 is negative
by Th2;
end;

registration
cluster natural -> non negative set ;
coherence
for b1 being Nat holds not b1 is negative
by Th2;
end;

theorem :: NAT_1:24
for i, h, j being Nat st i <> 0 & h = j * i holds
j <= h
proof end;

theorem :: NAT_1:25
canceled;

scheme :: NAT_1:sch 8
Ind1{ F1() -> Nat, P1[ Nat] } :
for i being Nat st F1() <= i holds
P1[i]
provided
A1: P1[F1()] and
A2: for j being Nat st F1() <= j & P1[j] holds
P1[j + 1]
proof end;

scheme :: NAT_1:sch 9
CompInd1{ F1() -> Nat, P1[ Nat] } :
for k being Nat st k >= F1() holds
P1[k]
provided
A1: for k being Nat st k >= F1() & ( for n being Nat st n >= F1() & n < k holds
P1[n] ) holds
P1[k]
proof end;

theorem Th26: :: NAT_1:26
for n being Nat holds
( not n <= 1 or n = 0 or n = 1 )
proof end;

theorem Th27: :: NAT_1:27
for n being Nat holds
( not n <= 2 or n = 0 or n = 1 or n = 2 )
proof end;

theorem Th28: :: NAT_1:28
for n being Nat holds
( not n <= 3 or n = 0 or n = 1 or n = 2 or n = 3 )
proof end;

theorem Th29: :: NAT_1:29
for n being Nat holds
( not n <= 4 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 )
proof end;

theorem Th30: :: NAT_1:30
for n being Nat holds
( not n <= 5 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 )
proof end;

theorem Th31: :: NAT_1:31
for n being Nat holds
( not n <= 6 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 or n = 6 )
proof end;

theorem Th32: :: NAT_1:32
for n being Nat holds
( not n <= 7 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 or n = 6 or n = 7 )
proof end;

theorem Th33: :: NAT_1:33
for n being Nat holds
( not n <= 8 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 or n = 6 or n = 7 or n = 8 )
proof end;

theorem Th34: :: NAT_1:34
for n being Nat holds
( not n <= 9 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 or n = 6 or n = 7 or n = 8 or n = 9 )
proof end;

theorem Th35: :: NAT_1:35
for n being Nat holds
( not n <= 10 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 or n = 6 or n = 7 or n = 8 or n = 9 or n = 10 )
proof end;

theorem Th36: :: NAT_1:36
for n being Nat holds
( not n <= 11 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 or n = 6 or n = 7 or n = 8 or n = 9 or n = 10 or n = 11 )
proof end;

theorem Th37: :: NAT_1:37
for n being Nat holds
( not n <= 12 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 or n = 6 or n = 7 or n = 8 or n = 9 or n = 10 or n = 11 or n = 12 )
proof end;

theorem :: NAT_1:38
for n being Nat holds
( not n <= 13 or n = 0 or n = 1 or n = 2 or n = 3 or n = 4 or n = 5 or n = 6 or n = 7 or n = 8 or n = 9 or n = 10 or n = 11 or n = 12 or n = 13 )
proof end;

scheme :: NAT_1:sch 10
Indfrom1{ P1[ Nat] } :
for k being non empty Nat holds P1[k]
provided
A1: P1[1] and
A2: for k being non empty Nat st P1[k] holds
P1[k + 1]
proof end;

definition
let A be set ;
func min* A -> Element of NAT means :Def1: :: NAT_1:def 1
( it in A & ( for k being Nat st k in A holds
it <= k ) ) if A is non empty Subset of NAT
otherwise it = 0 ;
existence
( ( A is non empty Subset of NAT implies ex b1 being Element of NAT st
( b1 in A & ( for k being Nat st k in A holds
b1 <= k ) ) ) & ( A is not non empty Subset of NAT implies ex b1 being Element of NAT st b1 = 0 ) )
proof end;
uniqueness
for b1, b2 being Element of NAT holds
( ( A is non empty Subset of NAT & b1 in A & ( for k being Nat st k in A holds
b1 <= k ) & b2 in A & ( for k being Nat st k in A holds
b2 <= k ) implies b1 = b2 ) & ( A is not non empty Subset of NAT & b1 = 0 & b2 = 0 implies b1 = b2 ) )
proof end;
consistency
for b1 being Element of NAT holds verum
;
end;

:: deftheorem Def1 defines min* NAT_1:def 1 :
for A being set
for b2 being Element of NAT holds
( ( A is non empty Subset of NAT implies ( b2 = min* A iff ( b2 in A & ( for k being Nat st k in A holds
b2 <= k ) ) ) ) & ( A is not non empty Subset of NAT implies ( b2 = min* A iff b2 = 0 ) ) );

theorem Th39: :: NAT_1:39
for n being natural number holds succ n = n + 1
proof end;

theorem Th40: :: NAT_1:40
for n, m being Nat holds
( n <= m iff n c= m )
proof end;

theorem Th41: :: NAT_1:41
for n, m being Nat holds
( card n c= card m iff n <= m )
proof end;

theorem Th42: :: NAT_1:42
for n, m being Nat holds
( card n in card m iff n < m )
proof end;

theorem :: NAT_1:43
for n being Nat holds nextcard (card n) = card (n + 1)
proof end;

definition
let n be natural number ;
redefine func succ n equals :: NAT_1:def 2
n + 1;
compatibility
for b1 being set holds
( b1 = succ n iff b1 = n + 1 )
by Th39;
end;

:: deftheorem defines succ NAT_1:def 2 :
for n being natural number holds succ n = n + 1;

theorem :: NAT_1:44
for X, Y being finite set st X c= Y holds
card X <= card Y
proof end;

theorem :: NAT_1:45
for k, n being Nat holds
( k in n iff k < n )
proof end;

theorem :: NAT_1:46
for n being Nat holds n in n + 1
proof end;

theorem :: NAT_1:47
for k, n being Nat st k <= n holds
k = k /\ n
proof end;

scheme :: NAT_1:sch 11
LambdaRecEx{ F1() -> set , F2( set , set ) -> set } :
ex f being Function st
( dom f = NAT & f . 0 = F1() & ( for n being Nat holds f . (n + 1) = F2(n,(f . n)) ) )
proof end;

scheme :: NAT_1:sch 12
LambdaRecExD{ F1() -> non empty set , F2() -> Element of F1(), F3( set , set ) -> Element of F1() } :
ex f being Function of NAT,F1() st
( f . 0 = F2() & ( for n being Nat holds f . (n + 1) = F3(n,(f . n)) ) )
proof end;

scheme :: NAT_1:sch 13
RecUn{ F1() -> set , F2() -> Function, F3() -> Function, P1[ set , set , set ] } :
F2() = F3()
provided
A1: dom F2() = NAT and
A2: F2() . 0 = F1() and
A3: for n being Nat holds P1[n,F2() . n,F2() . (n + 1)] and
A4: dom F3() = NAT and
A5: F3() . 0 = F1() and
A6: for n being Nat holds P1[n,F3() . n,F3() . (n + 1)] and
A7: for n being Nat
for x, y1, y2 being set st P1[n,x,y1] & P1[n,x,y2] holds
y1 = y2
proof end;

scheme :: NAT_1:sch 14
RecUnD{ F1() -> non empty set , F2() -> Element of F1(), P1[ set , set , set ], F3() -> Function of NAT,F1(), F4() -> Function of NAT,F1() } :
F3() = F4()
provided
A1: F3() . 0 = F2() and
A2: for n being Nat holds P1[n,F3() . n,F3() . (n + 1)] and
A3: F4() . 0 = F2() and
A4: for n being Nat holds P1[n,F4() . n,F4() . (n + 1)] and
A5: for n being Nat
for x, y1, y2 being Element of F1() st P1[n,x,y1] & P1[n,x,y2] holds
y1 = y2
proof end;

scheme :: NAT_1:sch 15
LambdaRecUn{ F1() -> set , F2( set , set ) -> set , F3() -> Function, F4() -> Function } :
F3() = F4()
provided
A1: dom F3() = NAT and
A2: F3() . 0 = F1() and
A3: for n being Nat holds F3() . (n + 1) = F2(n,(F3() . n)) and
A4: dom F4() = NAT and
A5: F4() . 0 = F1() and
A6: for n being Nat holds F4() . (n + 1) = F2(n,(F4() . n))
proof end;

scheme :: NAT_1:sch 16
LambdaRecUnD{ F1() -> non empty set , F2() -> Element of F1(), F3( set , set ) -> Element of F1(), F4() -> Function of NAT,F1(), F5() -> Function of NAT,F1() } :
F4() = F5()
provided
A1: F4() . 0 = F2() and
A2: for n being Nat holds F4() . (n + 1) = F3(n,(F4() . n)) and
A3: F5() . 0 = F2() and
A4: for n being Nat holds F5() . (n + 1) = F3(n,(F5() . n))
proof end;

registration
let x, y be Nat;
cluster min (x,y) -> natural ;
coherence
min (x,y) is natural
by XXREAL_0:15;
cluster max (x,y) -> natural ;
coherence
max (x,y) is natural
by XXREAL_0:16;
end;

scheme :: NAT_1:sch 17
MinIndex{ F1( Nat) -> Nat } :
ex k being Nat st
( F1(k) = 0 & ( for n being Nat st F1(n) = 0 holds
k <= n ) )
provided
A1: for k being Nat holds
( F1((k + 1)) < F1(k) or F1(k) = 0 )
proof end;

definition
let D be set ;
let f be Function of NAT,D;
let n be Nat;
:: original: .
redefine func f . n -> Element of D;
coherence
f . n is Element of D
proof end;
end;

definition
let X be set ;
mode sequence of X is Function of NAT,X;
end;

definition
let X be non empty set ;
let s be sequence of X;
let k be Nat;
func s ^\ k -> sequence of X means :Def3: :: NAT_1:def 3
for n being Nat holds it . n = s . (n + k);
existence
ex b1 being sequence of X st
for n being Nat holds b1 . n = s . (n + k)
proof end;
uniqueness
for b1, b2 being sequence of X st ( for n being Nat holds b1 . n = s . (n + k) ) & ( for n being Nat holds b2 . n = s . (n + k) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def3 defines ^\ NAT_1:def 3 :
for X being non empty set
for s being sequence of X
for k being Nat
for b4 being sequence of X holds
( b4 = s ^\ k iff for n being Nat holds b4 . n = s . (n + k) );

theorem :: NAT_1:48
for X being non empty set
for s being sequence of X holds s ^\ 0 = s
proof end;

theorem Th49: :: NAT_1:49
for X being non empty set
for s being sequence of X
for k, m being Nat holds (s ^\ k) ^\ m = s ^\ (k + m)
proof end;

theorem :: NAT_1:50
for X being non empty set
for s being sequence of X
for k, m being Nat holds (s ^\ k) ^\ m = (s ^\ m) ^\ k
proof end;

theorem :: NAT_1:51
for X being non empty set
for s being sequence of X
for k being Nat
for N being sequence of NAT holds (s * N) ^\ k = s * (N ^\ k)
proof end;

theorem :: NAT_1:52
for n being Nat
for X being non empty set
for s being sequence of X holds s . n in rng s
proof end;

theorem :: NAT_1:53
for Y being set
for X being non empty set
for s being sequence of X st ( for n being Nat holds s . n in Y ) holds
rng s c= Y
proof end;

theorem :: NAT_1:54
for n being natural number holds
( n is empty or n = 1 or n > 1 )
proof end;

theorem :: NAT_1:55
for n being Nat holds succ n = { l where l is Element of NAT : l <= n }
proof end;

scheme :: NAT_1:sch 18
MinPred{ F1( Element of NAT ) -> Element of NAT , P1[ set ] } :
ex k being Element of NAT st
( P1[k] & ( for n being Element of NAT st P1[n] holds
k <= n ) )
provided
A1: for k being Element of NAT holds
( F1((k + 1)) < F1(k) or P1[k] )
proof end;

registration
let k be Ordinal;
let x be set ;
cluster k --> x -> T-Sequence-like ;
coherence
k --> x is T-Sequence-like
proof end;
end;