reserve n,k,b for Nat, i for Integer;

theorem Th13:
  for N,i being Nat
  st i in dom Sgm0(N /\ OddNAT)
  holds (Sgm0(N /\ OddNAT)).i = 2*i+1
  proof
    defpred P[Nat] means for i being Nat st i in dom Sgm0($1 /\ OddNAT)
    holds (Sgm0($1 /\ OddNAT)).i = 2*i+1;
    A1: P[0]
    proof
      let i be Nat;
      assume i in dom Sgm0(0 /\ OddNAT);
      then i in len Sgm0({});
      then i in card {} by AFINSQ_2:20;
      hence thesis;
    end;
    A2:
    now
      let n be Nat;
      assume A3: P[n];
      thus P[n+1]
      proof
        let i be Nat;
        assume A4: i in dom Sgm0((n+1) /\ OddNAT);
        per cases;
        suppose A5: n is odd;
          A6: (n+1)/\OddNAT = (n /\ OddNAT) \/ {n}
          proof
            thus (n+1)/\OddNAT c= (n /\ OddNAT) \/ {n}
            proof
              let x be object;
              assume A7: x in (n+1)/\OddNAT;
              then x in (n+1) & x in OddNAT by XBOOLE_0:def 4;
              then consider y being Nat such that
              A8: y=x & y is odd;
              y in Segm(n+1) & y in OddNAT by A7,XBOOLE_0:def 4,A8;
              then (y < n or y = n) & y in OddNAT by NAT_1:44,NAT_1:22;
              then (y in Segm n & y in OddNAT) or y = n by NAT_1:44;
              then y in (n /\ OddNAT) or y in {n}
              by XBOOLE_0:def 4,TARSKI:def 1;
              hence x in (n /\ OddNAT) \/ {n} by A8,XBOOLE_0:def 3;
            end;
            let x be object;
            assume x in (n/\OddNAT) \/ {n};
            then per cases by XBOOLE_0:def 3;
            suppose A9: x in (n/\OddNAT);
              Segm n c= Segm(n+1) by NAT_1:11,NAT_1:39;
              then n /\ OddNAT c= (n+1) /\ OddNAT by XBOOLE_1:26;
              hence x in (n+1) /\ OddNAT by A9;
            end;
            suppose x in {n};
              then x=n by TARSKI:def 1;
              then x in Segm(n+1) & x in OddNAT by NAT_1:45,A5;
              hence x in (n+1) /\ OddNAT by XBOOLE_0:def 4;
            end;
          end;
          reconsider X = n /\ OddNAT as finite natural-membered set;
          reconsider Y = {n} as finite natural-membered set;
          A10: X <N< Y
          proof
            let a,b be Nat;
            assume a in X & b in Y;
            then a in Segm n & b=n by XBOOLE_0:def 4,TARSKI:def 1;
            hence a < b by NAT_1:44;
          end;
          not n in n; then
          not n in (n /\ OddNAT) by XBOOLE_0:def 4;
          then A11: card ((n+1)/\OddNAT) = card (n /\ OddNAT) + 1
          by A6,CARD_2:41;
          A12: i in Segm dom Sgm0((n+1) /\ OddNAT) by A4;
          then i < len Sgm0((n+1) /\ OddNAT) by NAT_1:44;
          then i < card (n /\ OddNAT) + 1 by A11,AFINSQ_2:20;
          then i < len (Sgm0 X) + 1 by AFINSQ_2:20;
          then per cases by NAT_1:22;
          suppose A13: i < len (Sgm0 X);
            then A14: i < Segm card (Sgm0(n /\ OddNAT));
            thus (Sgm0((n+1) /\ OddNAT)).i = (Sgm0(n /\ OddNAT)).i
            by A10,A13,AFINSQ_2:29,A6
            .= 2*i+1 by A14,NAT_1:44,A3;
          end;
          suppose A15: i=len (Sgm0 X);
            then A16: (Sgm0((n+1) /\ OddNAT)).i = (Sgm0 Y).0
            by AFINSQ_2:32,A10,A6
            .= n by AFINSQ_2:22;
            (Sgm0((n+1) /\ OddNAT)).i in rng (Sgm0((n+1) /\ OddNAT))
            by FUNCT_1:3,A4;
            then (Sgm0((n+1) /\ OddNAT)).i in (n+1) /\ OddNAT
            by AFINSQ_2:def 4;
            then (Sgm0((n+1) /\ OddNAT)).i in OddNAT by XBOOLE_0:def 4;
            then consider r being Nat such that
            A17: r=(Sgm0((n+1) /\ OddNAT)).i & r is odd;
            consider j being Nat such that
            A18: r=2*j+1 by A17,ABIAN:9;
            per cases by XXREAL_0:1;
              suppose A19: j<i;
                then A20: j < Segm card (Sgm0(n /\ OddNAT)) by A15;
                j < card Sgm0((n+1) /\ OddNAT) by A19,A12,NAT_1:44,XXREAL_0:2;
                then A21: j in Segm dom Sgm0((n+1) /\ OddNAT) by NAT_1:44;
                (Sgm0((n+1) /\ OddNAT)).j = (Sgm0(n /\ OddNAT)).j
                by A10,A19,A15,AFINSQ_2:29,A6
                .= (Sgm0((n+1) /\ OddNAT)).i by A20,NAT_1:44,A3,A17,A18;
                hence (Sgm0((n+1) /\ OddNAT)).i = 2*i+1
                by A21,A4,FUNCT_1:def 4,A19;
              end;
              suppose j=i;
                hence (Sgm0((n+1) /\ OddNAT)).i = 2*i+1 by A17,A18;
              end;
            suppose j>i;
              then A22: 2*i< 2*j by XREAL_1:68;
              A23: 2*i+1 in OddNAT;
              2*i+1 < n & n < n+1 by A22,XREAL_1:8,A17,A18,A16,NAT_1:16;
              then 2*i+1 < n+1 by XXREAL_0:2;
              then 2*i+1 in Segm (n+1) by NAT_1:44;
              then 2*i+1 in ((n+1) /\ OddNAT) by A23,XBOOLE_0:def 4;
              then 2*i+1 in rng (Sgm0((n+1) /\ OddNAT)) by AFINSQ_2:def 4;
              then consider l being object such that
              A24: l in dom (Sgm0((n+1) /\ OddNAT)) &
              (Sgm0((n+1) /\ OddNAT)).l=2*i+1 by FUNCT_1:def 3;
              reconsider l as Element of NAT by A24;
              l in Segm dom Sgm0((n+1) /\ OddNAT) by A24;
              then l < len Sgm0((n+1) /\ OddNAT) by NAT_1:44;
              then l < card (n /\ OddNAT) + 1 by A11,AFINSQ_2:20;
              then l < len (Sgm0 X) + 1 by AFINSQ_2:20;
              then per cases by NAT_1:22;
              suppose A25: l < len (Sgm0 X);
                then A26: l < Segm card (Sgm0(n /\ OddNAT));
                (Sgm0((n+1) /\ OddNAT)).l = (Sgm0(n /\ OddNAT)).l
                by A10,A25,AFINSQ_2:29,A6
                .= 2*l+1 by A26,NAT_1:44,A3;
                then 2*i+1=2*l+1 by A24;
                hence (Sgm0((n+1) /\ OddNAT)).i = 2*i+1 by A25,A15;
              end;
              suppose l=len (Sgm0 X);
                hence (Sgm0((n+1) /\ OddNAT)).i = 2*i+1 by A15,A24;
              end;
            end;
          end;
        end;
        suppose A27: n is even;
          (n+1)/\OddNAT = n /\ OddNAT
          proof
            thus (n+1)/\OddNAT c= n /\ OddNAT
            proof
              let x be object;
              assume x in (n+1)/\OddNAT;
              then A28: x in Segm (n+1) & x in OddNAT by XBOOLE_0:def 4;
              then consider y being Nat such that
              A29: y=x & y is odd;
              y<n by A28,A29,NAT_1:44,A27,NAT_1:22;
              then y in Segm n & y in OddNAT by A29,NAT_1:44;
              hence x in n /\ OddNAT by A29,XBOOLE_0:def 4;
            end;
            Segm n c= Segm(n+1) by NAT_1:11,NAT_1:39;
            hence n /\ OddNAT c= (n+1) /\ OddNAT by XBOOLE_1:26;
          end;
          hence (Sgm0((n+1) /\ OddNAT)).i = 2*i+1 by A4,A3;
        end;
      end;
    end;
    for N being Nat holds P[N] from NAT_1:sch 2(A1,A2);
    hence thesis;
  end;
