:: FINSEQ_8 semantic presentation

theorem Th1: :: FINSEQ_8:1
for b1 being set
for b2 being FinSequence of b1 holds b2 | 0 = {}
proof end;

theorem Th2: :: FINSEQ_8:2
for b1 being set
for b2 being FinSequence of b1 holds b2 /^ 0 = b2
proof end;

definition
let c1 be set ;
let c2, c3 be FinSequence of c1;
redefine func ^ as c2 ^ c3 -> FinSequence of a1;
correctness
coherence
c2 ^ c3 is FinSequence of c1
;
proof end;
end;

theorem Th3: :: FINSEQ_8:3
for b1 being non empty set
for b2, b3 being FinSequence of b1 st len b2 >= 1 holds
mid (b2 ^ b3),1,(len b2) = b2
proof end;

theorem Th4: :: FINSEQ_8:4
for b1 being set
for b2 being FinSequence of b1
for b3 being Nat st b3 >= len b2 holds
b2 /^ b3 = <*> b1
proof end;

theorem Th5: :: FINSEQ_8:5
for b1 being non empty set
for b2, b3 being Nat holds mid (<*> b1),b2,b3 = <*> b1
proof end;

definition
let c1 be set ;
let c2 be FinSequence of c1;
let c3, c4 be Nat;
func smid c2,c3,c4 -> FinSequence of a1 equals :: FINSEQ_8:def 1
(a2 /^ (a3 -' 1)) | ((a4 + 1) -' a3);
correctness
coherence
(c2 /^ (c3 -' 1)) | ((c4 + 1) -' c3) is FinSequence of c1
;
;
end;

:: deftheorem Def1 defines smid FINSEQ_8:def 1 :
for b1 being set
for b2 being FinSequence of b1
for b3, b4 being Nat holds smid b2,b3,b4 = (b2 /^ (b3 -' 1)) | ((b4 + 1) -' b3);

theorem Th6: :: FINSEQ_8:6
for b1 being non empty set
for b2 being FinSequence of b1
for b3, b4 being Nat st b3 <= b4 holds
smid b2,b3,b4 = mid b2,b3,b4
proof end;

theorem Th7: :: FINSEQ_8:7
for b1 being non empty set
for b2 being FinSequence of b1
for b3 being Nat holds smid b2,1,b3 = b2 | b3
proof end;

theorem Th8: :: FINSEQ_8:8
for b1 being non empty set
for b2 being FinSequence of b1
for b3 being Nat st len b2 <= b3 holds
smid b2,1,b3 = b2
proof end;

theorem Th9: :: FINSEQ_8:9
for b1 being set
for b2 being FinSequence of b1
for b3, b4 being Nat st b3 > b4 holds
( smid b2,b3,b4 = {} & smid b2,b3,b4 = <*> b1 )
proof end;

theorem Th10: :: FINSEQ_8:10
for b1 being set
for b2 being FinSequence of b1
for b3 being Nat holds smid b2,0,b3 = smid b2,1,(b3 + 1)
proof end;

theorem Th11: :: FINSEQ_8:11
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds smid (b2 ^ b3),((len b2) + 1),((len b2) + (len b3)) = b3
proof end;

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
func ovlpart c2,c3 -> FinSequence of a1 means :Def2: :: FINSEQ_8:def 2
( len a4 <= len a3 & a4 = smid a3,1,(len a4) & a4 = smid a2,(((len a2) -' (len a4)) + 1),(len a2) & ( for b1 being Nat st b1 <= len a3 & smid a3,1,b1 = smid a2,(((len a2) -' b1) + 1),(len a2) holds
b1 <= len a4 ) );
existence
ex b1 being FinSequence of c1 st
( len b1 <= len c3 & b1 = smid c3,1,(len b1) & b1 = smid c2,(((len c2) -' (len b1)) + 1),(len c2) & ( for b2 being Nat st b2 <= len c3 & smid c3,1,b2 = smid c2,(((len c2) -' b2) + 1),(len c2) holds
b2 <= len b1 ) )
proof end;
uniqueness
for b1, b2 being FinSequence of c1 st len b1 <= len c3 & b1 = smid c3,1,(len b1) & b1 = smid c2,(((len c2) -' (len b1)) + 1),(len c2) & ( for b3 being Nat st b3 <= len c3 & smid c3,1,b3 = smid c2,(((len c2) -' b3) + 1),(len c2) holds
b3 <= len b1 ) & len b2 <= len c3 & b2 = smid c3,1,(len b2) & b2 = smid c2,(((len c2) -' (len b2)) + 1),(len c2) & ( for b3 being Nat st b3 <= len c3 & smid c3,1,b3 = smid c2,(((len c2) -' b3) + 1),(len c2) holds
b3 <= len b2 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def2 defines ovlpart FINSEQ_8:def 2 :
for b1 being non empty set
for b2, b3, b4 being FinSequence of b1 holds
( b4 = ovlpart b2,b3 iff ( len b4 <= len b3 & b4 = smid b3,1,(len b4) & b4 = smid b2,(((len b2) -' (len b4)) + 1),(len b2) & ( for b5 being Nat st b5 <= len b3 & smid b3,1,b5 = smid b2,(((len b2) -' b5) + 1),(len b2) holds
b5 <= len b4 ) ) );

theorem Th12: :: FINSEQ_8:12
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds len (ovlpart b2,b3) <= len b2
proof end;

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
func ovlcon c2,c3 -> FinSequence of a1 equals :: FINSEQ_8:def 3
a2 ^ (a3 /^ (len (ovlpart a2,a3)));
correctness
coherence
c2 ^ (c3 /^ (len (ovlpart c2,c3))) is FinSequence of c1
;
;
end;

:: deftheorem Def3 defines ovlcon FINSEQ_8:def 3 :
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds ovlcon b2,b3 = b2 ^ (b3 /^ (len (ovlpart b2,b3)));

theorem Th13: :: FINSEQ_8:13
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds ovlcon b2,b3 = (b2 | ((len b2) -' (len (ovlpart b2,b3)))) ^ b3
proof end;

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
func ovlldiff c2,c3 -> FinSequence of a1 equals :: FINSEQ_8:def 4
a2 | ((len a2) -' (len (ovlpart a2,a3)));
correctness
coherence
c2 | ((len c2) -' (len (ovlpart c2,c3))) is FinSequence of c1
;
;
end;

:: deftheorem Def4 defines ovlldiff FINSEQ_8:def 4 :
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds ovlldiff b2,b3 = b2 | ((len b2) -' (len (ovlpart b2,b3)));

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
func ovlrdiff c2,c3 -> FinSequence of a1 equals :: FINSEQ_8:def 5
a3 /^ (len (ovlpart a2,a3));
correctness
coherence
c3 /^ (len (ovlpart c2,c3)) is FinSequence of c1
;
;
end;

:: deftheorem Def5 defines ovlrdiff FINSEQ_8:def 5 :
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds ovlrdiff b2,b3 = b3 /^ (len (ovlpart b2,b3));

theorem Th14: :: FINSEQ_8:14
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds
( ovlcon b2,b3 = ((ovlldiff b2,b3) ^ (ovlpart b2,b3)) ^ (ovlrdiff b2,b3) & ovlcon b2,b3 = (ovlldiff b2,b3) ^ ((ovlpart b2,b3) ^ (ovlrdiff b2,b3)) )
proof end;

theorem Th15: :: FINSEQ_8:15
for b1 being non empty set
for b2 being FinSequence of b1 holds
( ovlcon b2,b2 = b2 & ovlpart b2,b2 = b2 & ovlldiff b2,b2 = {} & ovlrdiff b2,b2 = {} )
proof end;

theorem Th16: :: FINSEQ_8:16
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds
( ovlpart (b2 ^ b3),b3 = b3 & ovlpart b2,(b2 ^ b3) = b2 )
proof end;

theorem Th17: :: FINSEQ_8:17
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds
( len (ovlcon b2,b3) = ((len b2) + (len b3)) - (len (ovlpart b2,b3)) & len (ovlcon b2,b3) = ((len b2) + (len b3)) -' (len (ovlpart b2,b3)) & len (ovlcon b2,b3) = (len b2) + ((len b3) -' (len (ovlpart b2,b3))) )
proof end;

theorem Th18: :: FINSEQ_8:18
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds
( len (ovlpart b2,b3) <= len b2 & len (ovlpart b2,b3) <= len b3 )
proof end;

definition
let c1 be non empty set ;
let c2 be FinSequence of c1;
pred c2 separates_uniquely means :Def6: :: FINSEQ_8:def 6
for b1 being FinSequence of a1
for b2, b3 being Nat st 1 <= b2 & b2 < b3 & (b3 + (len a2)) -' 1 <= len b1 & smid b1,b2,((b2 + (len a2)) -' 1) = smid b1,b3,((b3 + (len a2)) -' 1) & smid b1,b2,((b2 + (len a2)) -' 1) = a2 holds
b3 -' b2 >= len a2;
end;

:: deftheorem Def6 defines separates_uniquely FINSEQ_8:def 6 :
for b1 being non empty set
for b2 being FinSequence of b1 holds
( b2 separates_uniquely iff for b3 being FinSequence of b1
for b4, b5 being Nat st 1 <= b4 & b4 < b5 & (b5 + (len b2)) -' 1 <= len b3 & smid b3,b4,((b4 + (len b2)) -' 1) = smid b3,b5,((b5 + (len b2)) -' 1) & smid b3,b4,((b4 + (len b2)) -' 1) = b2 holds
b5 -' b4 >= len b2 );

theorem Th19: :: FINSEQ_8:19
for b1 being non empty set
for b2 being FinSequence of b1 holds
( b2 separates_uniquely iff len (ovlpart (b2 /^ 1),b2) = 0 )
proof end;

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
let c4 be Nat;
pred c3 is_substring_of c2,c4 means :Def7: :: FINSEQ_8:def 7
( len a3 > 0 implies ex b1 being Nat st
( a4 <= b1 & b1 <= len a2 & mid a2,b1,((b1 -' 1) + (len a3)) = a3 ) );
correctness
;
end;

:: deftheorem Def7 defines is_substring_of FINSEQ_8:def 7 :
for b1 being non empty set
for b2, b3 being FinSequence of b1
for b4 being Nat holds
( b3 is_substring_of b2,b4 iff ( len b3 > 0 implies ex b5 being Nat st
( b4 <= b5 & b5 <= len b2 & mid b2,b5,((b5 -' 1) + (len b3)) = b3 ) ) );

theorem Th20: :: FINSEQ_8:20
for b1 being non empty set
for b2, b3 being FinSequence of b1
for b4 being Nat st len b3 = 0 holds
b3 is_substring_of b2,b4 by Def7;

theorem Th21: :: FINSEQ_8:21
for b1 being non empty set
for b2, b3 being FinSequence of b1
for b4, b5 being Nat st b5 >= b4 & b3 is_substring_of b2,b5 holds
b3 is_substring_of b2,b4
proof end;

theorem Th22: :: FINSEQ_8:22
for b1 being non empty set
for b2 being FinSequence of b1 st 1 <= len b2 holds
b2 is_substring_of b2,1
proof end;

theorem Th23: :: FINSEQ_8:23
for b1 being non empty set
for b2, b3 being FinSequence of b1 st b3 is_substring_of b2,0 holds
b3 is_substring_of b2,1
proof end;

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
pred c3 is_preposition_of c2 means :Def8: :: FINSEQ_8:def 8
( len a3 > 0 implies ( 1 <= len a2 & mid a2,1,(len a3) = a3 ) );
correctness
;
end;

:: deftheorem Def8 defines is_preposition_of FINSEQ_8:def 8 :
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds
( b3 is_preposition_of b2 iff ( len b3 > 0 implies ( 1 <= len b2 & mid b2,1,(len b3) = b3 ) ) );

theorem Th24: :: FINSEQ_8:24
for b1 being non empty set
for b2, b3 being FinSequence of b1 st len b3 = 0 holds
b3 is_preposition_of b2 by Def8;

theorem Th25: :: FINSEQ_8:25
for b1 being non empty set
for b2 being FinSequence of b1 holds b2 is_preposition_of b2
proof end;

theorem Th26: :: FINSEQ_8:26
for b1 being non empty set
for b2, b3 being FinSequence of b1 st b3 is_preposition_of b2 holds
len b3 <= len b2
proof end;

theorem Th27: :: FINSEQ_8:27
for b1 being non empty set
for b2, b3 being FinSequence of b1 st len b3 > 0 & b3 is_preposition_of b2 holds
b3 . 1 = b2 . 1
proof end;

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
pred c3 is_postposition_of c2 means :Def9: :: FINSEQ_8:def 9
Rev a3 is_preposition_of Rev a2;
correctness
;
end;

:: deftheorem Def9 defines is_postposition_of FINSEQ_8:def 9 :
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds
( b3 is_postposition_of b2 iff Rev b3 is_preposition_of Rev b2 );

theorem Th28: :: FINSEQ_8:28
for b1 being non empty set
for b2, b3 being FinSequence of b1 st len b3 = 0 holds
b3 is_postposition_of b2
proof end;

theorem Th29: :: FINSEQ_8:29
for b1 being non empty set
for b2, b3 being FinSequence of b1 st b3 is_postposition_of b2 holds
len b3 <= len b2
proof end;

theorem Th30: :: FINSEQ_8:30
for b1 being non empty set
for b2, b3 being FinSequence of b1 st b3 is_postposition_of b2 & len b3 > 0 holds
( len b3 <= len b2 & mid b2,(((len b2) + 1) -' (len b3)),(len b2) = b3 )
proof end;

theorem Th31: :: FINSEQ_8:31
for b1 being non empty set
for b2, b3 being FinSequence of b1 st ( len b3 > 0 implies ( len b3 <= len b2 & mid b2,(((len b2) + 1) -' (len b3)),(len b2) = b3 ) ) holds
b3 is_postposition_of b2
proof end;

theorem Th32: :: FINSEQ_8:32
for b1 being non empty set
for b2, b3 being FinSequence of b1 st len b3 = 0 holds
b3 is_preposition_of b2 by Def8;

theorem Th33: :: FINSEQ_8:33
for b1 being non empty set
for b2, b3 being FinSequence of b1 st 1 <= len b2 & b3 is_preposition_of b2 holds
b3 is_substring_of b2,1
proof end;

theorem Th34: :: FINSEQ_8:34
for b1 being non empty set
for b2, b3 being FinSequence of b1
for b4 being Nat st not b3 is_substring_of b2,b4 holds
for b5 being Nat st b4 <= b5 & 0 < b5 holds
mid b2,b5,((b5 -' 1) + (len b3)) <> b3
proof end;

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
let c4 be Nat;
func instr c4,c2,c3 -> Nat means :Def10: :: FINSEQ_8:def 10
( ( a5 <> 0 implies ( a4 <= a5 & a3 is_preposition_of a2 /^ (a5 -' 1) & ( for b1 being Nat st b1 >= a4 & b1 > 0 & a3 is_preposition_of a2 /^ (b1 -' 1) holds
b1 >= a5 ) ) ) & ( a5 = 0 implies not a3 is_substring_of a2,a4 ) );
existence
ex b1 being Nat st
( ( b1 <> 0 implies ( c4 <= b1 & c3 is_preposition_of c2 /^ (b1 -' 1) & ( for b2 being Nat st b2 >= c4 & b2 > 0 & c3 is_preposition_of c2 /^ (b2 -' 1) holds
b2 >= b1 ) ) ) & ( b1 = 0 implies not c3 is_substring_of c2,c4 ) )
proof end;
uniqueness
for b1, b2 being Nat st ( b1 <> 0 implies ( c4 <= b1 & c3 is_preposition_of c2 /^ (b1 -' 1) & ( for b3 being Nat st b3 >= c4 & b3 > 0 & c3 is_preposition_of c2 /^ (b3 -' 1) holds
b3 >= b1 ) ) ) & ( b1 = 0 implies not c3 is_substring_of c2,c4 ) & ( b2 <> 0 implies ( c4 <= b2 & c3 is_preposition_of c2 /^ (b2 -' 1) & ( for b3 being Nat st b3 >= c4 & b3 > 0 & c3 is_preposition_of c2 /^ (b3 -' 1) holds
b3 >= b2 ) ) ) & ( b2 = 0 implies not c3 is_substring_of c2,c4 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def10 defines instr FINSEQ_8:def 10 :
for b1 being non empty set
for b2, b3 being FinSequence of b1
for b4, b5 being Nat holds
( b5 = instr b4,b2,b3 iff ( ( b5 <> 0 implies ( b4 <= b5 & b3 is_preposition_of b2 /^ (b5 -' 1) & ( for b6 being Nat st b6 >= b4 & b6 > 0 & b3 is_preposition_of b2 /^ (b6 -' 1) holds
b6 >= b5 ) ) ) & ( b5 = 0 implies not b3 is_substring_of b2,b4 ) ) );

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
func addcr c2,c3 -> FinSequence of a1 equals :: FINSEQ_8:def 11
ovlcon a2,a3;
correctness
coherence
ovlcon c2,c3 is FinSequence of c1
;
;
end;

:: deftheorem Def11 defines addcr FINSEQ_8:def 11 :
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds addcr b2,b3 = ovlcon b2,b3;

definition
let c1 be non empty set ;
let c2, c3 be FinSequence of c1;
pred c2 is_terminated_by c3 means :Def12: :: FINSEQ_8:def 12
( len a3 > 0 implies ( len a2 >= len a3 & instr 1,a2,a3 = ((len a2) + 1) -' (len a3) ) );
correctness
;
end;

:: deftheorem Def12 defines is_terminated_by FINSEQ_8:def 12 :
for b1 being non empty set
for b2, b3 being FinSequence of b1 holds
( b2 is_terminated_by b3 iff ( len b3 > 0 implies ( len b2 >= len b3 & instr 1,b2,b3 = ((len b2) + 1) -' (len b3) ) ) );

theorem Th35: :: FINSEQ_8:35
for b1 being non empty set
for b2 being FinSequence of b1 holds b2 is_terminated_by b2
proof end;