
theorem Th14:
  for n be Nat st n >= 1 holds for k be Nat st k >= 2 holds for tx
,ty,tz,tw be Tuple of n,k-SD st (for i be Nat st i in Seg n holds (DigA(tx,i) =
DigA(tz,i) & DigA(ty,i) = DigA(tw,i)) or (DigA(ty,i) = DigA(tz,i) & DigA(tx,i)
  = DigA(tw,i))) holds SDDec(tz) + SDDec(tw) = SDDec(tx) + SDDec(ty)
proof
  defpred P[Nat] means for k be Nat st k >= 2 holds for tx,ty,tz,tw be Tuple
  of $1,k-SD st (for i be Nat st i in Seg $1 holds (DigA(tx,i) = DigA(tz,i) &
DigA(ty,i) = DigA(tw,i)) or (DigA(ty,i) = DigA(tz,i) & DigA(tx,i) = DigA(tw,i))
  ) holds SDDec(tz) + SDDec(tw) = SDDec(tx) + SDDec(ty);
A1: for n be Nat st n >= 1 & P[n] holds P[n+1]
  proof
    let n be Nat;
    assume that
    n >= 1 and
A2: P[n];
    let k be Nat;
    assume
A3: k >= 2;
    let tx,ty,tz,tw be Tuple of (n+1),k-SD;
    assume
A4: for i be Nat st i in Seg (n+1) holds DigA(tx,i) = DigA(tz,i) &
DigA(ty,i) = DigA(tw,i) or DigA(ty,i) = DigA(tz,i) & DigA(tx,i) = DigA(tw,i);
    deffunc F(Nat) = DigB(tx,$1);
    consider txn being FinSequence of INT such that
A5: len txn = n and
A6: for i be Nat st i in dom txn holds txn.i = F(i) from FINSEQ_2:sch
    1;
A7: dom txn = Seg n by A5,FINSEQ_1:def 3;
    rng txn c= k-SD
    proof
      let z be object;
      assume z in rng txn;
      then consider xx be object such that
A8:   xx in dom txn and
A9:   z = txn.xx by FUNCT_1:def 3;
      reconsider xx as Element of NAT by A8;
      dom txn = Seg n by A5,FINSEQ_1:def 3;
      then xx in Seg (n+1) by A8,FINSEQ_2:8;
      then
A10:  DigA(tx,xx) is Element of k-SD by RADIX_1:16;
      z = DigB(tx,xx) by A6,A8,A9
        .= DigA(tx,xx) by RADIX_1:def 4;
      hence thesis by A10;
    end;
    then reconsider txn as FinSequence of k-SD by FINSEQ_1:def 4;
A11: for i be Nat st i in Seg n holds txn.i = tx.i
    proof
      let i be Nat;
      assume
A12:  i in Seg n;
      then
A13:  i in Seg (n+1) by FINSEQ_2:8;
      txn.i = DigB(tx,i) by A6,A7,A12
        .= DigA(tx,i) by RADIX_1:def 4;
      hence thesis by A13,RADIX_1:def 3;
    end;
    deffunc F(Nat) = DigB(ty,$1);
    consider tyn being FinSequence of INT such that
A14: len tyn = n and
A15: for i be Nat st i in dom tyn holds tyn.i = F(i) from FINSEQ_2:sch
    1;
A16: dom tyn = Seg n by A14,FINSEQ_1:def 3;
    rng tyn c= k-SD
    proof
      let z be object;
      assume z in rng tyn;
      then consider yy be object such that
A17:  yy in dom tyn and
A18:  z = tyn.yy by FUNCT_1:def 3;
      reconsider yy as Element of NAT by A17;
      dom tyn = Seg n by A14,FINSEQ_1:def 3;
      then yy in Seg (n+1) by A17,FINSEQ_2:8;
      then
A19:  DigA(ty,yy) is Element of k-SD by RADIX_1:16;
      z = DigB(ty,yy) by A15,A17,A18
        .= DigA(ty,yy) by RADIX_1:def 4;
      hence thesis by A19;
    end;
    then reconsider tyn as FinSequence of k-SD by FINSEQ_1:def 4;
A20: for i be Nat st i in Seg n holds tyn.i = ty.i
    proof
      let i be Nat;
      assume
A21:  i in Seg n;
      then
A22:  i in Seg (n+1) by FINSEQ_2:8;
      tyn.i = DigB(ty,i) by A15,A16,A21
        .= DigA(ty,i) by RADIX_1:def 4;
      hence thesis by A22,RADIX_1:def 3;
    end;
    deffunc F(Nat) = DigB(tz,$1);
    consider tzn being FinSequence of INT such that
A23: len tzn = n and
A24: for i be Nat st i in dom tzn holds tzn.i = F(i) from FINSEQ_2:sch
    1;
A25: dom tzn = Seg n by A23,FINSEQ_1:def 3;
    rng tzn c= k-SD
    proof
      let z be object;
      assume z in rng tzn;
      then consider zz be object such that
A26:  zz in dom tzn and
A27:  z = tzn.zz by FUNCT_1:def 3;
      reconsider zz as Element of NAT by A26;
      dom tzn = Seg n by A23,FINSEQ_1:def 3;
      then zz in Seg (n+1) by A26,FINSEQ_2:8;
      then
A28:  DigA(tz,zz) is Element of k-SD by RADIX_1:16;
      z = DigB(tz,zz) by A24,A26,A27
        .= DigA(tz,zz) by RADIX_1:def 4;
      hence thesis by A28;
    end;
    then reconsider tzn as FinSequence of k-SD by FINSEQ_1:def 4;
A29: for i be Nat st i in Seg n holds tzn.i = tz.i
    proof
      let i be Nat;
      assume
A30:  i in Seg n;
      then
A31:  i in Seg (n+1) by FINSEQ_2:8;
      tzn.i = DigB(tz,i) by A24,A25,A30
        .= DigA(tz,i) by RADIX_1:def 4;
      hence thesis by A31,RADIX_1:def 3;
    end;
    deffunc F(Nat) = DigB(tw,$1);
    consider twn being FinSequence of INT such that
A32: len twn = n and
A33: for i be Nat st i in dom twn holds twn.i = F(i) from FINSEQ_2:sch
    1;
A34: dom twn = Seg n by A32,FINSEQ_1:def 3;
    rng twn c= k-SD
    proof
      let w be object;
      assume w in rng twn;
      then consider ww be object such that
A35:  ww in dom twn and
A36:  w = twn.ww by FUNCT_1:def 3;
      reconsider ww as Element of NAT by A35;
      dom twn = Seg n by A32,FINSEQ_1:def 3;
      then ww in Seg (n+1) by A35,FINSEQ_2:8;
      then
A37:  DigA(tw,ww) is Element of k-SD by RADIX_1:16;
      w = DigB(tw,ww) by A33,A35,A36
        .= DigA(tw,ww) by RADIX_1:def 4;
      hence thesis by A37;
    end;
    then reconsider twn as FinSequence of k-SD by FINSEQ_1:def 4;
A38: for i be Nat st i in Seg n holds twn.i = tw.i
    proof
      let i be Nat;
      assume
A39:  i in Seg n;
      then
A40:  i in Seg (n+1) by FINSEQ_2:8;
      twn.i = DigB(tw,i) by A33,A34,A39
        .= DigA(tw,i) by RADIX_1:def 4;
      hence thesis by A40,RADIX_1:def 3;
    end;
    reconsider n as Element of NAT by ORDINAL1:def 12;
    twn is Element of n-tuples_on (k-SD) by A32,FINSEQ_2:92;
    then reconsider twn as Tuple of n,k-SD;
        tzn is Element of n-tuples_on (k-SD) by A23,FINSEQ_2:92;
    then reconsider tzn as Tuple of n,k-SD;
        tyn is Element of n-tuples_on (k-SD) by A14,FINSEQ_2:92;
    then reconsider tyn as Tuple of n,k-SD;
A41: SDDec(tyn) + (Radix(k) |^ n)*DigA(ty,n+1) = SDDec(ty) by A20,RADIX_2:10;
    n+1 in Seg (n+1) by FINSEQ_1:3;
    then
A42: DigA(tx,n+1) = DigA(tz,n+1) & DigA(ty,n+1) = DigA(tw,n+1) or DigA(ty,
    n+1) = DigA(tz,n+1) & DigA(tx,n+1) = DigA(tw,n+1) by A4;
A43: SDDec(twn) + (Radix(k) |^ n)*DigA(tw,n+1) = SDDec(tw) by A38,RADIX_2:10;
A44: SDDec(tzn) + (Radix(k) |^ n)*DigA(tz,n+1) = SDDec(tz) by A29,RADIX_2:10;
        txn is Element of n-tuples_on (k-SD) by A5,FINSEQ_2:92;
    then reconsider txn as Tuple of n,k-SD;
    for i be Nat st i in Seg n holds DigA(txn,i) = DigA(tzn,i) & DigA(tyn
    ,i) = DigA(twn,i) or DigA(tyn,i) = DigA(tzn,i) & DigA(txn,i) = DigA(twn,i)
    proof
      let i be Nat;
      assume
A45:  i in Seg n;
      then i <= n by FINSEQ_1:1;
      then
A46:  i <= n + 1 by NAT_1:12;
      1 <= i by A45,FINSEQ_1:1;
      then
A47:  i in Seg (n+1) by A46,FINSEQ_1:1;
      then
A48:  DigA(ty,i) = ty.i by RADIX_1:def 3
        .= tyn.i by A20,A45
        .= DigA(tyn,i) by A45,RADIX_1:def 3;
A49:  DigA(tw,i) = tw.i by A47,RADIX_1:def 3
        .= twn.i by A38,A45
        .= DigA(twn,i) by A45,RADIX_1:def 3;
A50:  DigA(tz,i) = tz.i by A47,RADIX_1:def 3
        .= tzn.i by A29,A45
        .= DigA(tzn,i) by A45,RADIX_1:def 3;
      DigA(tx,i) = tx.i by A47,RADIX_1:def 3
        .= txn.i by A11,A45
        .= DigA(txn,i) by A45,RADIX_1:def 3;
      hence thesis by A4,A47,A48,A50,A49;
    end;
    then
A51: SDDec(tzn) + SDDec(twn) = SDDec(txn) + SDDec(tyn) by A2,A3;
    SDDec(txn) + (Radix(k) |^ n)*DigA(tx,n+1) = SDDec(tx) by A11,RADIX_2:10;
    hence thesis by A41,A44,A43,A51,A42;
  end;
A52: P[1]
  proof
    let k be Nat;
    assume
A53: k >= 2;
    let tx,ty,tz,tw be Tuple of 1,k-SD;
A54: 1 in Seg 1 by FINSEQ_1:1;
A55: SDDec(tx '+' ty) = DigA(tx '+' ty,1) by Th4
      .= Add(tx,ty,1,k) by A54,RADIX_1:def 14
      .= SD_Add_Data(DigA(tx,1)+DigA(ty,1),k) + SD_Add_Carry(DigA(tx,1-'1)+
    DigA(ty,1-'1)) by A53,A54,RADIX_1:def 13
      .= SD_Add_Data(DigA(tx,1)+DigA(ty,1),k) + SD_Add_Carry(DigA(tx,0)+DigA
    (ty,1-'1)) by XREAL_1:232
      .= SD_Add_Data(DigA(tx,1)+DigA(ty,1),k) + SD_Add_Carry(DigA(tx,0)+DigA
    (ty,0)) by XREAL_1:232
      .= SD_Add_Data(DigA(tx,1)+DigA(ty,1),k) + SD_Add_Carry(DigA(tx,0)+0)
    by RADIX_1:def 3
      .= SD_Add_Data(DigA(tx,1)+DigA(ty,1),k) + SD_Add_Carry(0+0) by
RADIX_1:def 3
      .= SD_Add_Data(DigA(tx,1)+DigA(ty,1),k) + 0 by RADIX_1:def 10;
A56: SDDec(tz '+' tw) = DigA(tz '+' tw,1) by Th4
      .= Add(tz,tw,1,k) by A54,RADIX_1:def 14
      .= SD_Add_Data(DigA(tz,1)+DigA(tw,1),k) + SD_Add_Carry(DigA(tz,1-'1)+
    DigA(tw,1-'1)) by A53,A54,RADIX_1:def 13
      .= SD_Add_Data(DigA(tz,1)+DigA(tw,1),k) + SD_Add_Carry(DigA(tz,0)+DigA
    (tw,1-'1)) by XREAL_1:232
      .= SD_Add_Data(DigA(tz,1)+DigA(tw,1),k) + SD_Add_Carry(DigA(tz,0)+DigA
    (tw,0)) by XREAL_1:232
      .= SD_Add_Data(DigA(tz,1)+DigA(tw,1),k) + SD_Add_Carry(DigA(tz,0)+0)
    by RADIX_1:def 3
      .= SD_Add_Data(DigA(tz,1)+DigA(tw,1),k) + SD_Add_Carry(0+0) by
RADIX_1:def 3
      .= SD_Add_Data(DigA(tz,1)+DigA(tw,1),k) + 0 by RADIX_1:def 10;
A57: DigA(tx,1) = DigA(tz,1) & DigA(ty,1) = DigA(tw,1) implies SDDec(tz) +
    SDDec(tw) = SDDec(tx) + SDDec(ty)
    proof
      assume DigA(tx,1) = DigA(tz,1) & DigA(ty,1) = DigA(tw,1);
      then
      SDDec(tz) + SDDec(tw) = (SDDec(tx '+' ty)) + (SD_Add_Carry(DigA(tx,
      1)+DigA(ty,1))*(Radix(k) |^ 1)) by A53,A56,A55,RADIX_2:11;
      hence thesis by A53,RADIX_2:11;
    end;
    assume
A58: for j be Nat st j in Seg 1 holds DigA(tx,j) = DigA(tz,j) & DigA(ty
    ,j) = DigA(tw,j) or DigA(ty,j) = DigA(tz,j) & DigA(tx,j) = DigA(tw,j);
    then
A59: DigA(tx,1) = DigA(tz,1) & DigA(ty,1) = DigA(tw,1) or DigA(ty,1) = DigA
    (tz,1) & DigA(tx,1) = DigA(tw,1) by A54;
    DigA(ty,1) = DigA(tz,1) & DigA(tx,1) = DigA(tw,1) implies SDDec(tz) +
    SDDec(tw) = SDDec(tx) + SDDec(ty)
    proof
      assume that
      DigA(ty,1) = DigA(tz,1) and
      DigA(tx,1) = DigA(tw,1);
      SDDec(tz) + SDDec(tw) = (SDDec(tx '+' ty)) + SD_Add_Carry(DigA(tx,1
      )+DigA(ty,1))*(Radix(k) |^ 1) by A53,A56,A55,A59,RADIX_2:11;
      hence thesis by A53,RADIX_2:11;
    end;
    hence thesis by A58,A54,A57;
  end;
  for n be Nat st n >= 1 holds P[n] from NAT_1:sch 8(A52,A1);
  hence thesis;
end;
