reserve a,b,k,m,n,s for Nat;
reserve c,c1,c2,c3 for Complex;
reserve i,j,z for Integer;
reserve p for Prime;
reserve x for object;

theorem Th28:
  card { 3|^m where m is Nat: m is odd & m <= 2*n+1 } = n+1
  proof
    deffunc F(Nat) = 3|^$1;
A1: F(1) = 3;
    deffunc A(Nat) = { F(m) where m is Nat: m is odd & m <= 2*$1+1 };
    defpred P[Nat] means card A($1) = $1+1;
A2: P[0]
    proof
      A(0) = {3}
      proof
        thus A(0) c= {3}
        proof
          let x be object;
          assume x in A(0);
          then consider m such that
A3:       x = F(m) and
A4:       m is odd and
A5:       m <= 2*0+1;
          m = 1 by A4,A5,NAT_1:25;
          hence thesis by A3,TARSKI:def 1;
        end;
        let x be object;
        assume x in {3};
        then x = 3 by TARSKI:def 1;
        hence thesis by A1;
      end;
      hence thesis by CARD_1:30;
    end;
A6: P[a] implies P[a+1]
    proof
      assume
A7:   P[a];
      set K = F(2*a+3);
      defpred Q[Nat] means $1 is odd;
      set X = {F(i) where i is Nat: i <= 2*a+1 & Q[i]};
A8:   X is finite from FINSEQ_1:sch 6;
      X = A(a)
      proof
        thus X c= A(a)
        proof
          let x be object;
          assume x in X;
          then ex i being Nat st x = F(i) & i <= 2*a+1 & Q[i];
          hence thesis;
        end;
        let x be object;
        assume x in A(a);
        then ex i being Nat st x = F(i) & Q[i] & i <= 2*a+1;
        hence thesis;
      end;
      then reconsider An = A(a) as finite set by A8;
A9:   now
        assume K in An;
        then consider m such that
A10:    K = F(m) and
        m is odd and
A11:    m <= 2*a+1;
        2*a+1 < 2*a+1+2 by NAT_1:16;
        hence contradiction by A10,A11,PEPIN:30;
      end;
      set b = a+1;
      A(b) = A(a) \/ {K}
      proof
        thus A(b) c= A(a) \/ {K}
        proof
          let x be object;
          assume x in A(b);
          then consider m being Nat such that
A12:      x = F(m) and
A13:      m is odd and
A14:      m <= 2*b+1;
          per cases;
          suppose m <= 2*a+1;
            then x in A(a) by A12,A13;
            hence thesis by XBOOLE_0:def 3;
          end;
          suppose m > 2*a+1;
            then m >= 2*a+1+1 by NAT_1:13;
            then m = 2*a+2+0 or ... or m = 2*a+2+1 by A14,NAT_1:62;
            then x in {K} by A12,A13,TARSKI:def 1;
            hence thesis by XBOOLE_0:def 3;
          end;
        end;
        let x be object;
        assume x in A(a) \/ {K};
        then per cases by XBOOLE_0:def 3;
        suppose x in A(a);
          then consider m such that
A15:      x = F(m) and
A16:      m is odd and
A17:      m <= 2*a+1;
          a <= a+1 by NAT_1:16;
          then 2*a <= 2*(a+1) by XREAL_1:64;
          then 2*a+1 <= 2*(a+1)+1 by XREAL_1:6;
          then m <= 2*b+1 by A17,XXREAL_0:2;
          hence thesis by A15,A16;
        end;
        suppose x in {K};
          then x = K by TARSKI:def 1;
          hence thesis;
        end;
      end;
      hence thesis by A7,A9,CARD_2:41;
    end;
    P[a] from NAT_1:sch 2(A2,A6);
    hence thesis;
  end;
