reserve a,b,c for set;

theorem Th41:
  for D being non empty set,f,g being FinSequence of D, n being
Element of NAT st g is_substring_of f|n,1 & len g>0 holds g is_substring_of f,1
proof
  let D be non empty set,f,g be FinSequence of D,n be Element of NAT;
  assume that
A1: g is_substring_of f|n,1 and
A2: len g>0;
  consider i2 being Nat such that
A3: 1<=i2 and
A4: i2<=len (f|n) and
A5: mid(f|n,i2,(i2-'1)+len g)=g by A1,A2,FINSEQ_8:def 7;
  len g>= 0+1 by A2,NAT_1:13;
  then len g -1>=0 by XREAL_1:48;
  then
A6: len g-1+i2>=0+i2 by XREAL_1:7;
  then
A7: i2-1+len g >=i2;
  per cases;
  suppose
A8: len f>=n;
    (i2-'1)+len g=(i2-1)+len g by A3,XREAL_1:233;
    then
A9: (i2-'1)+len g-'i2+1 = (i2-1)+len g-i2+1 by A6,XREAL_1:233
      .= len g;
    i2-1>=0 by A3,XREAL_1:48;
    then
A10: i2<=(i2-'1)+len g by A7,XREAL_0:def 2;
    then
A11: g = ((f|n)/^(i2-'1))|((i2-'1)+len g-'i2+1) by A5,FINSEQ_6:def 3
      .=((f/^(i2-'1))|(n-'(i2-'1)))|len g by A9,FINSEQ_5:80;
    now
A12:  len (f/^(i2-'1))=len f -'(i2-'1) by RFINSEQ:29;
      assume
A13:  n-'(i2-'1)<len g;
      then g=((f/^(i2-'1))|(n-'(i2-'1))) by A11,FINSEQ_5:77;
      hence contradiction by A8,A13,A12,FINSEQ_1:59,NAT_D:42;
    end;
    then
A14: g=(f/^(i2-'1))|len g by A11,FINSEQ_5:77
      .= mid(f,i2,(i2-'1)+len g) by A10,A9,FINSEQ_6:def 3;
    len (f|n)<=len f by FINSEQ_5:16;
    then i2<=len f by A4,XXREAL_0:2;
    hence thesis by A3,A14,FINSEQ_8:def 7;
  end;
  suppose
    len f<n;
    hence thesis by A1,FINSEQ_1:58;
  end;
end;
