reserve p,q,r for FinSequence;
reserve u,v,x,y,y1,y2,z for object, A,D,X,Y for set;
reserve i,j,k,l,m,n for Nat;
reserve J for Nat;

theorem Th106:
  for i,k,m,n being Nat st n=m+1 & k in Seg n & i in Seg m holds
  (1<=i & i<k implies Sgm(Seg n \ {k}).i = i) &
  (k<=i & i<=m implies Sgm(Seg n \ {k}).i = i+1)
proof
  defpred P[Nat] means for n,k,i being Nat st n = $1 + 1
& k in Seg n & i in Seg $1 holds (1<=i & i<k implies Sgm(Seg n \ {k}).i = i) &
  (k<=i & i<=$1implies Sgm(Seg n \ {k}).i = i+1);
  let i,k,m,n be Nat;
  assume that
A1: n = m + 1 and
A2: k in Seg n and
A3: i in Seg m;
A4: for k being Nat st P[k] holds P[k+1]
  proof
    let k being Nat such that
A5: P[k];
    let g,i,n be Nat;
    assume that
A6: g = k+1 + 1 and
A7: i in Seg g and
A8: n in Seg(k+1);
A9: 1<=i by A7,FINSEQ_1:1;
    set X = Seg g \ {i};
A10: len Sgm(X)=k+1 by A6,A7,Th105;
A11: 1<=n by A8,FINSEQ_1:1;
A12: i<=g by A7,FINSEQ_1:1;
A13: X c= Seg g by XBOOLE_1:36;
A14: rng Sgm(X) = X by FINSEQ_1:def 14;
A15: n<=k+1 by A8,FINSEQ_1:1;
    now
      per cases;
      suppose
A16:    i=g; then
A17:    k+1<i by A6,NAT_1:13;
        X = Seg(k+1)
        proof
          thus X c= Seg(k+1)
          proof
            let x be object;
A18:        Seg g = {J: 1<=J & J<= g} by FINSEQ_1:def 1;
            assume
A19:        x in X;
            then x in Seg g by XBOOLE_0:def 5;
            then consider J such that
A20:        x=J and
A21:        1<=J and
A22:        J<=g by A18;
            not x in {i} by A19,XBOOLE_0:def 5;
            then x<>i by TARSKI:def 1;
            then J<g by A16,A20,A22,XXREAL_0:1;
            then J<=k+1 by A6,NAT_1:13;
            hence thesis by A20,A21,FINSEQ_1:1;
          end;
          let x be object;
          assume x in Seg(k+1);
          then x in {J: 1<=J & J<=k+1} by FINSEQ_1:def 1;
          then consider J such that
A23:      x=J and
A24:      1<=J and
A25:      J<=k+1;
          k+1<=g by A6,NAT_1:11;
          then J<=g by A25,XXREAL_0:2;
          then
A26:      J in Seg g by A24,FINSEQ_1:1;
          not J in {i} by A17,A25,TARSKI:def 1;
          hence thesis by A23,A26,XBOOLE_0:def 5;
        end;
        then Sgm X = idseq (k+1) by Th46;
        hence 1<=n & n<i implies Sgm(X).n = n by A8,FUNCT_1:17;
        thus i<=n & n<=k+1 implies Sgm(Seg g \ {i}).n = n+1 by A6,A16,NAT_1:13;
      end;
      suppose
A27:    i<>g;
        set A = {l where l is Nat : 1<=l & l<=g & l<>i};
A28:    X = A
        proof
          thus X c= A
          proof
            let x be object;
A29:        Seg g= {J: 1<=J & J<=g } by FINSEQ_1:def 1;
            assume
A30:        x in X;
            then x in Seg g by XBOOLE_0:def 5;
            then consider m being Nat such that
A31:        x=m and
A32:        1<=m and
A33:        m<=g by A29;
            not x in {i} by A30,XBOOLE_0:def 5;
            then m<>i by A31,TARSKI:def 1;
            hence thesis by A31,A32,A33;
          end;
          let x be object;
          assume x in A;
          then consider m being Nat such that
A34:      x=m and
A35:      1<=m and
A36:      m<=g and
A37:      m<>i;
A38:      not m in {i} by A37,TARSKI:def 1;
          m in Seg g by A35,A36,FINSEQ_1:1;
          hence thesis by A34,A38,XBOOLE_0:def 5;
        end;
        1<=k+1 by A11,A15,XXREAL_0:2;
        then k+1 in dom Sgm(X) by A10,Th25;
        then Sgm(X).(k+1) in X by A14,FUNCT_1:def 3;
        then
A39:    ex J st Sgm(X).(k+1) = J & 1<=J & J<=g & J<>i by A28;
        1<=g by A9,A12,XXREAL_0:2;
        then g in rng Sgm(X) by A14,A27,A28;
        then consider x be Nat such that
A40:    x in dom Sgm(X) and
A41:    Sgm(X).x=g by FINSEQ_2:10;
        1<=x by A40,Th25;
        then
A42:    k+1<=x by A10,A39,A41,FINSEQ_1:def 14;
A43:    i<g by A12,A27,XXREAL_0:1;
        then
A44:    i<=k+1 by A6,NAT_1:13;
A45:    x<=k+1 by A10,A40,Th25;
        now
          per cases by A15,XXREAL_0:1;
          suppose
A46:        n=k+1;
            hence 1<=n & n<i implies Sgm(X).n = n by A6,A43,NAT_1:13;
            thus i<=n & n<=k+1 implies Sgm(Seg g \ {i}).n=n+1 by A6,A41,A45,A42
,A46,XXREAL_0:1;
          end;
          suppose
A47:        n<k+1;
            set Y = Seg(k+1) \ {i};
A48:        now
              let j1,j be Nat;
              assume that
A49:          j1 in Y and
A50:          j in {g};
              j1 in Seg(k+1) by A49,XBOOLE_0:def 5;
              then
A51:          j1<=k+1 by FINSEQ_1:1;
              j=g by A50,TARSKI:def 1;
              hence j1<j by A6,A51,NAT_1:13;
            end;
A52:        X = Y \/ {g}
            proof
              thus X c= Y \/ {g}
              proof
                let x be object;
                assume x in X;
                then consider J such that
A53:            x=J and
A54:            1<=J and
A55:            J<=g and
A56:            J<>i by A28;
                now
                  per cases by A55,XXREAL_0:1;
                  suppose
                    J=g;
                    then x in {g} by A53,TARSKI:def 1;
                    hence thesis by XBOOLE_0:def 3;
                  end;
                  suppose
                    J<g;
                    then J<=k+1 by A6,NAT_1:13;
                    then
A57:                J in Seg(k+1) by A54,FINSEQ_1:1;
                    not J in {i} by A56,TARSKI:def 1;
                    then x in Y by A53,A57,XBOOLE_0:def 5;
                    hence thesis by XBOOLE_0:def 3;
                  end;
                end;
                hence thesis;
              end;
              let x be object such that
A58:          x in Y \/ {g};
              now
                per cases by A58,XBOOLE_0:def 3;
                suppose
A59:              x in Y;
A60:              Seg(k+1)={ s where s is Nat :1<=s & s<=k+1}
                  by FINSEQ_1:def 1;
                  x in Seg(k+1) by A59,XBOOLE_0:def 5;
                  then consider s be Nat such that
A61:              x=s and
A62:              1<=s and
A63:              s<=k+1 by A60;
                  not x in {i} by A59,XBOOLE_0:def 5;
                  then
A64:              s<>i by A61,TARSKI:def 1;
                  k+1<=g by A6,NAT_1:11;
                  then s<=g by A63,XXREAL_0:2;
                  hence thesis by A28,A61,A62,A64;
                end;
                suppose
                  x in {g};
                  then
A65:              x=g by TARSKI:def 1;
                  1<=g by A9,A12,XXREAL_0:2;
                  hence thesis by A27,A28,A65;
                end;
              end;
              hence thesis;
            end;
            then {g} c= X by XBOOLE_1:7;
            then {g} c= Seg g by A13;
            then
            {g} is included_in_Seg by FINSEQ_1:def 13;
            then
A67:        Sgm(X) = Sgm(Y)^Sgm({g}) by A52,A48,Th40;
            n<=k by A47,NAT_1:13;
            then
A68:        n in Seg k by A11,FINSEQ_1:1;
A69:        i in Seg(k+1) by A9,A44,FINSEQ_1:1;
            then len Sgm(Y) = k by Th105;
            then
A70:        n in dom Sgm(Y) by A68,FINSEQ_1:def 3;
            n<=k by A47,NAT_1:13;
            then
A71:        n in Seg k by A11,FINSEQ_1:1;
            then
A72:        1<=n & n<i implies Sgm(Seg(k+1) \ {i}).n = n by A5,A69;
            now
              assume that
A73:          1<=n and
A74:          n<i;
              n in Seg len Sgm(Y) by A71,A69,Th105;
              then n in dom Sgm(Y) by FINSEQ_1:def 3;
              hence Sgm(X).n = n by A72,A67,A73,A74,FINSEQ_1:def 7;
            end;
            hence 1<=n & n<i implies Sgm(X).n = n;
            assume that
A75:        i<=n and
            n<=k+1;
            i<=n & n<=k implies Sgm(Seg(k+1) \ {i}).n = n+1 by A5,A71,A69;
            hence Sgm(X).n = n+1 by A47,A67,A75,A70,FINSEQ_1:def 7,NAT_1:13;
          end;
        end;
        hence thesis;
      end;
    end;
    hence thesis;
  end;
A76: P[0];
  for k being Nat holds P[k] from NAT_1:sch 2(A76,A4);
  hence thesis by A1,A2,A3;
end;
