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

theorem Th6:
  for p be a_partition of n
    ex O be odd-valued FinSequence,
       a be natural-valued FinSequence st
    len O = len p = len a & p = O (#) 2|^a &
    ( p.1 = O.1 * (2|^a.1) & ... & p.len p = O.len p * (2|^a.len p))
proof
  let p be a_partition of n;
  defpred P[object,object] means
    for i,j st p.$1=(2|^i)*(2*j+1) holds $2=[2*j+1,i];
  A1:dom p = Seg len p by FINSEQ_1:def 3;
  A2:for k st k in Seg len p ex x st P[k,x]
  proof
    let k;
    assume k in Seg len p;
    then p.k in rng p by FUNCT_1:def 3,A1;
    then consider n,m be Nat such that
    A3:p.k=(2|^n)*(2*m+1) by NAGATA_2:1;
    take x=[2*m+1,n];
    let i,j;
    assume p.k=(2|^i)*(2*j+1);
    then i=n & j=m by A3,CARD_4:4;
    hence thesis;
  end;
  consider Oa be FinSequence such that
  A4:dom Oa = Seg len p &
  for k st k in Seg len p holds P[k,Oa.k] from FINSEQ_1:sch 1(A2);
  deffunc P1(object)=(Oa.$1)`1;
  consider O be FinSequence such that
  A5:len O = len p & for k st k in dom O holds O.k=P1(k) from FINSEQ_1:sch 2;
  A6:dom O=dom p by FINSEQ_3:29,A5;
  for x st x in dom O holds O.x is odd Nat
  proof
    let x;
    assume A7:x in dom O;
    then p.x in rng p by FUNCT_1:def 3,A6;
    then consider n,m be Nat such that
    A8:p.x=(2|^n)*(2*m+1) by NAGATA_2:1;
    Oa.x = [2*m+1,n] by A7,A1,A8,A6,A4;
    then P1(x) = 2*m+1;
    hence thesis by A7,A5;
  end;
  then reconsider O as odd-valued FinSequence by Def2;
  deffunc P2(object)=(Oa.$1)`2;
  consider A be FinSequence such that
  A9:len A = len p & for k st k in dom A holds A.k=P2(k) from FINSEQ_1:sch 2;
  A10:dom A=dom p by FINSEQ_3:29,A9;
  for x st x in dom A holds A.x is natural
  proof
    let x;
    assume A11:x in dom A;
    then p.x in rng p by FUNCT_1:def 3,A10;
    then consider n,m be Nat such that
    A12: p.x=(2|^n)*(2*m+1) by NAGATA_2:1;
    Oa.x = [2*m+1,n] by A11,A1,A12,A10,A4;
    then P2(x) = n;
    hence thesis by A11,A9;
  end;
  then reconsider A as natural-valued FinSequence by VALUED_0:def 12;
  take O,A;
  thus len O = len p =len A by A5,A9;
  set OA=O (#) 2|^A;
  dom (2|^A) = dom A by FLEXARY1:def 4;
  then A13:dom O /\ dom (2|^A) = dom p by A10,A6;
  A14: p.1 = O.1 * (2|^A.1) & ... & p.len p = O.len p * (2|^A.len p)
  proof
    let i;
    assume A15: 1<= i & i <= len p;
    then i in dom p by FINSEQ_3:25;
    then p.i in rng p by FUNCT_1:def 3;
    then consider n,m be Nat such that
    A16:p.i=(2|^n)*(2*m+1) by NAGATA_2:1;
    Oa.i = [2*m+1,n] & [2*m+1,n]`1 = 2*m+1 & [2*m+1,n]`2 = n
      by A15,FINSEQ_3:25,A1,A16,A4;
    then O.i = 2*m+1 & A.i = n by A15,FINSEQ_3:25,A5,A9;
    hence thesis by A16;
  end;
  for i st i in dom p holds p.i = OA.i
  proof
    let i;
    assume A17:i in dom p;
    then 1 <= i & i <= len p by FINSEQ_3:25;
    then A18: p.i = O.i * ( 2|^A.i) by A14;
    (2|^A).i = 2 to_power (A.i) by A17,A10,FLEXARY1:def 4;
    hence thesis by VALUED_1:5,A18;
  end;
  hence thesis by A13,VALUED_1:def 4,A14;
end;
