reserve f for Function;
reserve p,q for FinSequence;
reserve A,B,C for set,x,x1,x2,y,z for object;
reserve k,l,m,n for Nat;
reserve a for Nat;
reserve D for non empty set;
reserve d,d1,d2,d3 for Element of D;
reserve L,M for Element of NAT;

theorem
  p is one-to-one & x in rng p implies for k st k in dom(p - {x}) holds
  ((p - {x}).k = p.k iff k < x..p) & ((p - {x}).k = p.(k + 1) iff x..p <= k)
proof
  assume that
A1: p is one-to-one and
A2: x in rng p;
  set q = p - {x};
  let k;
  assume
A3: k in dom(p - {x});
A4: p just_once_values x by A1,A2,Th8;
  then dom q = Seg(len q) & len(p - {x}) = len p - 1 by Th30,FINSEQ_1:def 3;
  then k <= len p - 1 by A3,FINSEQ_1:1;
  then 1 <= k + 1 & k + 1 <= len p by NAT_1:12,XREAL_1:19;
  then k + 1 in Seg(len p);
  then
A5: dom(p - {x}) c= dom p & k + 1 in dom p by FINSEQ_1:def 3,FINSEQ_3:63;
  thus (p - {x}).k = p.k implies k < x..p
  proof
    assume that
A6: (p - {x}).k = p.k and
A7: not k < x..p;
    q.k = p.(k + 1) by A4,A3,A7,Th31;
    then k + 0 = k + 1 by A1,A3,A5,A6;
    hence thesis;
  end;
  thus k < x..p implies (p - {x}).k = p.k by A4,A3,Th31;
  thus (p - {x}).k = p.(k + 1) implies x..p <= k
  proof
    assume
A8: (p - {x}).k = p.(k + 1);
    assume not x..p <= k;
    then p.(k + 1) = p.k by A4,A3,A8,Th31;
    then k + 0 = k + 1 by A1,A3,A5;
    hence thesis;
  end;
  thus thesis by A4,A3,Th31;
end;
