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 Th31:
  p just_once_values x implies for k st k in dom(p - {x}) holds (k
< x..p implies (p - {x}).k = p.k) & (x..p <= k implies (p - {x}).k = p.(k + 1))
proof
  assume
A1: p just_once_values x;
  set q = p - {x};
  let k;
  assume
A2: k in dom(p - {x});
  set A = {L : L in dom p & L <= k & p.L in {x}};
A3: dom(p - {x}) c= dom p by FINSEQ_3:63;
  thus k < x..p implies (p - {x}).k = p.k
  proof
    assume
A4: k < x..p;
    A c= {}
    proof
      let y be object;
      assume y in A;
      then consider L such that
      y = L and
A5:   L in dom p & L <= k and
A6:   p.L in {x};
      p.L <> x by A1,A4,A5,Th26;
      hence thesis by A6,TARSKI:def 1;
    end;
    then
A7: A = {};
    p.k <> x by A1,A2,A3,A4,Th26;
    then not p.k in {x} by TARSKI:def 1;
    then q.(k - 0) = p.k by A2,A3,A7,CARD_1:27,FINSEQ_3:85;
    hence thesis;
  end;
  set B = {M : M in dom p & M <= k + 1 & p.M in {x}};
  assume
A8: x..p <= k;
A9: x in rng p by A1,Th5;
A10: B = {x..p}
  proof
    thus B c= {x..p}
    proof
      let y be object;
      assume y in B;
      then consider M such that
A11:  M = y and
A12:  M in dom p and
      M <= k + 1 and
A13:  p.M in {x};
      p.M = x by A13,TARSKI:def 1;
      then M = x..p by A1,A12,Th26;
      hence thesis by A11,TARSKI:def 1;
    end;
    let y be object;
    assume y in {x..p};
    then
A14: y = x..p by TARSKI:def 1;
    p.(x..p) = x by A9,Th19;
    then
A15: p.(x..p) in {x} by TARSKI:def 1;
    x..p in dom p & x..p <= k + 1 by A9,A8,Th20,NAT_1:12;
    hence thesis by A14,A15;
  end;
  then reconsider B as finite set;
  dom q = Seg(len q) & len(p - {x}) = len p - 1 by A1,Th30,FINSEQ_1:def 3;
  then k <= len p - 1 by A2,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
A16: k + 1 in dom p by FINSEQ_1:def 3;
  now
    x..p <> k + 1 by A8,XREAL_1:29;
    then
A17: p.(k + 1) <> x by A1,A16,Th26;
    assume p.(k + 1) in {x};
    hence contradiction by A17,TARSKI:def 1;
  end;
  then (p - {x}).((k + 1) - card B) = p.(k + 1) by A16,FINSEQ_3:85;
  then q.((k + 1) - 1) = p.(k + 1) by A10,CARD_1:30;
  hence thesis;
end;
