reserve n,m,k for Nat;
reserve r,r1 for Real;
reserve f,seq,seq1 for Real_Sequence;
reserve x,y for set;
reserve e1,e2 for ExtReal;
reserve Nseq for increasing sequence of NAT;
reserve v for FinSequence of REAL,
  r,s for Real,
  n,m,i,j,k for Nat;

theorem Th44:
  v<>{} & rng v c= Seg n & v.(len v) = n & (for k st 1<=k & k<=len
v - 1 holds for r,s st r = v.k & s = v.(k+1) holds |.r-s.| = 1 or r=s) & i in
  Seg n & i+1 in Seg n & m in dom v & v.m = i & (for k st k in dom v & v.k = i
  holds k<=m) implies m+1 in dom v & v.(m+1)=i+1
proof
  assume that
A1: v<>{} and
A2: rng v c= Seg n and
A3: v.(len v) = n and
A4: for k st 1<=k & k<=len v - 1 holds for r,s st r = v.k & s = v.(k+1)
  holds |.r-s.| = 1 or r=s and
A5: i in Seg n and
A6: i+1 in Seg n and
A7: m in dom v and
A8: v.m = i and
A9: for k st k in dom v & v.k = i holds k<=m;
A10: m<=len v by A7,FINSEQ_3:25;
  0+1<=len v by A1,NAT_1:13;
  then
A11: len v in dom v by FINSEQ_3:25;
  reconsider r=v.(m+1) as Real;
A12: i<=n by A5,FINSEQ_1:1;
A13: 1<=m by A7,FINSEQ_3:25;
A14: i+1<=n by A6,FINSEQ_1:1;
A15: now
    assume not m+1 in dom v;
    then 1>m+1 or m+1>len v by FINSEQ_3:25;
    then
A16: len v <=m by NAT_1:11,13;
    i<n by A14,NAT_1:13;
    hence contradiction by A3,A8,A10,A16,XXREAL_0:1;
  end;
  then
A17: m+1<=len v by FINSEQ_3:25;
  then
A18: m<len v by NAT_1:13;
A19: m<=len v - 1 by A17,XREAL_1:19;
  now
    per cases by A4,A8,A13,A19;
    case
A20:  |.i - r.| = 1;
      now
        per cases by A20,Th40;
        case
A21:      i>r & i=r+1;
          defpred P[set] means for k,r st k=$1 & k>0 & m+k in dom v & r=v.(m+k
          ) holds r<i;
A22:      for k st P[k] holds P[k+1]
          proof
            let k such that
A23:        P[k];
            let j,s such that
A24:        j=k+1 and
A25:        j>0 and
A26:        m+j in dom v and
A27:        s=v.(m+j);
            now
              per cases;
              suppose
                k=0;
                hence thesis by A21,A24,A27;
              end;
              suppose
A28:            k<>0;
A29:            m+k<=m+k+1 by NAT_1:11;
                m<=m+k by NAT_1:11;
                then
A30:            1<=m+k by A13,XXREAL_0:2;
A31:            m+(k+1)<=len v by A24,A26,FINSEQ_3:25;
                then m+k<=len v by A29,XXREAL_0:2;
                then
A32:            m+k in dom v by A30,FINSEQ_3:25;
                then v.(m+k) in rng v by FUNCT_1:def 3;
                then v.(m+k) in Seg n by A2;
                then reconsider r1=v.(m+k) as Element of NAT;
A33:            r1<i by A23,A28,A32;
A34:            m+k<=len v - 1 by A29,A31,XREAL_1:19;
                now
                  per cases by A4,A24,A27,A29,A30,A34;
                  suppose
A35:                |.r1-s.|=1;
                    now
                      per cases by A35,Th40;
                      suppose
                        r1>s & r1=s+1;
                        hence thesis by A33,XXREAL_0:2;
                      end;
                      suppose
                        r1<s & s=r1+1;
                        then
A36:                    s<=i by A33,NAT_1:13;
                        now
                          per cases by A36,XXREAL_0:1;
                          case
                            s<i;
                            hence thesis;
                          end;
                          case
                            s=i;
                            then m+j<=m by A9,A26,A27;
                            then j<=m-m by XREAL_1:19;
                            hence contradiction by A25;
                          end;
                        end;
                        hence thesis;
                      end;
                    end;
                    hence thesis;
                  end;
                  suppose
                    r1=s;
                    hence thesis by A23,A28,A32;
                  end;
                end;
                hence thesis;
              end;
            end;
            hence thesis;
          end;
          reconsider l = len v - m as Element of NAT by A18,INT_1:5;
A37:      0< len v - m & m+l = len v by A17,XREAL_1:19;
A38:      P[0];
          for k holds P[k] from NAT_1:sch 2(A38,A22);
          hence contradiction by A3,A11,A12,A37;
        end;
        case
          i<r & r=i+1;
          hence thesis by A15;
        end;
      end;
      hence thesis;
    end;
    case
      i=r;
      then m+1<=m by A9,A15;
      then 1<=m-m by XREAL_1:19;
      then 1<=0;
      hence contradiction;
    end;
  end;
  hence thesis;
end;
