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



theorem Th1: :: AFINSQ_1:1
for n being Element of NAT holds n in n + 1
proof end;

theorem Th2: :: AFINSQ_1:2
for k, n being Element of NAT st k <= n holds
k = k /\ n
proof end;

theorem :: AFINSQ_1:3
for k, n being Element of NAT st k = k /\ n holds
k <= n by Th2;

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

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

theorem :: AFINSQ_1:6
for n being Element of 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 Element of NAT st dom r = n )
proof end;

definition
mode XFinSequence is finite T-Sequence;
end;

registration
let p be XFinSequence;
cluster dom 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 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
canceled;
let p be XFinSequence;
:: original: dom
redefine func dom p -> Subset of NAT ;
coherence
dom 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 Element of 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 Element of NAT st k in F1() holds
P1[k,p . k] ) )
provided
A2: for k being Element of 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 Element of 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 Element of 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 Element of NAT st k in dom p holds
p . k = q . k ) holds
p = q
proof end;

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

theorem Th12: :: AFINSQ_1:12
for n being Element of NAT
for p being XFinSequence holds p | n is XFinSequence
proof 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 :: AFINSQ_1:14
for k being Element of NAT
for p being XFinSequence st k < len p holds
dom (p | k) = k
proof end;

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

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

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

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

registration
let D be set ;
cluster finite Element of bool [:NAT ,D:];
existence
ex b1 being PartFunc of NAT ,D st b1 is finite
proof end;
end;

theorem :: AFINSQ_1:16
for k being Element of NAT
for D being set
for p being XFinSequence of holds p | k is XFinSequence of by Th12;

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

registration
cluster empty set ;
existence
ex b1 being XFinSequence st b1 is empty
by ORDINAL1:45;
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
proof end;

registration
let D be set ;
cluster empty set ;
existence
ex b1 being XFinSequence of st 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 equals :: AFINSQ_1:def 3
{} ;
coherence
{} is XFinSequence of
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 Element of NAT st k in dom p holds
it . k = p . k ) & ( for k being Element of 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 Element of NAT st k in dom p holds
b1 . k = p . k ) & ( for k being Element of 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 Element of NAT st k in dom p holds
b3 . k = p . k ) & ( for k being Element of 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:20
for p, q being XFinSequence holds len (p ^ q) = (len p) + (len q) by Def4;

theorem Th21: :: AFINSQ_1:21
for k being Element of 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 :: AFINSQ_1:22
for k being Element of 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 Element of NAT
for p, q being XFinSequence holds
( not k in dom (p ^ q) or k in dom p or ex n being Element of 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 Element of NAT st
( k = x & (len p) + k in dom (p ^ q) )
proof end;

theorem Th26: :: AFINSQ_1:26
for k being Element of 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 :: 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 :: AFINSQ_1:33
for p, q being XFinSequence st p ^ q = {} holds
( p = {} & q = {} )
proof end;

definition
let D be set ;
let p, q be XFinSequence of ;
:: original: ^
redefine func p ^ q -> T-Sequence of ;
coherence
p ^ q is T-Sequence of
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 holds
( p is XFinSequence of & q is XFinSequence of )
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 :: AFINSQ_1:39
for x being set
for p being XFinSequence holds (<%x%> ^ p) . 0 = x
proof end;

theorem :: 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 :: 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 :: AFINSQ_1:44
for p being XFinSequence st p <> {} holds
ex q being XFinSequence ex x being set st p = q ^ <%x%>
proof end;

definition
let D be non empty set ;
let x be Element of D;
:: original: <%
redefine func <%x%> -> XFinSequence of ;
coherence
<%x%> is XFinSequence of
proof end;
end;

scheme :: AFINSQ_1:sch 3
IndXSeq{ P1[ XFinSequence] } :
for p being XFinSequence holds P1[p]
provided
A1: P1[ {} ] and
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 );
existence
ex b1 being set st
for x being set holds
( x in b1 iff x is XFinSequence of )
proof end;
uniqueness
for b1, b2 being set st ( for x being set holds
( x in b1 iff x is XFinSequence of ) ) & ( for x being set holds
( x in b2 iff x is XFinSequence of ) ) 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 ) );

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 ) 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;

definition
let D be non empty set ;
let p be XFinSequence of ;
let i be Element of NAT ;
let a be Element of D;
:: original: Replace
redefine func Replace p,i,a -> XFinSequence of ;
coherence
Replace p,i,a is XFinSequence of
proof end;
end;

registration
let x, y be set ;
cluster [x,y] -> non natural ;
coherence
not [x,y] is natural
proof end;
end;

registration
cluster -> real-valued set ;
coherence
for b1 being XFinSequence of holds b1 is real-valued
proof end;
end;

registration
cluster -> natural-valued set ;
coherence
for b1 being XFinSequence of holds b1 is natural-valued
proof end;
end;