
theorem Th11:
  for D being non empty set, f,g being FinSequence of D, n being Nat
  st g is_substring_of f,n holds len g = 0 or
    (1 <= n-'1+len g & n-'1+len g <= len f & n <= n-'1+len g)
proof
  let D be non empty set, f,g be FinSequence of D, n be Nat;
  assume A1: g is_substring_of f,n;
  per cases;
  suppose A2: len g > 0;
    then consider i being Nat such that
      A3: n<=i & i<=len f and
      A4: mid(f,i,(i-'1)+len g)=g by A1,FINSEQ_8:def 7;
    A5: 1 <= n-'1+len g by A2, NAT_1:14;
    A6: n <= n-'1+len g
    proof
      A7: n-'1+1 <= n-'1+len g by A2, NAT_1:14, XREAL_1:6;
      per cases;
      suppose n-'1 >= 1;
        hence n <= n-'1+len g by A7, NAT_D:43;
      end;
      suppose n-'1 < 1;
        then A8: n-'1 = 0 by NAT_1:14;
        then n <= 0+1 by NAT_D:36;
        then per cases by NAT_1:9;
        suppose n = 0;
          hence thesis;
        end;
        suppose n = 1;
          hence n <= n-'1+len g by A7, A8;
        end;
      end;
    end;
    A9: (i-'1)+len g <= len f by A3, A4, Th6;
    n-'1 <= i-'1 by A3, NAT_D:42;
    then (n-'1)+len g <= (i-'1)+len g by XREAL_1:6;
    hence thesis by A5, A6, A9, XXREAL_0:2;
  end;
  suppose len g = 0;
    hence thesis;
  end;
end;
