:: Factorial and Newton coefficients
:: by Rafa{\l} Kwiatek
::
:: Received July 27, 1990
:: Copyright (c) 1990 Association of Mizar Users


begin

theorem :: NEWTON:1
canceled;

theorem :: NEWTON:2
canceled;

theorem :: NEWTON:3
canceled;

theorem :: NEWTON:4
canceled;

Th3: for F, G being FinSequence st len F = len G & ( for i being Nat st i in dom F holds
F . i = G . i ) holds
F = G
by FINSEQ_2:10;

theorem Th5: :: NEWTON:5
for n being Nat st n >= 1 holds
Seg n = ({1} \/ { k where k is Element of NAT : ( 1 < k & k < n ) } ) \/ {n}
proof end;

theorem Th6: :: NEWTON:6
for a being real number
for F being FinSequence of REAL holds len (a * F) = len F
proof end;

theorem Th7: :: NEWTON:7
for a being real number
for G being FinSequence of REAL holds dom G = dom (a * G) by VALUED_1:def 5;

definition
let i be Nat;
let x be real number ;
:: original: |->
redefine func i |-> x -> FinSequence of REAL ;
coherence
i |-> x is FinSequence of REAL
proof end;
end;

registration
let x be complex number ;
let n be Nat;
cluster n |-> x -> complex-yielding ;
coherence
n |-> x is complex-yielding
;
end;

definition
let x be complex number ;
let n be Nat;
func x |^ n -> set equals :: NEWTON:def 1
Product (n |-> x);
coherence
Product (n |-> x) is set
;
end;

:: deftheorem defines |^ NEWTON:def 1 :
for x being complex number
for n being Nat holds x |^ n = Product (n |-> x);

registration
let x be real number ;
let n be Nat;
cluster x |^ n -> real ;
coherence
x |^ n is real
;
end;

definition
let x be Real;
let n be Nat;
:: original: |^
redefine func x |^ n -> Real;
coherence
x |^ n is Real
by XREAL_0:def 1;
end;

theorem :: NEWTON:8
canceled;

registration
let z be complex number ;
let n be Nat;
cluster z |^ n -> complex ;
coherence
z |^ n is complex
;
end;

theorem :: NEWTON:9
for z being complex number holds z |^ 0 = 1 by RVSUM_1:124;

theorem Th10: :: NEWTON:10
for z being complex number holds z |^ 1 = z
proof end;

theorem Th11: :: NEWTON:11
for s being Nat
for z being complex number holds z |^ (s + 1) = (z |^ s) * z
proof end;

registration
let x, n be Nat;
cluster x |^ n -> natural ;
coherence
x |^ n is natural
proof end;
end;

theorem :: NEWTON:12
for s being Nat
for x, y being complex number holds (x * y) |^ s = (x |^ s) * (y |^ s)
proof end;

theorem Th13: :: NEWTON:13
for s, t being Nat
for x being complex number holds x |^ (s + t) = (x |^ s) * (x |^ t)
proof end;

theorem :: NEWTON:14
for s, t being Nat
for x being complex number holds (x |^ s) |^ t = x |^ (s * t)
proof end;

theorem Th15: :: NEWTON:15
for s being Nat holds 1 |^ s = 1
proof end;

theorem Th16: :: NEWTON:16
for s being Nat st s >= 1 holds
0 |^ s = 0
proof end;

definition
let n be Nat;
:: original: idseq
redefine func idseq n -> FinSequence of REAL ;
coherence
idseq n is FinSequence of REAL
proof end;
end;

definition
let n be Nat;
func n ! -> Real equals :: NEWTON:def 2
Product (idseq n);
coherence
Product (idseq n) is Real
;
end;

:: deftheorem defines ! NEWTON:def 2 :
for n being Nat holds n ! = Product (idseq n);

registration
let n be Nat;
cluster n ! -> real ;
coherence
n ! is real
;
end;

theorem :: NEWTON:17
canceled;

theorem Th18: :: NEWTON:18
0 ! = 1 by RVSUM_1:124;

theorem :: NEWTON:19
1 ! = 1 by FINSEQ_2:59, RVSUM_1:125;

theorem :: NEWTON:20
2 ! = 2
proof end;

theorem Th21: :: NEWTON:21
for s being Nat holds (s + 1) ! = (s !) * (s + 1)
proof end;

theorem Th22: :: NEWTON:22
for s being Nat holds s ! is Element of NAT
proof end;

theorem Th23: :: NEWTON:23
for s being Nat holds s ! > 0
proof end;

registration
let n be Nat;
cluster n ! -> positive ;
coherence
n ! is positive
by Th23;
end;

theorem :: NEWTON:24
canceled;

theorem :: NEWTON:25
for s, t being Nat holds (s !) * (t !) <> 0 ;

definition
let k, n be Nat;
func n choose k -> set means :Def3: :: NEWTON:def 3
for l being Nat st l = n - k holds
it = (n !) / ((k !) * (l !)) if n >= k
otherwise it = 0 ;
consistency
for b1 being set holds verum
;
existence
( ( n >= k implies ex b1 being set st
for l being Nat st l = n - k holds
b1 = (n !) / ((k !) * (l !)) ) & ( not n >= k implies ex b1 being set st b1 = 0 ) )
proof end;
uniqueness
for b1, b2 being set holds
( ( n >= k & ( for l being Nat st l = n - k holds
b1 = (n !) / ((k !) * (l !)) ) & ( for l being Nat st l = n - k holds
b2 = (n !) / ((k !) * (l !)) ) implies b1 = b2 ) & ( not n >= k & b1 = 0 & b2 = 0 implies b1 = b2 ) )
proof end;
end;

:: deftheorem Def3 defines choose NEWTON:def 3 :
for k, n being Nat
for b3 being set holds
( ( n >= k implies ( b3 = n choose k iff for l being Nat st l = n - k holds
b3 = (n !) / ((k !) * (l !)) ) ) & ( not n >= k implies ( b3 = n choose k iff b3 = 0 ) ) );

registration
let k, n be Nat;
cluster n choose k -> real ;
coherence
n choose k is real
proof end;
end;

definition
let k, n be Nat;
:: original: choose
redefine func n choose k -> Real;
coherence
n choose k is Real
by XREAL_0:def 1;
end;

theorem :: NEWTON:26
canceled;

theorem :: NEWTON:27
canceled;

theorem :: NEWTON:28
canceled;

theorem Th29: :: NEWTON:29
for s being Nat holds s choose 0 = 1
proof end;

theorem Th30: :: NEWTON:30
for s, t, r being Nat st s >= t & r = s - t holds
s choose t = s choose r
proof end;

theorem Th31: :: NEWTON:31
for s being Nat holds s choose s = 1
proof end;

theorem Th32: :: NEWTON:32
for t, s being Nat holds (t + 1) choose (s + 1) = (t choose (s + 1)) + (t choose s)
proof end;

theorem Th33: :: NEWTON:33
for s being Nat st s >= 1 holds
s choose 1 = s
proof end;

theorem :: NEWTON:34
for s, t being Nat st s >= 1 & t = s - 1 holds
s choose t = s
proof end;

theorem Th35: :: NEWTON:35
for s, r being Nat holds s choose r is Element of NAT
proof end;

theorem :: NEWTON:36
for n, m being Nat
for F being FinSequence of REAL st m <> 0 & len F = m & ( for i, l being Nat st i in dom F & l = (n + i) - 1 holds
F . i = l choose n ) holds
Sum F = (n + m) choose (n + 1)
proof end;

registration
let k, n be Nat;
cluster n choose k -> natural ;
coherence
n choose k is natural
by Th35;
end;

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

definition
let a, b be real number ;
let n be Nat;
func (a,b) In_Power n -> FinSequence of REAL means :Def4: :: NEWTON:def 4
( len it = n + 1 & ( for i, l, m being Nat st i in dom it & m = i - 1 & l = n - m holds
it . i = ((n choose m) * (a |^ l)) * (b |^ m) ) );
existence
ex b1 being FinSequence of REAL st
( len b1 = n + 1 & ( for i, l, m being Nat st i in dom b1 & m = i - 1 & l = n - m holds
b1 . i = ((n choose m) * (a |^ l)) * (b |^ m) ) )
proof end;
uniqueness
for b1, b2 being FinSequence of REAL st len b1 = n + 1 & ( for i, l, m being Nat st i in dom b1 & m = i - 1 & l = n - m holds
b1 . i = ((n choose m) * (a |^ l)) * (b |^ m) ) & len b2 = n + 1 & ( for i, l, m being Nat st i in dom b2 & m = i - 1 & l = n - m holds
b2 . i = ((n choose m) * (a |^ l)) * (b |^ m) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def4 defines In_Power NEWTON:def 4 :
for a, b being real number
for n being Nat
for b4 being FinSequence of REAL holds
( b4 = (a,b) In_Power n iff ( len b4 = n + 1 & ( for i, l, m being Nat st i in dom b4 & m = i - 1 & l = n - m holds
b4 . i = ((n choose m) * (a |^ l)) * (b |^ m) ) ) );

theorem :: NEWTON:37
canceled;

theorem Th38: :: NEWTON:38
for a, b being real number holds (a,b) In_Power 0 = <*1*>
proof end;

theorem Th39: :: NEWTON:39
for s being Nat
for a, b being real number holds ((a,b) In_Power s) . 1 = a |^ s
proof end;

theorem Th40: :: NEWTON:40
for s being Nat
for a, b being real number holds ((a,b) In_Power s) . (s + 1) = b |^ s
proof end;

theorem Th41: :: NEWTON:41
for s being Nat
for a, b being real number holds (a + b) |^ s = Sum ((a,b) In_Power s)
proof end;

definition
let n be Nat;
func Newton_Coeff n -> FinSequence of REAL means :Def5: :: NEWTON:def 5
( len it = n + 1 & ( for i, k being Nat st i in dom it & k = i - 1 holds
it . i = n choose k ) );
existence
ex b1 being FinSequence of REAL st
( len b1 = n + 1 & ( for i, k being Nat st i in dom b1 & k = i - 1 holds
b1 . i = n choose k ) )
proof end;
uniqueness
for b1, b2 being FinSequence of REAL st len b1 = n + 1 & ( for i, k being Nat st i in dom b1 & k = i - 1 holds
b1 . i = n choose k ) & len b2 = n + 1 & ( for i, k being Nat st i in dom b2 & k = i - 1 holds
b2 . i = n choose k ) holds
b1 = b2
proof end;
end;

:: deftheorem Def5 defines Newton_Coeff NEWTON:def 5 :
for n being Nat
for b2 being FinSequence of REAL holds
( b2 = Newton_Coeff n iff ( len b2 = n + 1 & ( for i, k being Nat st i in dom b2 & k = i - 1 holds
b2 . i = n choose k ) ) );

theorem :: NEWTON:42
canceled;

theorem Th43: :: NEWTON:43
for s being Nat holds Newton_Coeff s = (1,1) In_Power s
proof end;

theorem :: NEWTON:44
for s being Nat holds 2 |^ s = Sum (Newton_Coeff s)
proof end;

begin

theorem Th45: :: NEWTON:45
for l, k being Nat st l >= 1 holds
k * l >= k
proof end;

theorem Th46: :: NEWTON:46
for l, n, k being Nat st l >= 1 & n >= k * l holds
n >= k
proof end;

definition
let n be Nat;
:: original: !
redefine func n ! -> Element of NAT ;
coherence
n ! is Element of NAT
by Th22;
end;

theorem Th47: :: NEWTON:47
for l being Nat st l <> 0 holds
l divides l !
proof end;

theorem :: NEWTON:48
for n being Nat st n <> 0 holds
(n + 1) / n > 1
proof end;

theorem Th49: :: NEWTON:49
for k being Nat holds k / (k + 1) < 1
proof end;

theorem Th50: :: NEWTON:50
for l being Nat holds l ! >= l
proof end;

theorem Th51: :: NEWTON:51
for m, n being Nat st m <> 1 & m divides n holds
not m divides n + 1
proof end;

theorem :: NEWTON:52
canceled;

theorem Th53: :: NEWTON:53
for j, k being Nat st j <> 0 holds
j divides (j + k) !
proof end;

theorem Th54: :: NEWTON:54
for j, l being Nat st j <= l & j <> 0 holds
j divides l !
proof end;

theorem :: NEWTON:55
for j, l being Nat st j <> 1 & j <> 0 & j divides (l !) + 1 holds
j > l by Th51, Th54;

theorem :: NEWTON:56
for m, n, k being Nat holds m lcm (n lcm k) = (m lcm n) lcm k
proof end;

theorem Th57: :: NEWTON:57
for m, n being Nat holds
( m divides n iff m lcm n = n )
proof end;

theorem :: NEWTON:58
for n, m, k being Nat holds
( ( n divides m & k divides m ) iff n lcm k divides m )
proof end;

theorem :: NEWTON:59
for m being Nat holds m lcm 1 = m
proof end;

theorem Th60: :: NEWTON:60
for m, n being Nat holds m lcm n divides m * n
proof end;

theorem :: NEWTON:61
for m, n, k being Nat holds m gcd (n gcd k) = (m gcd n) gcd k
proof end;

theorem Th62: :: NEWTON:62
for n, m being Nat st n divides m holds
n gcd m = n
proof end;

theorem :: NEWTON:63
for m, n, k being Nat holds
( ( m divides n & m divides k ) iff m divides n gcd k )
proof end;

theorem :: NEWTON:64
for m being Nat holds m gcd 1 = 1
proof end;

theorem :: NEWTON:65
for m being Nat holds m gcd 0 = m
proof end;

theorem Th66: :: NEWTON:66
for m, n being Nat holds (m gcd n) lcm n = n
proof end;

theorem Th67: :: NEWTON:67
for m, n being Nat holds m gcd (m lcm n) = m
proof end;

theorem :: NEWTON:68
for m, n being Nat holds m gcd (m lcm n) = (n gcd m) lcm m
proof end;

theorem :: NEWTON:69
for m, n, k being Nat st m divides n holds
m gcd k divides n gcd k
proof end;

theorem :: NEWTON:70
for m, n, k being Nat st m divides n holds
k gcd m divides k gcd n
proof end;

theorem Th71: :: NEWTON:71
for n, m being Nat st n > 0 holds
n gcd m > 0
proof end;

theorem :: NEWTON:72
canceled;

theorem :: NEWTON:73
for m, n being Nat st m > 0 & n > 0 holds
m lcm n > 0
proof end;

theorem :: NEWTON:74
for n, m, k being Nat holds (n gcd m) lcm (n gcd k) divides n gcd (m lcm k)
proof end;

theorem :: NEWTON:75
for m, l, n being Nat st m divides l holds
m lcm (n gcd l) divides (m lcm n) gcd l
proof end;

theorem :: NEWTON:76
for n, m being Nat holds n gcd m divides n lcm m
proof end;

theorem :: NEWTON:77
for m, n being Nat st 0 < m holds
n mod m = n - (m * (n div m))
proof end;

theorem :: NEWTON:78
for i2, i1 being Integer st i2 >= 0 holds
i1 mod i2 >= 0 by INT_1:84;

theorem :: NEWTON:79
for i2, i1 being Integer st i2 > 0 holds
i1 mod i2 < i2 by INT_1:85;

theorem :: NEWTON:80
for i2, i1 being Integer st i2 <> 0 holds
i1 = ((i1 div i2) * i2) + (i1 mod i2) by INT_1:86;

theorem :: NEWTON:81
for m, n being Nat st ( m > 0 or n > 0 ) holds
ex i, i1 being Integer st (i * m) + (i1 * n) = m gcd n
proof end;

definition
func SetPrimes -> Subset of NAT means :Def6: :: NEWTON:def 6
for n being Nat holds
( n in it iff n is prime );
existence
ex b1 being Subset of NAT st
for n being Nat holds
( n in b1 iff n is prime )
proof end;
uniqueness
for b1, b2 being Subset of NAT st ( for n being Nat holds
( n in b1 iff n is prime ) ) & ( for n being Nat holds
( n in b2 iff n is prime ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def6 defines SetPrimes NEWTON:def 6 :
for b1 being Subset of NAT holds
( b1 = SetPrimes iff for n being Nat holds
( n in b1 iff n is prime ) );

registration
cluster epsilon-transitive epsilon-connected ordinal natural complex real ext-real non negative integer prime V32() finite cardinal V59() V60() V61() V62() V63() V64() Element of NAT ;
existence
ex b1 being Element of NAT st b1 is prime
by INT_2:44;
cluster epsilon-transitive epsilon-connected ordinal natural complex real ext-real non negative integer prime finite cardinal set ;
existence
ex b1 being Nat st b1 is prime
by INT_2:44;
end;

definition
mode Prime is prime Nat;
end;

definition
let p be Nat;
func SetPrimenumber p -> Subset of NAT means :Def7: :: NEWTON:def 7
for q being Nat holds
( q in it iff ( q < p & q is prime ) );
existence
ex b1 being Subset of NAT st
for q being Nat holds
( q in b1 iff ( q < p & q is prime ) )
proof end;
uniqueness
for b1, b2 being Subset of NAT st ( for q being Nat holds
( q in b1 iff ( q < p & q is prime ) ) ) & ( for q being Nat holds
( q in b2 iff ( q < p & q is prime ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def7 defines SetPrimenumber NEWTON:def 7 :
for p being Nat
for b2 being Subset of NAT holds
( b2 = SetPrimenumber p iff for q being Nat holds
( q in b2 iff ( q < p & q is prime ) ) );

theorem Th82: :: NEWTON:82
for p being Nat holds SetPrimenumber p c= SetPrimes
proof end;

theorem :: NEWTON:83
for p, q being Nat st p <= q holds
SetPrimenumber p c= SetPrimenumber q
proof end;

theorem Th84: :: NEWTON:84
for p being Nat holds SetPrimenumber p c= Seg p
proof end;

theorem Th85: :: NEWTON:85
for p being Nat holds SetPrimenumber p is finite
proof end;

registration
let n be Nat;
cluster SetPrimenumber n -> finite ;
coherence
SetPrimenumber n is finite
by Th85;
end;

theorem Th86: :: NEWTON:86
for l being Nat ex p being Prime st
( p is prime & p > l )
proof end;

theorem :: NEWTON:87
canceled;

theorem :: NEWTON:88
canceled;

theorem :: NEWTON:89
canceled;

Th88: SetPrimenumber 2 = {}
proof end;

registration
cluster SetPrimes -> non empty ;
coherence
not SetPrimes is empty
by Def6, INT_2:44;
end;

registration
cluster SetPrimenumber 2 -> empty ;
coherence
SetPrimenumber 2 is empty
by Th88;
end;

theorem :: NEWTON:90
for m being Nat holds SetPrimenumber m c= Seg m
proof end;

theorem :: NEWTON:91
canceled;

theorem :: NEWTON:92
for k, m being Nat st k >= m holds
not k in SetPrimenumber m by Def7;

theorem :: NEWTON:93
for n being Nat holds (SetPrimenumber n) \/ {n} is finite ;

theorem Th94: :: NEWTON:94
for f being Prime
for g being Nat st f < g holds
(SetPrimenumber f) \/ {f} c= SetPrimenumber g
proof end;

theorem :: NEWTON:95
for k, m being Nat st k >= m holds
not k in SetPrimenumber m by Def7;

Lm1: for n being Nat holds SetPrimenumber n = { k where k is Element of NAT : ( k < n & k is prime ) }
proof end;

definition
let n be Nat;
func primenumber n -> prime Element of NAT means :Def8: :: NEWTON:def 8
n = card (SetPrimenumber it);
existence
ex b1 being prime Element of NAT st n = card (SetPrimenumber b1)
proof end;
uniqueness
for b1, b2 being prime Element of NAT st n = card (SetPrimenumber b1) & n = card (SetPrimenumber b2) holds
b1 = b2
proof end;
end;

:: deftheorem Def8 defines primenumber NEWTON:def 8 :
for n being Nat
for b2 being prime Element of NAT holds
( b2 = primenumber n iff n = card (SetPrimenumber b2) );

theorem :: NEWTON:96
for n being Nat holds SetPrimenumber n = { k where k is Element of NAT : ( k < n & k is prime ) } by Lm1;

theorem Th97: :: NEWTON:97
not SetPrimes is finite
proof end;

registration
cluster SetPrimes -> non empty infinite ;
coherence
( not SetPrimes is empty & not SetPrimes is finite )
by Th97;
end;

theorem :: NEWTON:98
for i being Nat st i is prime holds
for m, n being Nat holds
( not i divides m * n or i divides m or i divides n )
proof end;

theorem :: NEWTON:99
canceled;

theorem :: NEWTON:100
for x being complex number holds
( x |^ 2 = x * x & x ^2 = x |^ 2 )
proof end;

theorem :: NEWTON:101
for m, n being Nat holds
( m div n = m div n & m mod n = m mod n ) ;

theorem :: NEWTON:102
for k being Nat
for x being real number st x > 0 holds
x |^ k > 0
proof end;

theorem :: NEWTON:103
for n being Nat st n > 0 holds
0 |^ n = 0
proof end;

definition
let m, n be Element of NAT ;
:: original: |^
redefine func m |^ n -> Element of NAT ;
coherence
m |^ n is Element of NAT
by ORDINAL1:def 13;
end;

defpred S1[ Nat] means 2 |^ $1 >= $1 + 1;

Lm2: S1[ 0 ]
by RVSUM_1:124;

Lm3: for n being Nat st S1[n] holds
S1[n + 1]
proof end;

theorem Th104: :: NEWTON:104
for n being Nat holds 2 |^ n >= n + 1
proof end;

theorem :: NEWTON:105
for n being Nat holds 2 |^ n > n
proof end;

scheme :: NEWTON:sch 1
Euklides9{ F1( Nat) -> Element of NAT , F2( Nat) -> Element of NAT , F3() -> Element of NAT , F4() -> Element of NAT } :
ex k being Element of NAT st
( F1(k) = F3() gcd F4() & F2(k) = 0 )
provided
A1: 0 < F4() and
A2: F4() < F3() and
A3: F1(0) = F3() and
A4: F2(0) = F4() and
A5: for k being Element of NAT st F2(k) > 0 holds
( F1((k + 1)) = F2(k) & F2((k + 1)) = F1(k) mod F2(k) )
proof end;

theorem Th106: :: NEWTON:106
for r being Nat
for n being natural number holds
( ( r <> 0 or n = 0 ) iff r |^ n <> 0 )
proof end;

Lm4: for n1, m1, n2, m2 being natural number st (2 |^ n1) * ((2 * m1) + 1) = (2 |^ n2) * ((2 * m2) + 1) holds
n1 <= n2
proof end;

theorem :: NEWTON:107
for n1, m1, n2, m2 being natural number st (2 |^ n1) * ((2 * m1) + 1) = (2 |^ n2) * ((2 * m2) + 1) holds
( n1 = n2 & m1 = m2 )
proof end;