
theorem Th7:
  for n, i being Element of NAT st i < n holds (n-BinarySequence 2
to_power i).(i+1) = 1 & for j being Element of NAT st j in Seg n & j<>i+1 holds
  (n-BinarySequence 2 to_power i).j = 0
proof
  let n, i be Element of NAT;
  assume
A1: i < n;
  deffunc B(Nat) = $1-BinarySequence 2 to_power i;
  set B = n-BinarySequence 2 to_power i;
  defpred P[Nat] means i < $1 implies B($1).(i+1) = TRUE;
A2: now
    let n be Nat such that
A3: P[n];
    now
      assume
A4:   i < n+1;
      then
A5:   i <= n by NAT_1:13;
A6:    n in NAT by ORDINAL1:def 12;
      per cases by A5,XXREAL_0:1;
      suppose
A7:     n = 0;
        0*n = n |-> 0 by EUCLID:def 4;
        then dom 0*n =Seg n;
        then
A8:     len 0*n = n by FINSEQ_1:def 3,A6;
        dom <*TRUE*> =Seg 1 by FINSEQ_1:38;
        then
A9:     1 in dom <*TRUE*> by FINSEQ_1:1;
A10:     i = 0 by A4,A7,NAT_1:13;
        hence B(n+1).(i+1) = (0*n^<*TRUE*>).(i+1) by A7,BINARI_3:28
          .= <*TRUE*>.1 by A7,A10,A8,A9,FINSEQ_1:def 7
          .= TRUE by FINSEQ_1:40;
      end;
      suppose
A11:    n > 0 & n = i;
        0*n = n |-> 0 by EUCLID:def 4;
        then dom 0*n = Seg n;
        then
A12:    len 0*n = n by FINSEQ_1:def 3,A6;
        dom <*TRUE*> = Seg 1 by FINSEQ_1:38;
        then
A13:    1 in dom <*TRUE*> by FINSEQ_1:1;
        thus B(n+1).(i+1) = (0*n^<*TRUE*>).(i+1) by A11,BINARI_3:28
          .= <*TRUE*>.1 by A11,A12,A13,FINSEQ_1:def 7
          .= TRUE by FINSEQ_1:40;
      end;
      suppose
A14:    n > 0 & n > i;
        then reconsider n9 = n as non zero Nat;
A15:    0+1 <= i+1 by XREAL_1:6;
        i+1 <= n by A14,NAT_1:13;
        then i+1 in Seg n by A15,FINSEQ_1:1;
        then
A16:    i+1 in dom B(n) by Lm1;
        2 to_power i < 2 to_power n by A14,POWER:39;
        hence B(n+1).(i+1) = (B(n9)^<*FALSE*>).(i+1) by BINARI_3:27
          .= TRUE by A3,A14,A16,FINSEQ_1:def 7;
      end;
    end;
    hence P[n+1];
  end;
A17: P[ 0 ];
  for n being Nat holds P[n] from NAT_1:sch 2(A17,A2);
  hence B.(i+1) = 1 by A1;
  defpred P[Nat] means
i < $1 implies for j being Element of NAT st
  i+1 <=j & j <= $1 holds B($1).(j+1)= FALSE;
  let j be Element of NAT such that
A18: j in Seg n and
A19: j<>i+1;
A20: 1 <= j by A18,FINSEQ_1:1;
A21: now
    let n be Nat such that
A22: P[n];
    now
      assume i < n+1;
      then
A23:  i <= n by NAT_1:13;
A24:  0+1 <= i+1 by XREAL_1:6;
      let j be Element of NAT such that
A25:  i+1 <=j and
A26:  j <= n+1;
      per cases by A23,XXREAL_0:1;
      suppose
A27:    n = 0;
        1 <= j by A25,A24,XXREAL_0:2;
        then
A28:    j = 1 by A26,A27,XXREAL_0:1;
        dom B(n+1) = Seg (n+1) by Lm1;
        then not j+1 in dom B(n+1) by A27,A28,FINSEQ_1:1;
        hence B(n+1).(j+1) = FALSE by FUNCT_1:def 2;
      end;
      suppose
A29:    n > 0 & n = i;
A30:    dom B(n+1) = Seg (n+1) by Lm1;
        j+1 > n+1 by A25,A29,NAT_1:13;
        then not j+1 in dom B(n+1) by A30,FINSEQ_1:1;
        hence B(n+1).(j+1) = FALSE by FUNCT_1:def 2;
      end;
      suppose
A31:    n > 0 & n > i;
        then reconsider n9 = n as non zero Nat;
A32:    2 to_power i < 2 to_power n by A31,POWER:39;
        thus B(n+1).(j+1) = FALSE
        proof
          j<n+1 or j=n+1 by A26,XXREAL_0:1;
          then
A33:      j <= n or j = n+1 by NAT_1:13;
          per cases by A33,XXREAL_0:1;
          suppose
            j = n+1;
            then
A34:        j+1 > n+1 by NAT_1:13;
            dom B(n+1) = Seg (n+1) by Lm1;
            then not j+1 in dom B(n+1) by A34,FINSEQ_1:1;
            hence thesis by FUNCT_1:def 2;
          end;
          suppose
A35:        j = n;
            dom B(n) = Seg n by Lm1;
            then
A36:        j = len B(n) by A35,FINSEQ_1:def 3;
            dom <*FALSE*> = Seg 1 by FINSEQ_1:38;
            then
A37:        1 in dom <*FALSE*> by FINSEQ_1:1;
            thus B(n+1).(j+1) = (B(n9)^<*FALSE*>).(j+1) by A32,BINARI_3:27
              .= <*FALSE*>.1 by A36,A37,FINSEQ_1:def 7
              .= FALSE by FINSEQ_1:40;
          end;
          suppose
A38:        j < n;
A39:        1 <= j+1 by NAT_1:12;
            j+1 <= n by A38,NAT_1:13;
            then j+1 in Seg n by A39,FINSEQ_1:1;
            then
A40:        j+1 in dom B(n) by Lm1;
            thus B(n+1).(j+1) = (B(n9)^<*FALSE*>).(j+1) by A32,BINARI_3:27
              .= B(n).(j+1) by A40,FINSEQ_1:def 7
              .= FALSE by A22,A25,A31,A38;
          end;
        end;
      end;
    end;
    hence P[n+1];
  end;
A41: P[ 0 ];
A42: for n being Nat holds P[n] from NAT_1:sch 2(A41,A21);
  defpred P[Nat] means
i < $1 implies for j being Element of NAT st
  1 <=j & j < i+1 holds B($1).j = FALSE;
A43: now
    let n be Nat such that
A44: P[n];
    now
      assume
A45:  i < n+1;
      then
A46:  i <= n by NAT_1:13;
      let j be Element of NAT such that
A47:  1 <=j and
A48:  j < i+1;
      per cases by A46,XXREAL_0:1;
      suppose
        n = 0;
        then i = 0 by A45,NAT_1:13;
        hence B(n+1).j = FALSE by A47,A48;
      end;
      suppose
A49:    n > 0 & i < n;
        then reconsider n9 = n as non zero Nat;
A50:    dom B(n) = Seg n by Lm1;
A51:    i <= n by A45,NAT_1:13;
        j <= i by A48,NAT_1:13;
        then j <= n by A51,XXREAL_0:2;
        then
A52:    j in dom B(n) by A47,A50,FINSEQ_1:1;
        2 to_power i < 2 to_power n by A49,POWER:39;
        hence B(n+1).j = (B(n9)^<*FALSE*>).j by BINARI_3:27
          .= B(n).j by A52,FINSEQ_1:def 7
          .= FALSE by A44,A47,A48,A49;
      end;
      suppose
A53:    n > 0 & i = n;
        then j <= n by A48,NAT_1:13;
        then
A54:    j in Seg n by A47,FINSEQ_1:1;
A55:    0*n = n |-> 0 by EUCLID:def 4;
        then
A56:    j in dom 0*n by A54;
        thus B(n+1).j = (0*n^<*TRUE*>).j by A53,BINARI_3:28
          .= (0*n).j by A56,FINSEQ_1:def 7
          .= FALSE by A55;
      end;
    end;
    hence P[n+1];
  end;
A57: P[ 0 ];
A58: for n being Nat holds P[n] from NAT_1:sch 2(A57,A43);
A59: j <= n by A18,FINSEQ_1:1;
  per cases by A19,A59,XXREAL_0:1;
  suppose
    j < i+1;
    hence thesis by A1,A58,A20;
  end;
  suppose
A60: j > i+1 & j < n;
    then consider k being Nat such that
A61: j = k+1 by NAT_1:6;
    reconsider k as Element of NAT by ORDINAL1:def 12;
A62: k <= n by A60,A61,NAT_1:13;
    i+1 <= k by A60,A61,NAT_1:13;
    hence thesis by A1,A42,A61,A62;
  end;
  suppose
A63: j > i+1 & j = n;
    then consider m being Nat such that
A64: n = m+1 by NAT_1:6;
    reconsider m as Element of NAT by ORDINAL1:def 12;
    i < m by A63,A64,XREAL_1:6;
    then 2 to_power i < 2 to_power m by POWER:39;
    hence thesis by A63,A64,BINARI_3:26;
  end;
end;
