:: RFINSEQ2 semantic presentation

definition
let c1 be FinSequence of REAL ;
func max_p c1 -> Nat means :Def1: :: RFINSEQ2:def 1
( ( len a1 = 0 implies a2 = 0 ) & ( len a1 > 0 implies ( a2 in dom a1 & ( for b1 being Nat
for b2, b3 being Real st b1 in dom a1 & b2 = a1 . b1 & b3 = a1 . a2 holds
b2 <= b3 ) & ( for b1 being Nat st b1 in dom a1 & a1 . b1 = a1 . a2 holds
a2 <= b1 ) ) ) );
existence
ex b1 being Nat st
( ( len c1 = 0 implies b1 = 0 ) & ( len c1 > 0 implies ( b1 in dom c1 & ( for b2 being Nat
for b3, b4 being Real st b2 in dom c1 & b3 = c1 . b2 & b4 = c1 . b1 holds
b3 <= b4 ) & ( for b2 being Nat st b2 in dom c1 & c1 . b2 = c1 . b1 holds
b1 <= b2 ) ) ) )
proof end;
uniqueness
for b1, b2 being Nat st ( len c1 = 0 implies b1 = 0 ) & ( len c1 > 0 implies ( b1 in dom c1 & ( for b3 being Nat
for b4, b5 being Real st b3 in dom c1 & b4 = c1 . b3 & b5 = c1 . b1 holds
b4 <= b5 ) & ( for b3 being Nat st b3 in dom c1 & c1 . b3 = c1 . b1 holds
b1 <= b3 ) ) ) & ( len c1 = 0 implies b2 = 0 ) & ( len c1 > 0 implies ( b2 in dom c1 & ( for b3 being Nat
for b4, b5 being Real st b3 in dom c1 & b4 = c1 . b3 & b5 = c1 . b2 holds
b4 <= b5 ) & ( for b3 being Nat st b3 in dom c1 & c1 . b3 = c1 . b2 holds
b2 <= b3 ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def1 defines max_p RFINSEQ2:def 1 :
for b1 being FinSequence of REAL
for b2 being Nat holds
( b2 = max_p b1 iff ( ( len b1 = 0 implies b2 = 0 ) & ( len b1 > 0 implies ( b2 in dom b1 & ( for b3 being Nat
for b4, b5 being Real st b3 in dom b1 & b4 = b1 . b3 & b5 = b1 . b2 holds
b4 <= b5 ) & ( for b3 being Nat st b3 in dom b1 & b1 . b3 = b1 . b2 holds
b2 <= b3 ) ) ) ) );

definition
let c1 be FinSequence of REAL ;
func min_p c1 -> Nat means :Def2: :: RFINSEQ2:def 2
( ( len a1 = 0 implies a2 = 0 ) & ( len a1 > 0 implies ( a2 in dom a1 & ( for b1 being Nat
for b2, b3 being Real st b1 in dom a1 & b2 = a1 . b1 & b3 = a1 . a2 holds
b2 >= b3 ) & ( for b1 being Nat st b1 in dom a1 & a1 . b1 = a1 . a2 holds
a2 <= b1 ) ) ) );
existence
ex b1 being Nat st
( ( len c1 = 0 implies b1 = 0 ) & ( len c1 > 0 implies ( b1 in dom c1 & ( for b2 being Nat
for b3, b4 being Real st b2 in dom c1 & b3 = c1 . b2 & b4 = c1 . b1 holds
b3 >= b4 ) & ( for b2 being Nat st b2 in dom c1 & c1 . b2 = c1 . b1 holds
b1 <= b2 ) ) ) )
proof end;
uniqueness
for b1, b2 being Nat st ( len c1 = 0 implies b1 = 0 ) & ( len c1 > 0 implies ( b1 in dom c1 & ( for b3 being Nat
for b4, b5 being Real st b3 in dom c1 & b4 = c1 . b3 & b5 = c1 . b1 holds
b4 >= b5 ) & ( for b3 being Nat st b3 in dom c1 & c1 . b3 = c1 . b1 holds
b1 <= b3 ) ) ) & ( len c1 = 0 implies b2 = 0 ) & ( len c1 > 0 implies ( b2 in dom c1 & ( for b3 being Nat
for b4, b5 being Real st b3 in dom c1 & b4 = c1 . b3 & b5 = c1 . b2 holds
b4 >= b5 ) & ( for b3 being Nat st b3 in dom c1 & c1 . b3 = c1 . b2 holds
b2 <= b3 ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def2 defines min_p RFINSEQ2:def 2 :
for b1 being FinSequence of REAL
for b2 being Nat holds
( b2 = min_p b1 iff ( ( len b1 = 0 implies b2 = 0 ) & ( len b1 > 0 implies ( b2 in dom b1 & ( for b3 being Nat
for b4, b5 being Real st b3 in dom b1 & b4 = b1 . b3 & b5 = b1 . b2 holds
b4 >= b5 ) & ( for b3 being Nat st b3 in dom b1 & b1 . b3 = b1 . b2 holds
b2 <= b3 ) ) ) ) );

definition
let c1 be FinSequence of REAL ;
func max c1 -> Real equals :: RFINSEQ2:def 3
a1 . (max_p a1);
correctness
coherence
c1 . (max_p c1) is Real
;
;
func min c1 -> Real equals :: RFINSEQ2:def 4
a1 . (min_p a1);
correctness
coherence
c1 . (min_p c1) is Real
;
;
end;

:: deftheorem Def3 defines max RFINSEQ2:def 3 :
for b1 being FinSequence of REAL holds max b1 = b1 . (max_p b1);

:: deftheorem Def4 defines min RFINSEQ2:def 4 :
for b1 being FinSequence of REAL holds min b1 = b1 . (min_p b1);

theorem Th1: :: RFINSEQ2:1
for b1 being FinSequence of REAL
for b2 being Nat st 1 <= b2 & b2 <= len b1 holds
( b1 . b2 <= b1 . (max_p b1) & b1 . b2 <= max b1 )
proof end;

theorem Th2: :: RFINSEQ2:2
for b1 being FinSequence of REAL
for b2 being Nat st 1 <= b2 & b2 <= len b1 holds
( b1 . b2 >= b1 . (min_p b1) & b1 . b2 >= min b1 )
proof end;

theorem Th3: :: RFINSEQ2:3
for b1 being FinSequence of REAL
for b2 being Real st b1 = <*b2*> holds
( max_p b1 = 1 & max b1 = b2 )
proof end;

theorem Th4: :: RFINSEQ2:4
for b1 being FinSequence of REAL
for b2 being Real st b1 = <*b2*> holds
( min_p b1 = 1 & min b1 = b2 )
proof end;

theorem Th5: :: RFINSEQ2:5
for b1 being FinSequence of REAL
for b2, b3 being Real st b1 = <*b2,b3*> holds
( max b1 = max b2,b3 & max_p b1 = IFEQ b2,(max b2,b3),1,2 )
proof end;

theorem Th6: :: RFINSEQ2:6
for b1 being FinSequence of REAL
for b2, b3 being Real st b1 = <*b2,b3*> holds
( min b1 = min b2,b3 & min_p b1 = IFEQ b2,(min b2,b3),1,2 )
proof end;

theorem Th7: :: RFINSEQ2:7
for b1, b2 being FinSequence of REAL st len b1 = len b2 & len b1 > 0 holds
max (b1 + b2) <= (max b1) + (max b2)
proof end;

theorem Th8: :: RFINSEQ2:8
for b1, b2 being FinSequence of REAL st len b1 = len b2 & len b1 > 0 holds
min (b1 + b2) >= (min b1) + (min b2)
proof end;

theorem Th9: :: RFINSEQ2:9
for b1 being FinSequence of REAL
for b2 being Real st len b1 > 0 & b2 > 0 holds
( max (b2 * b1) = b2 * (max b1) & max_p (b2 * b1) = max_p b1 )
proof end;

theorem Th10: :: RFINSEQ2:10
for b1 being FinSequence of REAL
for b2 being Real st len b1 > 0 & b2 > 0 holds
( min (b2 * b1) = b2 * (min b1) & min_p (b2 * b1) = min_p b1 )
proof end;

theorem Th11: :: RFINSEQ2:11
for b1 being FinSequence of REAL st len b1 > 0 holds
( max (- b1) = - (min b1) & max_p (- b1) = min_p b1 )
proof end;

theorem Th12: :: RFINSEQ2:12
for b1 being FinSequence of REAL st len b1 > 0 holds
( min (- b1) = - (max b1) & min_p (- b1) = max_p b1 )
proof end;

theorem Th13: :: RFINSEQ2:13
for b1 being FinSequence of REAL
for b2 being Nat st 1 <= b2 & b2 < len b1 holds
( max (b1 /^ b2) <= max b1 & min (b1 /^ b2) >= min b1 )
proof end;

Lemma5: for b1, b2 being FinSequence of REAL st b1,b2 are_fiberwise_equipotent holds
max b1 <= max b2
proof end;

theorem Th14: :: RFINSEQ2:14
for b1, b2 being FinSequence of REAL st b1,b2 are_fiberwise_equipotent holds
max b1 = max b2
proof end;

Lemma7: for b1, b2 being FinSequence of REAL st b1,b2 are_fiberwise_equipotent holds
min b1 >= min b2
proof end;

theorem Th15: :: RFINSEQ2:15
for b1, b2 being FinSequence of REAL st b1,b2 are_fiberwise_equipotent holds
min b1 = min b2
proof end;

definition
let c1 be FinSequence of REAL ;
func sort_d c1 -> non-increasing FinSequence of REAL means :Def5: :: RFINSEQ2:def 5
a1,a2 are_fiberwise_equipotent ;
existence
ex b1 being non-increasing FinSequence of REAL st c1,b1 are_fiberwise_equipotent
by RFINSEQ:35;
uniqueness
for b1, b2 being non-increasing FinSequence of REAL st c1,b1 are_fiberwise_equipotent & c1,b2 are_fiberwise_equipotent holds
b1 = b2
proof end;
end;

:: deftheorem Def5 defines sort_d RFINSEQ2:def 5 :
for b1 being FinSequence of REAL
for b2 being non-increasing FinSequence of REAL holds
( b2 = sort_d b1 iff b1,b2 are_fiberwise_equipotent );

theorem Th16: :: RFINSEQ2:16
for b1 being FinSequence of REAL st ( len b1 = 0 or len b1 = 1 ) holds
b1 is non-decreasing
proof end;

theorem Th17: :: RFINSEQ2:17
for b1 being FinSequence of REAL holds
( b1 is non-decreasing iff for b2, b3 being Nat st b2 in dom b1 & b3 in dom b1 & b2 < b3 holds
b1 . b2 <= b1 . b3 )
proof end;

Lemma12: for b1, b2 being non-decreasing FinSequence of REAL
for b3 being Nat st len b1 = b3 + 1 & len b1 = len b2 & b1,b2 are_fiberwise_equipotent holds
( b1 . (len b1) = b2 . (len b2) & b1 | b3,b2 | b3 are_fiberwise_equipotent )
proof end;

theorem Th18: :: RFINSEQ2:18
for b1 being non-decreasing FinSequence of REAL
for b2 being Nat holds b1 | b2 is non-decreasing FinSequence of REAL
proof end;

Lemma14: for b1 being Nat
for b2, b3 being non-decreasing FinSequence of REAL st b1 = len b2 & b2,b3 are_fiberwise_equipotent holds
b2 = b3
proof end;

theorem Th19: :: RFINSEQ2:19
for b1, b2 being non-decreasing FinSequence of REAL st b1,b2 are_fiberwise_equipotent holds
b1 = b2
proof end;

definition
let c1 be FinSequence of REAL ;
func sort_a c1 -> non-decreasing FinSequence of REAL means :Def6: :: RFINSEQ2:def 6
a1,a2 are_fiberwise_equipotent ;
existence
ex b1 being non-decreasing FinSequence of REAL st c1,b1 are_fiberwise_equipotent
by INTEGRA2:3;
uniqueness
for b1, b2 being non-decreasing FinSequence of REAL st c1,b1 are_fiberwise_equipotent & c1,b2 are_fiberwise_equipotent holds
b1 = b2
proof end;
end;

:: deftheorem Def6 defines sort_a RFINSEQ2:def 6 :
for b1 being FinSequence of REAL
for b2 being non-decreasing FinSequence of REAL holds
( b2 = sort_a b1 iff b1,b2 are_fiberwise_equipotent );

theorem Th20: :: RFINSEQ2:20
for b1 being non-increasing FinSequence of REAL holds sort_d b1 = b1 by Def5;

theorem Th21: :: RFINSEQ2:21
for b1 being non-decreasing FinSequence of REAL holds sort_a b1 = b1 by Def6;

theorem Th22: :: RFINSEQ2:22
for b1 being FinSequence of REAL holds sort_d (sort_d b1) = sort_d b1 by Def5;

theorem Th23: :: RFINSEQ2:23
for b1 being FinSequence of REAL holds sort_a (sort_a b1) = sort_a b1 by Def6;

theorem Th24: :: RFINSEQ2:24
for b1 being FinSequence of REAL st b1 is non-increasing holds
- b1 is non-decreasing
proof end;

theorem Th25: :: RFINSEQ2:25
for b1 being FinSequence of REAL st b1 is non-decreasing holds
- b1 is non-increasing
proof end;

theorem Th26: :: RFINSEQ2:26
for b1, b2 being FinSequence of REAL
for b3 being Permutation of dom b2 st b1 = b2 * b3 & len b2 >= 1 holds
- b1 = (- b2) * b3
proof end;

theorem Th27: :: RFINSEQ2:27
for b1, b2 being FinSequence of REAL st b1,b2 are_fiberwise_equipotent holds
- b1, - b2 are_fiberwise_equipotent
proof end;

theorem Th28: :: RFINSEQ2:28
for b1 being FinSequence of REAL holds sort_d (- b1) = - (sort_a b1)
proof end;

theorem Th29: :: RFINSEQ2:29
for b1 being FinSequence of REAL holds sort_a (- b1) = - (sort_d b1)
proof end;

theorem Th30: :: RFINSEQ2:30
for b1 being FinSequence of REAL holds
( dom (sort_d b1) = dom b1 & len (sort_d b1) = len b1 )
proof end;

theorem Th31: :: RFINSEQ2:31
for b1 being FinSequence of REAL holds
( dom (sort_a b1) = dom b1 & len (sort_a b1) = len b1 )
proof end;

theorem Th32: :: RFINSEQ2:32
for b1 being FinSequence of REAL st len b1 >= 1 holds
( max_p (sort_d b1) = 1 & min_p (sort_a b1) = 1 & (sort_d b1) . 1 = max b1 & (sort_a b1) . 1 = min b1 )
proof end;