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