reserve x,y for object,
        i,j,k,m,n for Nat;

theorem Th15:
  for e be odd-valued a_partition of n
    ex p be one-to-one a_partition of n st
      e = Euler_transformation p
proof
  let e be odd-valued a_partition of n;
A1:Sum e=n by Def3;
  deffunc h(object) = card Coim(e,$1);
  consider H be FinSequence such that
     A2:len H=n & for k st k in dom H holds H.k=h(k) from FINSEQ_1:sch 2;
  rng H c= NAT
  proof
    let y be object;
    assume y in rng H;
    then consider x be object such that
    A3:x in dom H & H.x=y by FUNCT_1:def 3;
    reconsider x as Nat by A3;
    H.x = card Coim(e,x) by A3,A2;
    hence thesis by A3;
  end;
  then reconsider H as natural-valued FinSequence by VALUED_0:def 6;
  A4:dom H = Seg len H by FINSEQ_1:def 3;
  A5:Sum e = Sum ((idseq n) (#)H)
  proof
    A6:for i st i in dom e holds 0 <= e.i;
    for i holds card Coim(e,i) = H.i
    proof
      let i;
      per cases by FINSEQ_3:25;
      suppose i in dom H;
        hence thesis by A2;
      end;
      suppose i < 1;
        then A8: not i in rng e & not i in dom H by NAT_1:14,FINSEQ_3:25;
        then H.i = 0 & e"{i}={} by FUNCT_1:def 2,72;
        then Coim(e,i)={} by RELAT_1:def 17;
        hence thesis by A8,FUNCT_1:def 2;
      end;
      suppose A9: i > len H;
        then A10: not i in dom H by FINSEQ_3:25;
        Coim(e,i)={}
        proof
          assume Coim(e,i)<>{};
          then e"{i}<>{} by RELAT_1:def 17;
          then i in rng e by FUNCT_1:72;
          then consider x be object such that
          A11: x in dom e & e.x=i by FUNCT_1:def 3;
          reconsider x as Nat by A11;
          i <= Sum e by A11,A6,MATRPROB:5;
          hence thesis by Def3,A9,A2;
        end;
        hence thesis by A10,FUNCT_1:def 2;
      end;
    end;
    hence Sum e = 1 * H.1 + 2 * H.2 + ((id dom H)(#)H,3) +... by Th9
               .=1 * H.1 + ((id dom H) (#)H).2+ ((id dom H)(#)H,3) +... by Lm2
               .=((id dom H)(#)H).1+((id dom H)(#)H).2+((id dom H)(#)H,3)+...
                  by Lm2
               .=((id dom H)(#)H).1+(((id dom H)(#)H).2+
                    ((id dom H)(#)H,2+1)+...)
               .=((id dom H)(#)H).1+((id dom H)(#)H,2) +... by FLEXARY1:20
               .=Sum ((idseq n) (#)H) by A4,A2,FLEXARY1:22;
  end;
  defpred F[Nat,object] means
    ex f be increasing natural-valued FinSequence st
      H.$1 = (2|^f).1+(2|^f,2)+... & $2 = $1*(2|^f);
  ex p be FinSequence of NAT* st
     dom p = Seg len H &
     for k st k in Seg len H holds F[k,p.k]
  proof
    A12:for k st k in Seg len H ex x be object st F[k,x]
    proof
      let k;
      assume k in Seg len H;
      consider f be increasing natural-valued FinSequence such that
      A13: H.k = (2|^f).1+(2|^f,2)+... by FLEXARY1:31;
      take G=k * (2|^f);
      thus thesis by A13;
    end;
    consider p be FinSequence such that
    A14:dom p = Seg len H &
    for k st k in Seg len H holds F[k,p.k] from FINSEQ_1:sch 1(A12);
    rng p c= NAT*
    proof
      let y be object;
      assume y in rng p;
      then consider x be object  such that
      A15:x in dom p & p.x=y by FUNCT_1:def 3;
      reconsider x as Nat by A15;
      consider f be increasing natural-valued FinSequence such that
      A16:H.x = (2|^f).1+(2|^f,2)+... &
      p.x = x*(2|^f) by A15,A14;
      rng (x*(2|^f)) c= NAT by VALUED_0:def 6;
      then x*(2|^f) is FinSequence of NAT by FINSEQ_1:def 4;
      hence thesis by FINSEQ_1:def 11,A15,A16;
    end;
    then p is FinSequence of NAT* by FINSEQ_1:def 4;
    hence thesis by A14;
  end;
  then consider p be FinSequence of NAT* such that
  A17: dom p = Seg len H & for k st k in Seg len H holds F[k,p.k];
  A18:for k st p.k<>{} holds k is odd
  proof
    let k;
    assume A19: p.k<>{};
    then A20:k in dom p by FUNCT_1:def 2;
    then consider f be increasing natural-valued FinSequence such that
    A21:H.k = (2|^f).1+(2|^f,2)+... &
    p.k = k*(2|^f) by A17;
    consider j be object such that
    A22:j in dom (p.k) by A19,XBOOLE_0:def 1;
    reconsider j as Nat by A22;
    A23:dom (p.k) = dom (2|^f) by A21,VALUED_1:def 5;
    then j in dom f by A22,FLEXARY1:def 4;
    then (2|^f).j = 2 to_power (f.j) by FLEXARY1: def 4
                 .= 2|^ (f.j);
    then A24:(2|^f).j >0 by NEWTON:83;
    for i st i in dom (2|^f) holds 0 <= (2|^f).i;
    then A25:Sum (2|^f) >0 by A22,A24,A23,RVSUM_1:85;
    A26:rng e c= OddNAT by Def1;
    H.k = card Coim(e,k) by A20,A4,A17,A2;
    then Coim(e,k) <> {} by FLEXARY1:22,A25,A21;
    then e"{k} <>{} by RELAT_1:def 17;
    then k in OddNAT by FUNCT_1:72,A26;
    hence thesis by Th2;
  end;
  A27:H is n-element complex-valued by A2,CARD_1:def 7;
  len p = n by A17,A2,FINSEQ_1:def 3;
  then A28:len (Sum p)=n by CARD_1:def 7;
  now let i;
    assume 1 <= i & i <= n;
    then i in Seg len H by A2;
    then consider f be increasing natural-valued FinSequence such that
    A29:H.i = (2|^f).1+(2|^f,2)+... &
    p.i = i*(2|^f) by A17;
    thus (Sum p).i = Sum (i*(2|^f)) by A29,FLEXARY1:def 8
                  .= i*Sum (2|^f) by RVSUM_1:87
                  .= i*H.i by A29,FLEXARY1:22
                  .= ((idseq n) (#)H).i by A4,A2,Lm2;
  end;
  then A30:Sum p = ((idseq n) (#)H) by CARD_1:def 7,A27,A28;
  set NC=NAT-concatenation,np=NC "**" p;
  NAT* c= COMPLEX* by NUMBERS:20,FINSEQ_1:62;
  then reconsider p1=p as FinSequence of COMPLEX* by FINSEQ_2:24;
  rng np c=REAL;
  then reconsider np as FinSequence of REAL by FINSEQ_1:def 4;
  set sp=sort_a np;
  Sum (COMPLEX-concatenation "**" p1) = Sum np by FLEXARY1:5;
  then A31:Sum np =n by FLEXARY1:48,A30,A5,A1;
  A32:Sum sp=n by RFINSEQ2:def 6,RFINSEQ:9,A31;
  A33:rng sp = rng np by RFINSEQ2:def 6,CLASSES1:75;
  A34:rng np = Values p by FLEXARY1:4;
  sp is one-to-one a_partition of n
  proof
    not 0 in rng sp
    proof
      assume 0 in rng sp;
      then consider x,y be object such that
      A35: x in dom p & y in dom (p.x) & 0=p.x.y by A33,A34,FLEXARY1:1;
      reconsider x,y as Nat by A35;
      consider f be increasing natural-valued FinSequence such that
      A36:H.x = (2|^f).1+(2|^f,2)+... & p.x = x*(2|^f) by A35,A17;
      A37: 1 <= x by A35,FINSEQ_3:25;
      A38: (x*(2|^f)).y = x* ((2|^f).y) by RVSUM_1:45;
      y in dom (2|^f) by A35, A36,VALUED_1:def 5;
      then y in dom f by FLEXARY1:def 4;
      then (2|^f).y = 2 to_power (f.y) by FLEXARY1:def 4
                    .= 2|^ (f.y);
      then (2|^f).y >0 by NEWTON:83;
      hence thesis by A35,A36,A37,A38;
    end;
    then A39:sp is non-zero by ORDINAL1:def 15;
    A40:Sum sp=n by RFINSEQ2:def 6,RFINSEQ:9,A31;
    A41:sp is natural-valued by A34,A33,VALUED_0:def 6;
    sp is one-to-one
    proof
      now
        let x1,x2 be set such that A42:x1 in dom sp & x2 in dom sp
          & sp.x1=sp.x2;
        sp.x1 in {sp.x1} by TARSKI:def 1;
        then A43:x1 in sp"{sp.x1} & x2 in sp"{sp.x1} by FUNCT_1:def 7,A42;
        assume x1<>x2;
        then not sp"{sp.x1} is trivial by A43,SUBSET_1:def 7;
        then A44: card (sp"{sp.x1}) >= 2 by NAT_D:60;
        card Coim(sp,sp.x1) = card Coim(np,sp.x1)
          by CLASSES1:def 10,RFINSEQ2:def 6;
        then card Coim(np,sp.x1) >= 2 by A44,RELAT_1:def 17;
        then A45:card (np"{sp.x1}) >= 2 by RELAT_1:def 17;
        then not np"{sp.x1} is trivial by NAT_D:60;
        then consider d1,d2 be Element of np"{sp.x1} such that
        A46: d1<>d2 by SUBSET_1:def 7;
        np"{sp.x1} is non empty by A45;
        then A47:d1 in dom np & np.d1 in {sp.x1} & d2 in dom np &
          np.d2 in {sp.x1} by FUNCT_1:def 7;
        then A48:np.d1=sp.x1 & np.d2=sp.x1 by TARSKI:def 1;
        consider n1,k1 be Nat such that
        A49:n1+1 in dom p & k1 in dom (p.(n1+1)) &
        d1 = k1 + len (NC "**" (p|n1)) by FLEXARY1:6,A47;
        set n2=n1+1;
        A50: np.d1 = p.n2.k1 by FLEXARY1:8,A49;
        consider f be increasing natural-valued FinSequence such that
        A51:H.n2 = (2|^f).1+(2|^f,2)+... &
        p.n2 = n2*(2|^f) by A49,A17;
        A52: p.n2.k1 = n2* ((2|^f).k1) by A51,RVSUM_1:45;
        k1 in dom (2|^f) by A49, A51,VALUED_1:def 5;
        then A53:k1 in dom f by FLEXARY1:def 4;
        then A54:(2|^f).k1 = 2 to_power (f.k1) by FLEXARY1:def 4
                           .= 2|^ (f.k1);
        consider n3,k3 be Nat such that
        A55:n3+1 in dom p & k3 in dom (p.(n3+1)) &
        d2 = k3 + len (NC "**" (p|n3)) by FLEXARY1:6,A47;
        set n4=n3+1;
        consider g be increasing natural-valued FinSequence such that
        A56:H.n4 = (2|^g).1+(2|^g,2)+... &
        p.n4 = n4*(2|^g) by A55,A17;
        k3 in dom (2|^g) by A55, A56,VALUED_1:def 5;
        then A57:k3 in dom g by FLEXARY1:def 4;
        then A58:(2|^g).k3 = 2 to_power (g.k3) by FLEXARY1:def 4
                           .= 2|^ (g.k3);
        A59: p.n4 <>{} & p.n2 <>{} by A55,A49;
        then consider c2 be Nat such that
        A60:n2=2*c2+1 by A18,ABIAN:9;
        consider c4 be Nat such that
        A61:n4=2*c4+1 by A59,A18,ABIAN:9;
        p.n2.k1 = p.n4.k3 by A48,A50,FLEXARY1:8,A55;
        then A62: n2 * (2|^ (f.k1)) = n4 * 2|^ (g.k3) by A56,RVSUM_1:45,
        A58,A52,A54;
        then A63:c2=c4 & f.k1 = g.k3 by A60,A61,CARD_4:4;
        n4=n2 by A62,A60,A61,CARD_4:4;
        then A64:f=g by A51,A56,FLEXARY1:27;
        f is one-to-one;
        hence thesis by A57,A53,A64,A63,A49,A55,A60,A61,A46;
      end;
      hence thesis;
    end;
    hence thesis by Def3,A39,A41,A40;
  end;
  then reconsider sp as one-to-one a_partition of n;
  take sp;
  for O be odd-valued FinSequence,
      a be natural-valued FinSequence,
      sort be odd_organization of O st
    len O = len sp = len a & sp = O (#) 2|^a
  for j holds card Coim(e,j*2-1) = ((2|^a)*.sort.j,1)+...
  proof
    let O be odd-valued FinSequence,
          a be natural-valued FinSequence,
          sort be odd_organization of O such that
    A65:   len O = len sp = len a & sp = O (#) 2|^a;
    let j;
    A66:dom a= dom sp = dom O & dom a = dom (2|^a)
      by FLEXARY1:def 4,FINSEQ_3:29,A65;
    then reconsider S=sort as DoubleReorganization of dom (2|^a);
    A67: 2*j-1 = O.sort_(j,1) & ...& 2*j-1 = O.sort_(j,len (sort.j)) by Def4;
    per cases;
    suppose A68: j < 1;
      then j = 0 by NAT_1:14;
      then not 2*j-1 in rng e;
      then e"{2*j-1} ={} by FUNCT_1:72;
      then A69:Coim(e,2*j-1)={} by RELAT_1:def 17;
      not j in dom ((2|^a)*.S) by FINSEQ_3:25, A68;
      then Sum ((2|^a)*.S.j) = 0 by FUNCT_1:def 2,RVSUM_1:72;
      hence card Coim(e,j*2-1) = ((2|^a)*.sort.j,1)+... by FLEXARY1:21,A69;
    end;
    suppose A70: j*2-1 > n;
      A71:Coim(e,j*2-1)={}
      proof
        assume Coim(e,j*2-1)<>{};
        then e"{j*2-1} <>0 by RELAT_1:def 17;
        then 2*j-1 in rng e by FUNCT_1:72;
        then consider w be object such that
        A72:w in dom e & e.w=2*j-1 by FUNCT_1:def 3;
        for i st i in dom e holds 0 <= e.i;
        hence thesis by A72,MATRPROB:5,A1,A70;
      end;
      (2|^a)*.S.j ={}
      proof
        set L=len (S.j),SjL=S.j.L;
        assume A74: (2|^a)*.S.j<>{};
        len ((2|^a)*.S.j) = L by CARD_1:def 7;
        then A75: L >=1 by A74,NAT_1:14;
        then A76:2*j-1 = O.sort_(j,L) by A67;
        S.j<>{} by A74;
        then A77:j in dom S by FUNCT_1:def 2;
        L in dom (S.j) by A75,FINSEQ_3:25;
        then A78: SjL in Values S by FLEXARY1:1,A77;
        then A79:SjL in dom O by FLEXARY1:def 7;
        then A80:sp.SjL = O.SjL * (2|^a).SjL by VALUED_1:def 4,A66,A65;
        A81: (2|^a).SjL = 2 to_power (a.SjL) by FLEXARY1:def 4,A66,A79;
        A82:for i st i in dom sp holds 0 <= sp.i;
        2 |^ (a.SjL)>0 by NEWTON:83;
        then 2 |^ (a.SjL) >=1 by NAT_1:14;
        then A83: sp.SjL >= 1*(2*j-1) by A76,A80, A81,XREAL_1:66;
        SjL in dom sp by A78,FLEXARY1:def 7,A66;
        then sp.SjL <= n by A82,MATRPROB:5,A32;
        hence thesis by A83,A70,XXREAL_0:2;
      end;
      hence card Coim(e,j*2-1) = ((2|^a)*.sort.j,1)+...
        by RVSUM_1:72,FLEXARY1:21,A71;
    end;
    suppose A84:j >=1 & j*2-1 <=n;
      set J=j*2-1;
      2*j >= 2*1 by A84,XREAL_1:64;
      then A85:J >= 2-1 by XREAL_1:9;
      then consider f be increasing natural-valued FinSequence such that
      A86:    H.J = (2|^f).1+(2|^f,2)+... &
      p.J = J*(2|^f) by A84,FINSEQ_3:25,A2,A17,A4;
      reconsider j1=j-1 as Nat by A84;
      A87:J=2*j1+1;
      for x be object holds card Coim((2|^a)*.sort.j,x) = card Coim(2|^f,x)
      proof
        let y be object;
        set AS=(2|^a)*.sort.j;
        A90:(2|^a)*.S.j = (2|^a)*(S.j) by FLEXARY1:41;
        A91:a*.sort.j is one-to-one by Th13,A65;
        A92:y in rng AS implies y in rng (2|^f)
        proof
          assume y in rng AS;
          then consider x be object such that
          A93:x in dom ((2|^a)*.S.j) & ((2|^a)*.S.j).x=y by FUNCT_1:def 3;
          reconsider x as Nat by A93;
          set Sjx=S.j.x;
          A94:x in dom (S.j) & Sjx in dom (2|^a) by A90,A93,FUNCT_1:11;
          then A95: 1<= x & x <= len (S.j) by FINSEQ_3:25;
          J = O.sort_(j,1) &...& J=O.sort_(j,len (sort.j)) by Def4;
          then A96: J = O.sort_(j,x) by A95;
          Sjx in dom a by A94,FLEXARY1:def 4;
          then A97:(2|^a).Sjx = 2 to_power (a.Sjx) by FLEXARY1:def 4;
          sp.Sjx in Values p by A66,A94,FUNCT_1:def 3,A33,A34;
          then consider u,w be object such that
          A98:u in dom p & w in dom (p.u) & sp.Sjx=p.u.w by FLEXARY1:1;
          reconsider u,w as Nat by A98;
          p.u <>{} by A98;
          then consider s be Nat such that
          A99:u=2*s+1 by A18,ABIAN:9;
          consider fu be increasing natural-valued FinSequence such that
          A100:H.u = (2|^fu).1+(2|^fu,2)+... &
          p.u = u*(2|^fu) by A17,A98;
          A101: p.u.w = u*(2|^fu).w by A100,RVSUM_1:45;
          w in dom (2|^fu) by A100,A98,VALUED_1:def 5;
          then w in dom fu by FLEXARY1:def 4;
          then A102: (2|^fu).w = 2 to_power (fu.w) by FLEXARY1: def 4;
          then A103: J*(2 |^ (a.Sjx)) = (2*s+1)*(2|^(fu.w))
            by A98,A101,A99,A65,VALUED_1:5,A97, A96;
          then A104: j1=s & a.Sjx = fu.w by CARD_4:4,A87;
          A105: u*(2|^fu) = J*(2|^f) by A103,CARD_4:4,A87,A100,A86,A99;
          then A106:w in dom (2|^f) by A98,A100,VALUED_1:def 5;
          u*((2|^fu).w) = J*((2|^f).w) by A105,A100,A101,RVSUM_1:45;
          then A107:(2|^fu).w = (2|^f).w by A104,A99,XCMPLX_1:5;
          y = (2|^fu).w by A102,A104, A90,A93,FUNCT_1:12,A97;
          hence thesis by A106,A107,FUNCT_1:def 3;
        end;
        A108: y in rng (2|^f) implies y in rng AS
        proof
          assume y in rng (2|^f);
          then consider x be object such that
          A109: x in dom (2|^f) & (2|^f).x=y by FUNCT_1:def 3;
          reconsider x as Nat by A109;
          x in dom f by A109,FLEXARY1:def 4;
          then A110:(2|^f).x = 2 to_power (f.x) by FLEXARY1:def 4;
          A111:x in dom (p.J) by A86,A109,VALUED_1:def 5;
          set pJx=p.J.x;
          J in dom p by A85,A84,A2,A17;
          then pJx in rng sp by FLEXARY1:1,A111,A33,A34;
          then consider w be object such that
          A112: w in dom sp & sp.w = pJx by FUNCT_1:def 3;
          reconsider w as Nat by A112;
          A113:sp.w = O.w * (2|^a).w by A65,VALUED_1:5;
          Values sort = dom O by FLEXARY1:def 7;
          then consider r,t be object such that
          A114: r in dom S & t in dom (S.r) & S.r.t = w by FLEXARY1:1,A112,A66;
          reconsider r,t as Nat by A114;
          1 <= r by A114,FINSEQ_3:25;
          then reconsider r1=r-1 as Nat;
          set R=2*r-1;
          A115:R= O.sort_(r,1) &...& R=O.sort_(r,len (sort.r)) by Def4;
          1<= t & t <= len (S.r) by A114,FINSEQ_3:25;
          then A116: R=O.sort_(r,t) by A115;
          A117:(2|^a).w = 2 to_power (a.w) by A112,A66,FLEXARY1:def 4;
          then J*(2|^(f.x)) = (2*r1+1)*(2|^(a.w))
            by A110,A113,A86,RVSUM_1:45,A112, A116,A114;
          then A118: j1=r1 & f.x = a.w by CARD_4:4,A87;
          then A119: t in dom ((2|^a)*(S.j)) by A112,A66,A114,FUNCT_1:11;
          then ((2|^a)*(S.j)).t = (2|^f).x
            by A114,A118,FUNCT_1:12,A110,A117;
          hence thesis by A109,A119,A90,FUNCT_1:def 3;
        end;
        per cases;
        suppose A120: Coim(AS,y)={};
          Coim(2|^f,y)={}
          proof
            assume Coim(2|^f,y)<>{};
            then (2|^f)"{y}<>{} by RELAT_1:def 17;
            then AS"{y}<>{} by FUNCT_1:72,A108;
            hence thesis by RELAT_1:def 17,A120;
          end;
          hence thesis by A120;
        end;
        suppose Coim(AS,y)<>{};
          then A121: AS"{y}<>{} by RELAT_1:def 17;
          then A122:y in rng AS by FUNCT_1:72;
          A123:2+0=2;
          (2|^a)*.S.j = 2|^(a*(S.j)) by FLEXARY1:25,A90
                         .= 2|^(a*.S.j) by FLEXARY1:41;
          then ex x st AS"{y}={x} by A91,A123,A122,FUNCT_1:74;
          then A124:card Coim (AS,y) = 1 by CARD_2:42,RELAT_1:def 17;
          ex x st (2|^f)"{y}={x} by A121,FUNCT_1:72,A92,A123,FUNCT_1:74;
          hence thesis by CARD_2:42,A124,RELAT_1:def 17;
        end;
      end;
      then Sum ((2|^a)*.S.j) = Sum (2|^f) by CLASSES1:def 10,RFINSEQ:9
                                 .= (2|^f).1+(2|^f,2)+... by FLEXARY1:22
                                 .= card Coim(e,J)
                                   by A85,A84,FINSEQ_3:25,A2,A86;
      hence thesis by FLEXARY1:21;
    end;
  end;
  hence thesis by Th12;
end;
