let D be non empty set ; :: thesis: for f being FinSequence of D holds
( f is almost-one-to-one iff ( f /^ 1 is one-to-one & f | ((len f) -' 1) is one-to-one ) )

let f be FinSequence of D; :: thesis: ( f is almost-one-to-one iff ( f /^ 1 is one-to-one & f | ((len f) -' 1) is one-to-one ) )
A1: len (f /^ 1) = (len f) -' 1 by RFINSEQ:29;
thus ( f is almost-one-to-one implies ( f /^ 1 is one-to-one & f | ((len f) -' 1) is one-to-one ) ) :: thesis: ( f /^ 1 is one-to-one & f | ((len f) -' 1) is one-to-one implies f is almost-one-to-one )
proof
assume A2: f is almost-one-to-one ; :: thesis: ( f /^ 1 is one-to-one & f | ((len f) -' 1) is one-to-one )
thus f /^ 1 is one-to-one :: thesis: f | ((len f) -' 1) is one-to-one
proof
let x, y be object ; :: according to FUNCT_1:def 4 :: thesis: ( not x in K70((f /^ 1)) or not y in K70((f /^ 1)) or not (f /^ 1) . x = (f /^ 1) . y or x = y )
assume that
A3: x in dom (f /^ 1) and
A4: y in dom (f /^ 1) and
A5: (f /^ 1) . x = (f /^ 1) . y ; :: thesis: x = y
reconsider i = x, j = y as Nat by A3, A4;
A6: i in Seg (len (f /^ 1)) by A3, FINSEQ_1:def 3;
then A7: 1 <= i by FINSEQ_1:1;
A8: i <= len (f /^ 1) by A6, FINSEQ_1:1;
then (len f) -' 1 >= 1 by A1, A7, XXREAL_0:2;
then A9: (len f) -' 1 = (len f) - 1 by NAT_D:39;
then A10: i + 1 <= len f by A1, A8, XREAL_1:19;
then A11: (f /^ 1) . i = f . (i + 1) by A7, FINSEQ_6:114;
A12: j in Seg (len (f /^ 1)) by A4, FINSEQ_1:def 3;
then A13: 1 <= j by FINSEQ_1:1;
j <= len (f /^ 1) by A12, FINSEQ_1:1;
then A14: j + 1 <= len f by A1, A9, XREAL_1:19;
then A15: (f /^ 1) . j = f . (j + 1) by A13, FINSEQ_6:114;
A16: j + 1 > 1 by A13, NAT_1:13;
then A17: j + 1 in dom f by A14, FINSEQ_3:25;
A18: i + 1 > 1 by A7, NAT_1:13;
then i + 1 in dom f by A10, FINSEQ_3:25;
then i + 1 = j + 1 by A2, A5, A11, A15, A18, A16, A17;
hence x = y ; :: thesis: verum
end;
A19: len (f | ((len f) -' 1)) = (len f) -' 1 by FINSEQ_1:59, NAT_D:35;
thus f | ((len f) -' 1) is one-to-one :: thesis: verum
proof
let x, y be object ; :: according to FUNCT_1:def 4 :: thesis: ( not x in K70((f | ((len f) -' 1))) or not y in K70((f | ((len f) -' 1))) or not (f | ((len f) -' 1)) . x = (f | ((len f) -' 1)) . y or x = y )
assume that
A20: x in dom (f | ((len f) -' 1)) and
A21: y in dom (f | ((len f) -' 1)) and
A22: (f | ((len f) -' 1)) . x = (f | ((len f) -' 1)) . y ; :: thesis: x = y
reconsider i = x, j = y as Nat by A20, A21;
A23: i in Seg (len (f | ((len f) -' 1))) by A20, FINSEQ_1:def 3;
then A24: 1 <= i by FINSEQ_1:1;
A25: j in Seg (len (f | ((len f) -' 1))) by A21, FINSEQ_1:def 3;
then A26: j <= len (f | ((len f) -' 1)) by FINSEQ_1:1;
then A27: (f | ((len f) -' 1)) . j = f . j by A19, FINSEQ_3:112;
A28: i <= len (f | ((len f) -' 1)) by A23, FINSEQ_1:1;
then A29: (f | ((len f) -' 1)) . i = f . i by A19, FINSEQ_3:112;
(len f) -' 1 >= 1 by A19, A24, A28, XXREAL_0:2;
then A30: (len f) -' 1 = (len f) - 1 by NAT_D:39;
then j + 1 <= len f by A19, A26, XREAL_1:19;
then A31: j < len f by NAT_1:13;
1 <= j by A25, FINSEQ_1:1;
then A32: j in dom f by A31, FINSEQ_3:25;
i + 1 <= len f by A19, A28, A30, XREAL_1:19;
then A33: i < len f by NAT_1:13;
then i in dom f by A24, FINSEQ_3:25;
hence x = y by A2, A22, A29, A27, A33, A31, A32; :: thesis: verum
end;
end;
assume that
A34: f /^ 1 is one-to-one and
A35: f | ((len f) -' 1) is one-to-one ; :: thesis: f is almost-one-to-one
let i, j be Nat; :: according to JORDAN23:def 1 :: thesis: ( i in dom f & j in dom f & ( i <> 1 or j <> len f ) & ( i <> len f or j <> 1 ) & f . i = f . j implies i = j )
assume that
A36: i in dom f and
A37: j in dom f and
A38: ( i <> 1 or j <> len f ) and
A39: ( i <> len f or j <> 1 ) and
A40: f . i = f . j ; :: thesis: i = j
A41: 0 + 1 <= i by A36, FINSEQ_3:25;
then A42: i - 1 >= 0 by XREAL_1:19;
A43: i <= len f by A36, FINSEQ_3:25;
then A44: i - 1 <= (len f) - 1 by XREAL_1:9;
then i -' 1 <= (len f) - 1 by A42, XREAL_0:def 2;
then A45: i -' 1 <= (len f) -' 1 by XREAL_0:def 2;
len f = ((len f) -' 1) + 1 by A41, A43, XREAL_1:235, XXREAL_0:2;
then (len f) -' 1 <= len f by NAT_1:13;
then A46: len (f | ((len f) -' 1)) = (len f) -' 1 by FINSEQ_1:59;
A47: j <= len f by A37, FINSEQ_3:25;
then j - 1 <= (len f) - 1 by XREAL_1:9;
then j -' 1 <= (len f) - 1 by A42, A44, XREAL_0:def 2;
then A48: j -' 1 <= (len f) -' 1 by XREAL_0:def 2;
not f is empty by A36;
then A49: f = <*(f /. 1)*> ^ (f /^ 1) by FINSEQ_5:29;
A50: i = (i -' 1) + 1 by A41, XREAL_1:235;
A51: 0 + 1 <= j by A37, FINSEQ_3:25;
then A52: j - 1 >= 0 by XREAL_1:19;
A53: j = (j -' 1) + 1 by A51, XREAL_1:235;
per cases ( ( i <> 1 & j <> 1 ) or i = 1 or j = 1 ) ;
suppose A54: ( i <> 1 & j <> 1 ) ; :: thesis: i = j
end;
suppose A58: i = 1 ; :: thesis: i = j
end;
suppose A63: j = 1 ; :: thesis: i = j
end;
end;