:: Zero Based Finite Sequences
:: by Tetsuya Tsunetou , Grzegorz Bancerek and Yatsuka Nakamura
::
:: Received September 28, 2001
:: Copyright (c) 2001-2011 Association of Mizar Users


begin

theorem :: AFINSQ_1:1
canceled;

theorem :: AFINSQ_1:2
canceled;

theorem :: AFINSQ_1:3
for k, n being Nat st k = k /\ n holds
k <= n by NAT_1:47;

theorem Th4: :: AFINSQ_1:4
for n being Nat holds n \/ {n} = n + 1
proof end;

theorem Th5: :: AFINSQ_1:5
for n being Nat holds Seg n c= n + 1
proof end;

theorem :: AFINSQ_1:6
for n being Nat holds n + 1 = {0} \/ (Seg n)
proof end;

theorem Th7: :: AFINSQ_1:7
for r being Function holds
( ( r is finite & r is T-Sequence-like ) iff ex n being Nat st dom r = n )
proof end;

definition
mode XFinSequence is finite T-Sequence;
end;

registration
let p be XFinSequence;
cluster proj1 p -> natural ;
coherence
dom p is natural
proof end;
end;

notation
let p be XFinSequence;
synonym len p for card p;
end;

registration
let p be XFinSequence;
identify len p with proj1 p;
compatibility
len p = proj1 p
proof end;
end;

definition
let p be XFinSequence;
:: original: len
redefine func len p -> Element of NAT ;
coherence
len p is Element of NAT
proof end;
end;

definition
let p be XFinSequence;
canceled;
:: original: proj1
redefine func dom p -> Subset of NAT;
coherence
proj1 p is Subset of NAT
proof end;
end;

:: deftheorem AFINSQ_1:def 1 :
canceled;

theorem :: AFINSQ_1:8
for f being Function st ex k being Nat st dom f c= k holds
ex p being XFinSequence st f c= p
proof end;

scheme :: AFINSQ_1:sch 1
XSeqEx{ F1() -> Nat, P1[ set , set ] } :
ex p being XFinSequence st
( dom p = F1() & ( for k being Nat st k in F1() holds
P1[k,p . k] ) )
provided
A1: for k being Nat st k in F1() holds
ex x being set st P1[k,x]
proof end;

scheme :: AFINSQ_1:sch 2
XSeqLambda{ F1() -> Nat, F2( set ) -> set } :
ex p being XFinSequence st
( len p = F1() & ( for k being Nat st k in F1() holds
p . k = F2(k) ) )
proof end;

theorem :: AFINSQ_1:9
for z being set
for p being XFinSequence st z in p holds
ex k being Nat st
( k in dom p & z = [k,(p . k)] )
proof end;

theorem Th10: :: AFINSQ_1:10
for p, q being XFinSequence st dom p = dom q & ( for k being Nat st k in dom p holds
p . k = q . k ) holds
p = q
proof end;

theorem Th11: :: AFINSQ_1:11
for p, q being XFinSequence st len p = len q & ( for k being Nat st k < len p holds
p . k = q . k ) holds
p = q
proof end;

theorem :: AFINSQ_1:12
canceled;

registration
let p be XFinSequence;
let n be Nat;
cluster p | n -> finite ;
coherence
p | n is finite
proof end;
end;

theorem :: AFINSQ_1:13
for f being Function
for p being XFinSequence st rng p c= dom f holds
f * p is XFinSequence
proof end;

theorem Th14: :: AFINSQ_1:14
for k being Nat
for p being XFinSequence st k < len p holds
dom (p | k) = k
proof end;

registration
let D be set ;
cluster Relation-like D -valued T-Sequence-like Function-like finite set ;
existence
ex b1 being T-Sequence of D st b1 is finite
proof end;
end;

definition
let D be set ;
mode XFinSequence of D is finite T-Sequence of D;
end;

theorem Th15: :: AFINSQ_1:15
for D being set
for f being XFinSequence of D holds f is PartFunc of NAT,D
proof end;

registration
cluster Relation-like Function-like empty -> T-Sequence-like set ;
coherence
for b1 being Function st b1 is empty holds
b1 is T-Sequence-like
;
end;

theorem Th16: :: AFINSQ_1:16
for k being Nat
for a being set holds k --> a is XFinSequence
proof end;

theorem Th17: :: AFINSQ_1:17
for k being Nat
for D being non empty set ex p being XFinSequence of D st len p = k
proof end;

theorem :: AFINSQ_1:18
for p being XFinSequence holds
( len p = 0 iff p = {} ) ;

theorem Th19: :: AFINSQ_1:19
for D being set holds {} is XFinSequence of D
proof end;

registration
let D be set ;
cluster Relation-like D -valued T-Sequence-like Function-like empty finite set ;
existence
ex b1 being XFinSequence of D st b1 is empty
proof end;
end;

registration
let D be non empty set ;
cluster Relation-like D -valued T-Sequence-like Function-like non empty finite set ;
existence
not for b1 being XFinSequence of D holds b1 is empty
proof end;
end;

definition
let x be set ;
func <%x%> -> set equals :: AFINSQ_1:def 2
0 .--> x;
coherence
0 .--> x is set
;
end;

:: deftheorem defines <% AFINSQ_1:def 2 :
for x being set holds <%x%> = 0 .--> x;

registration
let x be set ;
cluster <%x%> -> non empty ;
coherence
not <%x%> is empty
;
end;

definition
let D be set ;
func <%> D -> XFinSequence of D equals :: AFINSQ_1:def 3
{} ;
coherence
{} is XFinSequence of D
by Th19;
end;

:: deftheorem defines <%> AFINSQ_1:def 3 :
for D being set holds <%> D = {} ;

registration
let D be set ;
cluster <%> D -> empty ;
coherence
<%> D is empty
;
end;

definition
let p, q be XFinSequence;
redefine func p ^ q means :Def4: :: AFINSQ_1:def 4
( dom it = (len p) + (len q) & ( for k being Nat st k in dom p holds
it . k = p . k ) & ( for k being Nat st k in dom q holds
it . ((len p) + k) = q . k ) );
compatibility
for b1 being set holds
( b1 = p ^ q iff ( dom b1 = (len p) + (len q) & ( for k being Nat st k in dom p holds
b1 . k = p . k ) & ( for k being Nat st k in dom q holds
b1 . ((len p) + k) = q . k ) ) )
proof end;
end;

:: deftheorem Def4 defines ^ AFINSQ_1:def 4 :
for p, q being XFinSequence
for b3 being set holds
( b3 = p ^ q iff ( dom b3 = (len p) + (len q) & ( for k being Nat st k in dom p holds
b3 . k = p . k ) & ( for k being Nat st k in dom q holds
b3 . ((len p) + k) = q . k ) ) );

registration
let p, q be XFinSequence;
cluster p ^ q -> finite ;
coherence
p ^ q is finite
proof end;
end;

theorem Th20: :: AFINSQ_1:20
for p, q being XFinSequence holds len (p ^ q) = (len p) + (len q) by Def4;

theorem Th21: :: AFINSQ_1:21
for k being Nat
for p, q being XFinSequence st len p <= k & k < (len p) + (len q) holds
(p ^ q) . k = q . (k - (len p))
proof end;

theorem Th22: :: AFINSQ_1:22
for k being Nat
for p, q being XFinSequence st len p <= k & k < len (p ^ q) holds
(p ^ q) . k = q . (k - (len p))
proof end;

theorem Th23: :: AFINSQ_1:23
for k being Nat
for p, q being XFinSequence holds
( not k in dom (p ^ q) or k in dom p or ex n being Nat st
( n in dom q & k = (len p) + n ) )
proof end;

theorem Th24: :: AFINSQ_1:24
for p, q being T-Sequence holds dom p c= dom (p ^ q)
proof end;

theorem Th25: :: AFINSQ_1:25
for x being set
for q, p being XFinSequence st x in dom q holds
ex k being Nat st
( k = x & (len p) + k in dom (p ^ q) )
proof end;

theorem Th26: :: AFINSQ_1:26
for k being Nat
for q, p being XFinSequence st k in dom q holds
(len p) + k in dom (p ^ q)
proof end;

theorem Th27: :: AFINSQ_1:27
for p, q being XFinSequence holds rng p c= rng (p ^ q)
proof end;

theorem Th28: :: AFINSQ_1:28
for q, p being XFinSequence holds rng q c= rng (p ^ q)
proof end;

theorem Th29: :: AFINSQ_1:29
for p, q being XFinSequence holds rng (p ^ q) = (rng p) \/ (rng q)
proof end;

theorem Th30: :: AFINSQ_1:30
for p, q, r being XFinSequence holds (p ^ q) ^ r = p ^ (q ^ r)
proof end;

theorem Th31: :: AFINSQ_1:31
for p, r, q being XFinSequence st ( p ^ r = q ^ r or r ^ p = r ^ q ) holds
p = q
proof end;

theorem Th32: :: AFINSQ_1:32
for p being XFinSequence holds
( p ^ {} = p & {} ^ p = p )
proof end;

theorem Th33: :: AFINSQ_1:33
for p, q being XFinSequence st p ^ q = {} holds
( p = {} & q = {} )
proof end;

registration
let D be set ;
let p, q be XFinSequence of D;
cluster p ^ q -> D -valued ;
coherence
p ^ q is D -valued
proof end;
end;

Lm1: for x, y, x1, y1 being set st [x,y] in {[x1,y1]} holds
( x = x1 & y = y1 )
proof end;

definition
let x be set ;
:: original: <%
redefine func <%x%> -> Function means :Def5: :: AFINSQ_1:def 5
( dom it = 1 & it . 0 = x );
coherence
<%x%> is Function
;
compatibility
for b1 being Function holds
( b1 = <%x%> iff ( dom b1 = 1 & b1 . 0 = x ) )
proof end;
end;

:: deftheorem Def5 defines <% AFINSQ_1:def 5 :
for x being set
for b2 being Function holds
( b2 = <%x%> iff ( dom b2 = 1 & b2 . 0 = x ) );

registration
let x be set ;
cluster <%x%> -> Relation-like Function-like ;
coherence
( <%x%> is Function-like & <%x%> is Relation-like )
;
end;

registration
let x be set ;
cluster <%x%> -> T-Sequence-like finite ;
coherence
( <%x%> is finite & <%x%> is T-Sequence-like )
proof end;
end;

theorem :: AFINSQ_1:34
for p, q being XFinSequence
for D being set st p ^ q is XFinSequence of D holds
( p is XFinSequence of D & q is XFinSequence of D )
proof end;

definition
let x, y be set ;
func <%x,y%> -> set equals :: AFINSQ_1:def 6
<%x%> ^ <%y%>;
correctness
coherence
<%x%> ^ <%y%> is set
;
;
let z be set ;
func <%x,y,z%> -> set equals :: AFINSQ_1:def 7
(<%x%> ^ <%y%>) ^ <%z%>;
correctness
coherence
(<%x%> ^ <%y%>) ^ <%z%> is set
;
;
end;

:: deftheorem defines <% AFINSQ_1:def 6 :
for x, y being set holds <%x,y%> = <%x%> ^ <%y%>;

:: deftheorem defines <% AFINSQ_1:def 7 :
for x, y, z being set holds <%x,y,z%> = (<%x%> ^ <%y%>) ^ <%z%>;

registration
let x, y be set ;
cluster <%x,y%> -> Relation-like Function-like ;
coherence
( <%x,y%> is Function-like & <%x,y%> is Relation-like )
;
let z be set ;
cluster <%x,y,z%> -> Relation-like Function-like ;
coherence
( <%x,y,z%> is Function-like & <%x,y,z%> is Relation-like )
;
end;

registration
let x, y be set ;
cluster <%x,y%> -> T-Sequence-like finite ;
coherence
( <%x,y%> is finite & <%x,y%> is T-Sequence-like )
;
let z be set ;
cluster <%x,y,z%> -> T-Sequence-like finite ;
coherence
( <%x,y,z%> is finite & <%x,y,z%> is T-Sequence-like )
;
end;

theorem :: AFINSQ_1:35
for x being set holds <%x%> = {[0,x]} by FUNCT_4:87;

theorem Th36: :: AFINSQ_1:36
for x being set
for p being XFinSequence holds
( p = <%x%> iff ( dom p = 1 & rng p = {x} ) )
proof end;

theorem :: AFINSQ_1:37
canceled;

theorem :: AFINSQ_1:38
for x being set
for p being XFinSequence holds
( p = <%x%> iff ( len p = 1 & p . 0 = x ) ) by Def5;

theorem Th39: :: AFINSQ_1:39
for x being set
for p being XFinSequence holds (<%x%> ^ p) . 0 = x
proof end;

theorem Th40: :: AFINSQ_1:40
for x being set
for p being XFinSequence holds (p ^ <%x%>) . (len p) = x
proof end;

theorem :: AFINSQ_1:41
for x, y, z being set holds
( <%x,y,z%> = <%x%> ^ <%y,z%> & <%x,y,z%> = <%x,y%> ^ <%z%> ) by Th30;

theorem Th42: :: AFINSQ_1:42
for x, y being set
for p being XFinSequence holds
( p = <%x,y%> iff ( len p = 2 & p . 0 = x & p . 1 = y ) )
proof end;

theorem Th43: :: AFINSQ_1:43
for x, y, z being set
for p being XFinSequence holds
( p = <%x,y,z%> iff ( len p = 3 & p . 0 = x & p . 1 = y & p . 2 = z ) )
proof end;

theorem Th44: :: AFINSQ_1:44
for p being XFinSequence st p <> {} holds
ex q being XFinSequence ex x being set st p = q ^ <%x%>
proof end;

registration
let D be non empty set ;
let d1 be Element of D;
cluster <%d1%> -> D -valued ;
coherence
<%d1%> is D -valued
;
let d2 be Element of D;
cluster <%d1,d2%> -> D -valued ;
coherence
<%d1,d2%> is D -valued
;
let d3 be Element of D;
cluster <%d1,d2,d3%> -> D -valued ;
coherence
<%d1,d2,d3%> is D -valued
;
end;

scheme :: AFINSQ_1:sch 3
IndXSeq{ P1[ XFinSequence] } :
for p being XFinSequence holds P1[p]
provided
A1: P1[ {} ] and
A2: for p being XFinSequence
for x being set st P1[p] holds
P1[p ^ <%x%>]
proof end;

theorem :: AFINSQ_1:45
for p, q, r, s being XFinSequence st p ^ q = r ^ s & len p <= len r holds
ex t being XFinSequence st p ^ t = r
proof end;

definition
let D be set ;
func D ^omega -> set means :Def8: :: AFINSQ_1:def 8
for x being set holds
( x in it iff x is XFinSequence of D );
existence
ex b1 being set st
for x being set holds
( x in b1 iff x is XFinSequence of D )
proof end;
uniqueness
for b1, b2 being set st ( for x being set holds
( x in b1 iff x is XFinSequence of D ) ) & ( for x being set holds
( x in b2 iff x is XFinSequence of D ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def8 defines ^omega AFINSQ_1:def 8 :
for D, b2 being set holds
( b2 = D ^omega iff for x being set holds
( x in b2 iff x is XFinSequence of D ) );

registration
let D be set ;
cluster D ^omega -> non empty ;
coherence
not D ^omega is empty
proof end;
end;

theorem :: AFINSQ_1:46
for x, D being set holds
( x in D ^omega iff x is XFinSequence of D ) by Def8;

theorem :: AFINSQ_1:47
for D being set holds {} in D ^omega
proof end;

scheme :: AFINSQ_1:sch 4
SepXSeq{ F1() -> non empty set , P1[ XFinSequence] } :
ex X being set st
for x being set holds
( x in X iff ex p being XFinSequence st
( p in F1() ^omega & P1[p] & x = p ) )
proof end;

notation
let p be XFinSequence;
let i, x be set ;
synonym Replace (p,i,x) for p +* (i,x);
end;

registration
let p be XFinSequence;
let i, x be set ;
cluster Replace (p,i,x) -> T-Sequence-like finite ;
coherence
( p +* (i,x) is finite & p +* (i,x) is T-Sequence-like )
proof end;
end;

theorem :: AFINSQ_1:48
for p being XFinSequence
for i being Element of NAT
for x being set holds
( len (Replace (p,i,x)) = len p & ( i < len p implies (Replace (p,i,x)) . i = x ) & ( for j being Element of NAT st j <> i holds
(Replace (p,i,x)) . j = p . j ) )
proof end;

registration
let D be non empty set ;
let p be XFinSequence of D;
let i be Element of NAT ;
let a be Element of D;
cluster Replace (p,i,a) -> D -valued ;
coherence
Replace (p,i,a) is D -valued
proof end;
end;

registration
cluster Relation-like REAL -valued T-Sequence-like Function-like finite -> real-valued set ;
coherence
for b1 being XFinSequence of REAL holds b1 is real-valued
proof end;
end;

registration
cluster Relation-like NAT -valued T-Sequence-like Function-like finite -> natural-valued set ;
coherence
for b1 being XFinSequence of NAT holds b1 is natural-valued
proof end;
end;

theorem Th49: :: AFINSQ_1:49
for p being XFinSequence
for x1, x2, x3, x4 being set st p = ((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%> holds
( len p = 4 & p . 0 = x1 & p . 1 = x2 & p . 2 = x3 & p . 3 = x4 )
proof end;

theorem Th50: :: AFINSQ_1:50
for p being XFinSequence
for x1, x2, x3, x4, x5 being set st p = (((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%>) ^ <%x5%> holds
( len p = 5 & p . 0 = x1 & p . 1 = x2 & p . 2 = x3 & p . 3 = x4 & p . 4 = x5 )
proof end;

theorem Th51: :: AFINSQ_1:51
for p being XFinSequence
for x1, x2, x3, x4, x5, x6 being set st p = ((((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%>) ^ <%x5%>) ^ <%x6%> holds
( len p = 6 & p . 0 = x1 & p . 1 = x2 & p . 2 = x3 & p . 3 = x4 & p . 4 = x5 & p . 5 = x6 )
proof end;

theorem Th52: :: AFINSQ_1:52
for p being XFinSequence
for x1, x2, x3, x4, x5, x6, x7 being set st p = (((((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%>) ^ <%x5%>) ^ <%x6%>) ^ <%x7%> holds
( len p = 7 & p . 0 = x1 & p . 1 = x2 & p . 2 = x3 & p . 3 = x4 & p . 4 = x5 & p . 5 = x6 & p . 6 = x7 )
proof end;

theorem Th53: :: AFINSQ_1:53
for p being XFinSequence
for x1, x2, x3, x4, x5, x6, x7, x8 being set st p = ((((((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%>) ^ <%x5%>) ^ <%x6%>) ^ <%x7%>) ^ <%x8%> holds
( len p = 8 & p . 0 = x1 & p . 1 = x2 & p . 2 = x3 & p . 3 = x4 & p . 4 = x5 & p . 5 = x6 & p . 6 = x7 & p . 7 = x8 )
proof end;

theorem :: AFINSQ_1:54
for p being XFinSequence
for x1, x2, x3, x4, x5, x6, x7, x8, x9 being set st p = (((((((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%>) ^ <%x5%>) ^ <%x6%>) ^ <%x7%>) ^ <%x8%>) ^ <%x9%> holds
( len p = 9 & p . 0 = x1 & p . 1 = x2 & p . 2 = x3 & p . 3 = x4 & p . 4 = x5 & p . 5 = x6 & p . 6 = x7 & p . 7 = x8 & p . 8 = x9 )
proof end;

theorem :: AFINSQ_1:55
for n being Nat
for p, q being XFinSequence st n < len p holds
(p ^ q) . n = p . n
proof end;

theorem :: AFINSQ_1:56
for n being Nat
for p being XFinSequence st len p <= n holds
p | n = p
proof end;

theorem Th57: :: AFINSQ_1:57
for n, k being Nat
for p being XFinSequence st n <= len p & k in n holds
( (p | n) . k = p . k & k in dom p )
proof end;

theorem Th58: :: AFINSQ_1:58
for n being Nat
for p being XFinSequence st n <= len p holds
len (p | n) = n
proof end;

theorem :: AFINSQ_1:59
for n being Nat
for p being XFinSequence holds len (p | n) <= n
proof end;

theorem Th60: :: AFINSQ_1:60
for n being Nat
for p being XFinSequence st len p = n + 1 holds
p = (p | n) ^ <%(p . n)%>
proof end;

theorem Th61: :: AFINSQ_1:61
for p, q being XFinSequence holds (p ^ q) | (dom p) = p
proof end;

theorem :: AFINSQ_1:62
for n being Nat
for p, q being XFinSequence st n <= dom p holds
(p ^ q) | n = p | n
proof end;

theorem :: AFINSQ_1:63
for n, k being Nat
for p, q being XFinSequence st n = (dom p) + k holds
(p ^ q) | n = p ^ (q | k)
proof end;

theorem :: AFINSQ_1:64
for n being Nat
for p being XFinSequence ex q being XFinSequence st p = (p | n) ^ q
proof end;

theorem :: AFINSQ_1:65
for n, k being Nat
for p being XFinSequence st len p = n + k holds
ex q1, q2 being XFinSequence st
( len q1 = n & len q2 = k & p = q1 ^ q2 )
proof end;

theorem :: AFINSQ_1:66
for x, y being set
for p, q being XFinSequence st <%x%> ^ p = <%y%> ^ q holds
( x = y & p = q )
proof end;

definition
let D be set ;
let q be FinSequence of D;
func FS2XFS q -> XFinSequence of D means :Def9: :: AFINSQ_1:def 9
( len it = len q & ( for i being Nat st i < len q holds
q . (i + 1) = it . i ) );
existence
ex b1 being XFinSequence of D st
( len b1 = len q & ( for i being Nat st i < len q holds
q . (i + 1) = b1 . i ) )
proof end;
uniqueness
for b1, b2 being XFinSequence of D st len b1 = len q & ( for i being Nat st i < len q holds
q . (i + 1) = b1 . i ) & len b2 = len q & ( for i being Nat st i < len q holds
q . (i + 1) = b2 . i ) holds
b1 = b2
proof end;
end;

:: deftheorem Def9 defines FS2XFS AFINSQ_1:def 9 :
for D being set
for q being FinSequence of D
for b3 being XFinSequence of D holds
( b3 = FS2XFS q iff ( len b3 = len q & ( for i being Nat st i < len q holds
q . (i + 1) = b3 . i ) ) );

definition
let D be set ;
let q be XFinSequence of D;
func XFS2FS q -> FinSequence of D means :: AFINSQ_1:def 10
( len it = len q & ( for i being Nat st 1 <= i & i <= len q holds
q . (i -' 1) = it . i ) );
existence
ex b1 being FinSequence of D st
( len b1 = len q & ( for i being Nat st 1 <= i & i <= len q holds
q . (i -' 1) = b1 . i ) )
proof end;
uniqueness
for b1, b2 being FinSequence of D st len b1 = len q & ( for i being Nat st 1 <= i & i <= len q holds
q . (i -' 1) = b1 . i ) & len b2 = len q & ( for i being Nat st 1 <= i & i <= len q holds
q . (i -' 1) = b2 . i ) holds
b1 = b2
proof end;
end;

:: deftheorem defines XFS2FS AFINSQ_1:def 10 :
for D being set
for q being XFinSequence of D
for b3 being FinSequence of D holds
( b3 = XFS2FS q iff ( len b3 = len q & ( for i being Nat st 1 <= i & i <= len q holds
q . (i -' 1) = b3 . i ) ) );

theorem Th67: :: AFINSQ_1:67
for D being set
for n being Nat
for r being set st r in D holds
n --> r is XFinSequence of D
proof end;

definition
let D be non empty set ;
let q be FinSequence of D;
let n be Nat;
assume that
A1: n > len q and
A2: NAT c= D ;
func FS2XFS* (q,n) -> non empty XFinSequence of D means :: AFINSQ_1:def 11
( len q = it . 0 & len it = n & ( for i being Nat st 1 <= i & i <= len q holds
it . i = q . i ) & ( for j being Nat st len q < j & j < n holds
it . j = 0 ) );
existence
ex b1 being non empty XFinSequence of D st
( len q = b1 . 0 & len b1 = n & ( for i being Nat st 1 <= i & i <= len q holds
b1 . i = q . i ) & ( for j being Nat st len q < j & j < n holds
b1 . j = 0 ) )
proof end;
uniqueness
for b1, b2 being non empty XFinSequence of D st len q = b1 . 0 & len b1 = n & ( for i being Nat st 1 <= i & i <= len q holds
b1 . i = q . i ) & ( for j being Nat st len q < j & j < n holds
b1 . j = 0 ) & len q = b2 . 0 & len b2 = n & ( for i being Nat st 1 <= i & i <= len q holds
b2 . i = q . i ) & ( for j being Nat st len q < j & j < n holds
b2 . j = 0 ) holds
b1 = b2
proof end;
end;

:: deftheorem defines FS2XFS* AFINSQ_1:def 11 :
for D being non empty set
for q being FinSequence of D
for n being Nat st n > len q & NAT c= D holds
for b4 being non empty XFinSequence of D holds
( b4 = FS2XFS* (q,n) iff ( len q = b4 . 0 & len b4 = n & ( for i being Nat st 1 <= i & i <= len q holds
b4 . i = q . i ) & ( for j being Nat st len q < j & j < n holds
b4 . j = 0 ) ) );

definition
let D be non empty set ;
let p be XFinSequence of D;
assume that
A1: p . 0 is Nat and
A2: p . 0 in len p ;
func XFS2FS* p -> FinSequence of D means :Def12: :: AFINSQ_1:def 12
for m being Nat st m = p . 0 holds
( len it = m & ( for i being Nat st 1 <= i & i <= m holds
it . i = p . i ) );
existence
ex b1 being FinSequence of D st
for m being Nat st m = p . 0 holds
( len b1 = m & ( for i being Nat st 1 <= i & i <= m holds
b1 . i = p . i ) )
proof end;
uniqueness
for b1, b2 being FinSequence of D st ( for m being Nat st m = p . 0 holds
( len b1 = m & ( for i being Nat st 1 <= i & i <= m holds
b1 . i = p . i ) ) ) & ( for m being Nat st m = p . 0 holds
( len b2 = m & ( for i being Nat st 1 <= i & i <= m holds
b2 . i = p . i ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def12 defines XFS2FS* AFINSQ_1:def 12 :
for D being non empty set
for p being XFinSequence of D st p . 0 is Nat & p . 0 in len p holds
for b3 being FinSequence of D holds
( b3 = XFS2FS* p iff for m being Nat st m = p . 0 holds
( len b3 = m & ( for i being Nat st 1 <= i & i <= m holds
b3 . i = p . i ) ) );

theorem :: AFINSQ_1:68
for D being non empty set
for p being XFinSequence of D st p . 0 = 0 & 0 < len p holds
XFS2FS* p = {}
proof end;

definition
let F be Function;
attr F is initial means :Def13: :: AFINSQ_1:def 13
for m, n being Nat st n in dom F & m < n holds
m in dom F;
end;

:: deftheorem Def13 defines initial AFINSQ_1:def 13 :
for F being Function holds
( F is initial iff for m, n being Nat st n in dom F & m < n holds
m in dom F );

registration
cluster Relation-like Function-like empty -> initial set ;
coherence
for b1 being Function st b1 is empty holds
b1 is initial
proof end;
end;

registration
cluster Relation-like T-Sequence-like Function-like finite -> initial set ;
coherence
for b1 being XFinSequence holds b1 is initial
proof end;
end;

registration
cluster Relation-like T-Sequence-like Function-like finite -> NAT -defined set ;
coherence
for b1 being XFinSequence holds b1 is NAT -defined
proof end;
end;

theorem Th69: :: AFINSQ_1:69
for F being NAT -defined non empty initial Function holds 0 in dom F
proof end;

registration
cluster Relation-like NAT -defined Function-like finite initial -> T-Sequence-like set ;
coherence
for b1 being Function st b1 is initial & b1 is finite & b1 is NAT -defined holds
b1 is T-Sequence-like
proof end;
end;

theorem Th70: :: AFINSQ_1:70
for F being NAT -defined finite initial Function
for n being Nat holds
( n in dom F iff n < card F ) by NAT_1:45;

theorem :: AFINSQ_1:71
for F being NAT -defined initial Function
for G being NAT -defined Function st dom F = dom G holds
G is initial
proof end;

theorem :: AFINSQ_1:72
for F being NAT -defined finite initial Function holds dom F = { k where k is Element of NAT : k < card F }
proof end;

theorem :: AFINSQ_1:73
for F being NAT -defined non empty finite initial Function
for G being NAT -defined non empty finite Function st F c= G & LastLoc F = LastLoc G holds
F = G
proof end;

theorem :: AFINSQ_1:74
for F being NAT -defined non empty finite initial Function holds LastLoc F = (card F) -' 1
proof end;

theorem :: AFINSQ_1:75
for F being NAT -defined non empty finite initial Function holds FirstLoc F = 0
proof end;

registration
let F be NAT -defined non empty finite initial Function;
cluster CutLastLoc F -> initial ;
coherence
CutLastLoc F is initial
proof end;
end;

theorem :: AFINSQ_1:76
for I being NAT -defined finite initial Function
for J being Function holds dom I misses dom (Shift (J,(card I)))
proof end;

theorem :: AFINSQ_1:77
for p being XFinSequence
for m being Nat st not m in dom p holds
not succ m in dom p
proof end;

registration
let D be set ;
cluster D ^omega -> functional ;
coherence
D ^omega is functional
proof end;
end;

registration
let D be set ;
cluster -> T-Sequence-like finite Element of D ^omega ;
coherence
for b1 being Element of D ^omega holds
( b1 is finite & b1 is T-Sequence-like )
by Def8;
end;

definition
let D be set ;
let f be XFinSequence of D;
func Down f -> Element of D ^omega equals :: AFINSQ_1:def 14
f;
coherence
f is Element of D ^omega
by Def8;
end;

:: deftheorem defines Down AFINSQ_1:def 14 :
for D being set
for f being XFinSequence of D holds Down f = f;

definition
let D be set ;
let f be XFinSequence of D;
let g be Element of D ^omega ;
:: original: ^
redefine func f ^ g -> Element of D ^omega ;
coherence
f ^ g is Element of D ^omega
proof end;
end;

definition
let D be set ;
let f, g be Element of D ^omega ;
:: original: ^
redefine func f ^ g -> Element of D ^omega ;
coherence
f ^ g is Element of D ^omega
proof end;
end;

theorem Th78: :: AFINSQ_1:78
for p, q being XFinSequence holds p c= p ^ q
proof end;

theorem :: AFINSQ_1:79
for x being set
for p being XFinSequence holds len (p ^ <%x%>) = (len p) + 1
proof end;

theorem :: AFINSQ_1:80
for x, y being set holds <%x,y%> = (0,1) --> (x,y)
proof end;

theorem Th81: :: AFINSQ_1:81
for p, q being XFinSequence holds p ^ q = p +* (Shift (q,(card p)))
proof end;

theorem :: AFINSQ_1:82
for p, q being XFinSequence holds
( p +* (p ^ q) = p ^ q & (p ^ q) +* p = p ^ q )
proof end;

theorem Th83: :: AFINSQ_1:83
for n being Element of NAT
for I being NAT -defined finite initial Function
for J being Function holds dom (Shift (I,n)) misses dom (Shift (J,(n + (card I))))
proof end;

theorem Th84: :: AFINSQ_1:84
for p, q being XFinSequence
for n being Element of NAT holds Shift (p,n) c= Shift ((p ^ q),n)
proof end;

theorem Th85: :: AFINSQ_1:85
for q, p being XFinSequence
for n being Element of NAT holds Shift (q,(n + (card p))) c= Shift ((p ^ q),n)
proof end;

theorem :: AFINSQ_1:86
for X being set
for p, q being XFinSequence
for n being Element of NAT st Shift ((p ^ q),n) c= X holds
Shift (p,n) c= X
proof end;

theorem :: AFINSQ_1:87
for X being set
for p, q being XFinSequence
for n being Element of NAT st Shift ((p ^ q),n) c= X holds
Shift (q,(n + (card p))) c= X
proof end;