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


begin

:: Extended Segments of Natural Numbers
theorem :: AFINSQ_1:1
for k, n being Nat st k = k /\ n holds
k <= n by NAT_1:46;

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

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

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

:: Finite ExFinSequences
theorem :: AFINSQ_1:5
for r being Function holds
( ( r is finite & r is T-Sequence-like ) iff ex n being Nat st dom r = n ) by FINSET_1:10, ORDINAL1:def 7;

definition
mode XFinSequence is finite T-Sequence;
end;

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

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

registration
let p be XFinSequence;
identify len p with dom p;
compatibility
len p = dom 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;
:: original: dom
redefine func dom p -> Subset of NAT;
coherence
dom p is Subset of NAT
proof end;
end;

theorem :: AFINSQ_1:6
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:7
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 Th8: :: AFINSQ_1:8
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 Th9: :: AFINSQ_1:9
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;

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

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

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

:: XFinSequences of D
registration
let D be set ;
cluster Relation-like D -valued T-Sequence-like Function-like finite for 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 Th12: :: AFINSQ_1:12
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 for set ;
coherence
for b1 being Function st b1 is empty holds
b1 is T-Sequence-like
;
end;

theorem :: AFINSQ_1:13
for k being Nat
for a being set holds k --> a is XFinSequence ;

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

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

theorem Th16: :: AFINSQ_1:16
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 for 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 for 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 1
0 .--> x;
coherence
0 .--> x is set
;
end;

:: deftheorem defines <% AFINSQ_1:def 1 :
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 2
{} ;
coherence
{} is XFinSequence of D
by Th16;
end;

:: deftheorem defines <%> AFINSQ_1:def 2 :
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 :Def3: :: AFINSQ_1:def 3
( 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 Def3 defines ^ AFINSQ_1:def 3 :
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 :: AFINSQ_1:17
for p, q being XFinSequence holds len (p ^ q) = (len p) + (len q) by Def3;

theorem Th18: :: AFINSQ_1:18
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 Th19: :: AFINSQ_1:19
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 Th20: :: AFINSQ_1:20
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 Th21: :: AFINSQ_1:21
for p, q being T-Sequence holds dom p c= dom (p ^ q)
proof end;

theorem Th22: :: AFINSQ_1:22
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 Th23: :: AFINSQ_1:23
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 Th24: :: AFINSQ_1:24
for p, q being XFinSequence holds rng p c= rng (p ^ q)
proof end;

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

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

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

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

registration
let p be XFinSequence;
reduce p ^ {} to p;
reducibility
p ^ {} = p
proof end;
reduce {} ^ p to p;
reducibility
{} ^ p = p
proof end;
end;

theorem :: AFINSQ_1:29
canceled;

theorem Th30: :: AFINSQ_1:30
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 :Def4: :: AFINSQ_1:def 4
( 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 Def4 defines <% AFINSQ_1:def 4 :
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:31
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 5
<%x%> ^ <%y%>;
correctness
coherence
<%x%> ^ <%y%> is set
;
;
let z be set ;
func <%x,y,z%> -> set equals :: AFINSQ_1:def 6
(<%x%> ^ <%y%>) ^ <%z%>;
correctness
coherence
(<%x%> ^ <%y%>) ^ <%z%> is set
;
;
end;

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

:: deftheorem defines <% AFINSQ_1:def 6 :
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:32
for x being set holds <%x%> = {[0,x]} by FUNCT_4:82;

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

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

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

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

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

theorem Th38: :: AFINSQ_1:38
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 Th39: :: AFINSQ_1:39
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;

registration
let x be set ;
cluster <%x%> -> 1 -element ;
coherence
<%x%> is 1 -element
proof end;
let y be set ;
cluster <%x,y%> -> 2 -element ;
coherence
<%x,y%> is 2 -element
proof end;
let z be set ;
cluster <%x,y,z%> -> 3 -element ;
coherence
<%x,y,z%> is 3 -element
proof end;
end;

registration
let n be Nat;
cluster Relation-like T-Sequence-like Function-like finite n -element -> n -defined for set ;
coherence
for b1 being XFinSequence st b1 is n -element holds
b1 is n -defined
proof end;
end;

registration
let n be Nat;
let x be set ;
cluster n --> x -> T-Sequence-like finite ;
coherence
( n --> x is finite & n --> x is T-Sequence-like )
;
end;

registration
let n be Nat;
cluster Relation-like T-Sequence-like Function-like finite n -element for set ;
existence
ex b1 being XFinSequence st b1 is n -element
proof end;
end;

registration
let n be Nat;
cluster Relation-like n -defined T-Sequence-like Function-like finite n -element -> n -defined total n -element for set ;
coherence
for b1 being n -defined n -element XFinSequence holds b1 is total
proof end;
end;

theorem Th40: :: AFINSQ_1:40
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 of induction for extended finite sequences
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:41
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 :Def7: :: AFINSQ_1:def 7
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 Def7 defines ^omega AFINSQ_1:def 7 :
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:42
for x, D being set holds
( x in D ^omega iff x is XFinSequence of D ) by Def7;

theorem :: AFINSQ_1:43
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:44
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;

:: missing, 2008.02.02, A.K.
registration
cluster Relation-like REAL -valued T-Sequence-like Function-like finite -> real-valued for 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 for set ;
coherence
for b1 being XFinSequence of NAT holds b1 is natural-valued
proof end;
end;

:: 2009.0929, A.T.
theorem Th45: :: AFINSQ_1:45
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 Th46: :: AFINSQ_1:46
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 Th47: :: AFINSQ_1:47
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 Th48: :: AFINSQ_1:48
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 Th49: :: AFINSQ_1:49
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:50
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;

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

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

theorem Th53: :: AFINSQ_1:53
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 Th54: :: AFINSQ_1:54
for n being Nat
for p being XFinSequence st n <= len p holds
len (p | n) = n
proof end;

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

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

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

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

theorem :: AFINSQ_1:59
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:60
for n being Nat
for p being XFinSequence ex q being XFinSequence st p = (p | n) ^ q
proof end;

theorem :: AFINSQ_1:61
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:62
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 :Def8: :: AFINSQ_1:def 8
( 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 Def8 defines FS2XFS AFINSQ_1:def 8 :
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 9
( 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 9 :
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 :: AFINSQ_1:63
for D being set
for n being Nat
for r being set st r in D holds
n --> r is XFinSequence of D ;

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 10
( 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 10 :
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 :Def11: :: AFINSQ_1:def 11
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 Def11 defines XFS2FS* AFINSQ_1:def 11 :
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:64
for D being non empty set
for p being XFinSequence of D st p . 0 = 0 & 0 < len p holds
XFS2FS* p = {}
proof end;

:: from EXTPRO_1, 2010.01.11, A.T.
definition
let F be Function;
attr F is initial means :Def12: :: AFINSQ_1:def 12
for m, n being Nat st n in dom F & m < n holds
m in dom F;
end;

:: deftheorem Def12 defines initial AFINSQ_1:def 12 :
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 for 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 for set ;
coherence
for b1 being XFinSequence holds b1 is initial
proof end;
end;

:: following, 2010.01.11, A.T.
registration
cluster Relation-like T-Sequence-like Function-like finite -> NAT -defined for set ;
coherence
for b1 being XFinSequence holds b1 is NAT -defined
proof end;
end;

theorem Th65: :: AFINSQ_1:65
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 for 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 :: AFINSQ_1:66
for F being NAT -defined finite initial Function
for n being Nat holds
( n in dom F iff n < card F ) by NAT_1:44;

:: from AMISTD_2, 2010.04.16, A.T.
theorem :: AFINSQ_1:67
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:68
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:69
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:70
for F being NAT -defined non empty finite initial Function holds LastLoc F = (card F) -' 1
proof end;

theorem :: AFINSQ_1:71
for F being NAT -defined non empty finite initial Function holds FirstLoc F = 0 by Th65, VALUED_1:35;

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:72
for I being NAT -defined finite initial Function
for J being Function holds dom I misses dom (Shift (J,(card I)))
proof end;

:: from SCMPDS_4, 2010.05.14, A.T.
theorem :: AFINSQ_1:73
for p being XFinSequence
for m being Nat st not m in dom p holds
not succ m in dom p
proof end;

:: from SCM_COMP, 2010.05.16, A.T.
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 for Element of D ^omega ;
coherence
for b1 being Element of D ^omega holds
( b1 is finite & b1 is T-Sequence-like )
by Def7;
end;

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

:: deftheorem defines Down AFINSQ_1:def 13 :
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;

:: missing, 2010.05.15, A.T.
theorem Th74: :: AFINSQ_1:74
for p, q being XFinSequence holds p c= p ^ q
proof end;

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

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

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

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

theorem Th79: :: AFINSQ_1:79
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 Th80: :: AFINSQ_1:80
for p, q being XFinSequence
for n being Element of NAT holds Shift (p,n) c= Shift ((p ^ q),n)
proof end;

theorem Th81: :: AFINSQ_1:81
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:82
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:83
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;

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

definition
let x1, x2, x3, x4 be set ;
func <%x1,x2,x3,x4%> -> set equals :: AFINSQ_1:def 14
((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%>;
coherence
((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%> is set
;
end;

:: deftheorem defines <% AFINSQ_1:def 14 :
for x1, x2, x3, x4 being set holds <%x1,x2,x3,x4%> = ((<%x1%> ^ <%x2%>) ^ <%x3%>) ^ <%x4%>;

registration
let x1, x2, x3, x4 be set ;
cluster <%x1,x2,x3,x4%> -> Relation-like Function-like ;
coherence
( <%x1,x2,x3,x4%> is Function-like & <%x1,x2,x3,x4%> is Relation-like )
;
end;

registration
let x1, x2, x3, x4 be set ;
cluster <%x1,x2,x3,x4%> -> T-Sequence-like finite ;
coherence
( <%x1,x2,x3,x4%> is finite & <%x1,x2,x3,x4%> is T-Sequence-like )
;
end;

theorem :: AFINSQ_1:84
for x1, x2, x3, x4 being set holds len <%x1,x2,x3,x4%> = 4
proof end;

theorem :: AFINSQ_1:85
for x1, x2, x3, x4 being set holds
( <%x1,x2,x3,x4%> . 0 = x1 & <%x1,x2,x3,x4%> . 1 = x2 & <%x1,x2,x3,x4%> . 2 = x3 & <%x1,x2,x3,x4%> . 3 = x4 )
proof end;