reserve x,y,z for set;
reserve f,f1,f2,f3 for FinSequence,
  p,p1,p2,p3 for set,
  i,k for Nat;
reserve D for non empty set,
  p,p1,p2,p3 for Element of D,
  f,f1,f2 for FinSequence of D;
reserve D for non empty set;
reserve p, q for FinSequence,
  X, Y, x, y for set,
  D for non empty set,
  i, j, k, l, m, n, r for Nat;
reserve a, a1, a2 for TwoValued Alternating FinSequence;
reserve fs, fs1, fs2 for FinSequence of X,
  fss, fss2 for Subset of fs;
reserve F, F1 for FinSequence of INT,
  k, m, n, ma for Nat;

theorem
  k+1 <= len F & ma = min_at(F, k+1, len F) & F is_split_at k &
  F is_non_decreasing_on 1, k & F1 = F+*(k+1, F.ma)+*(ma, F.(k+1))
  implies F1 is_non_decreasing_on 1, k+1
proof
  assume that
A1: k+1 <= len F and
A2: ma = min_at(F, k+1, len F) and
A3: F is_split_at k and
A4: F is_non_decreasing_on 1, k and
A5: F1 = F+*(k+1, F.ma)+*(ma, F.(k+1));
A6: 1 <= k+1 by NAT_1:12;
  set Fk = F+*(k+1, F.ma);
A7: dom F1 = dom Fk by A5,FUNCT_7:30;
A8: dom Fk = dom F by FUNCT_7:30;
  then
A9: k+1 in dom F1 by A1,A7,A6,FINSEQ_3:25;
  let i, j be Nat such that
A10: 1 <= i and
A11: i <= j and
A12: j <= k+1;
A13: j <= len F by A1,A12,XXREAL_0:2;
  1 <= j by A10,A11,XXREAL_0:2;
  then
A14: j in dom F1 by A7,A8,A13,FINSEQ_3:25;
  per cases by A12,XXREAL_0:1;
  suppose
A15: j < k+1;
    then i < k+1 by A11,XXREAL_0:2;
    then i <> ma by A1,A2,A6,Th59;
    then
A16: F1.i = Fk.i by A5,FUNCT_7:32
      .= F.i by A11,A15,FUNCT_7:32;
    j <> ma by A1,A2,A6,A15,Th59;
    then
A17: F1.j = Fk.j by A5,FUNCT_7:32
      .= F.j by A15,FUNCT_7:32;
    j <= k by A15,NAT_1:13;
    hence thesis by A4,A10,A11,A16,A17;
  end;
  suppose
A18: j = k+1;
    thus F1.i <= F1.j
    proof
      per cases by A11,XXREAL_0:1;
      suppose
A19:    i < j;
        then i <> ma by A1,A2,A6,A18,Th59;
        then
A20:    F1.i = Fk.i by A5,FUNCT_7:32
          .= F.i by A18,A19,FUNCT_7:32;
A21:    i <= k by A18,A19,NAT_1:13;
A22:    k < j by A18,NAT_1:13;
        thus F1.i <= F1.j
        proof
          per cases;
          suppose
            k+1 = ma;
            then F1.j = F.(k+1) by A5,A7,A9,A18,FUNCT_7:31;
            hence thesis by A1,A3,A10,A18,A20,A21,A22;
          end;
          suppose
A23:        k+1 <> ma;
A24:        ma <= len F by A1,A2,A6,Th59;
            k+1 <= ma by A1,A2,A6,Th59;
            then
A25:        k < ma by NAT_1:13;
            F1.j = Fk.j by A5,A18,A23,FUNCT_7:32
              .= F.ma by A7,A8,A14,A18,FUNCT_7:31;
            hence thesis by A3,A10,A20,A21,A25,A24;
          end;
        end;
      end;
      suppose
        i = j;
        hence thesis;
      end;
    end;
  end;
end;
