reserve i,j,k,n,m for Nat,
        X for set,
        b,s for bag of X,
        x for object;
reserve O for Ordinal,
        R for right_zeroed add-associative right_complementable
          right_unital distributive non trivial doubleLoopStr,
        p for Polynomial of O, R;
reserve O for Ordinal,
        R for right_zeroed add-associative right_complementable
             right_unital distributive non trivial doubleLoopStr,
        p for Polynomial of O, R;

theorem Th65:
  for L be non empty ZeroStr
  for m be Nat
  for p be Polynomial of m,L st
    for b be bag of m,n st b in Support p holds b.n is even
  for CS be one-to-one FinSequence of Bags m st
    rng CS = Support JsqrtSeries p
  ex S be one-to-one FinSequence of Bags m st
    len S = len CS & rng S = Support p &
    for i st i in dom S holds S.i = 2(#)(CS/.i) +* (0,(CS/.i.0))
proof
  let L be non empty ZeroStr;
  let m be Nat;
  let p be Polynomial of m,L such that
A1: for b be bag of m,n st b in Support p holds b.n is even;
  let CS be one-to-one FinSequence of Bags m such that
A2:rng CS = Support JsqrtSeries p;
  deffunc B(bag of m) = 2(#)$1 +* (0,$1.0);
  deffunc F(object) = B(CS/.$1);
  consider S be FinSequence such that
A3:len S = len CS & for k st k in dom S holds S.k=F(k) from FINSEQ_1:sch 2;
A4:dom S = dom CS by A3,FINSEQ_3:29;
A5:rng S c= Support p
  proof
    let y be object such that
A6: y in rng S;
    consider x such that
A7: x in dom S & S.x = y by A6,FUNCT_1:def 3;
    reconsider x as Nat by A7;
A8: (JsqrtSeries p).(CS/.x) = p.B(CS/.x) by Def12;
A9: B(CS/.x) in Bags m by PRE_POLY:def 12;
    CS.x = CS/.x & CS.x in rng CS by A7,A4,FUNCT_1:def 3,PARTFUN1:def 6;
    then (JsqrtSeries p).(CS/.x) <> 0.L by A2,POLYNOM1:def 4;
    then B(CS/.x) in Support p by A8,A9,POLYNOM1:def 4;
    hence thesis by A7,A3;
  end;
A10:Support p c= rng S
  proof
    let b be object such that
A11:b in Support p;
A12:b in dom p & p.b <>0.L by A11,POLYNOM1:def 3;
    reconsider b as bag of m by A11;
    defpred P[object,object] means
    ( $1 = 0 implies $2=b.0) &
    ( $1 <> 0 implies $2 = (1/2)*b.$1);
A13:  for x be object st x in m ex y being object st y in NAT & P[x,y]
    proof
      let x such that
A14:  x in m;
      x in Segm m by A14;
      then reconsider x as Nat;
      b.x is even by A11,A1;
      then consider i be Nat such that
A15:  b.x = 2*i by ABIAN:def 2;
      per cases;
      suppose
A16:    x=0;
        take b.x;
        thus thesis by A16,ORDINAL1:def 12;
      end;
      suppose
A17:    x<>0;
        take i;
        thus thesis by A17,A15,ORDINAL1:def 12;
      end;
    end;
    consider f be Function such that
A18:  dom f = m & rng f c= NAT
    & for x being object st x in m holds P[x,f.x] from FUNCT_1:sch 6(A13);
    reconsider f as ManySortedSet of m
    by A18,RELAT_1:def 18,PARTFUN1:def 2;
    reconsider f as bag of m by A18, VALUED_0:def 6;
A19:f in Bags m by PRE_POLY:def 12;
A20: dom b = m = dom (2(#)f) &
    m = dom (2(#)f +* (0,f.0)) by PARTFUN1:def 2;
    for x st x in m holds b.x = (2(#)f +* (0,f.0)).x
    proof
      let x such that
A21:  x in m;
      per cases;
      suppose
A22:    x=0;
        hence (2(#)f +* (0,f.0)).x = f.0 by A21,A20,FUNCT_7:31
        .= b.x by A22,A18,A21;
      end;
      suppose
A23:    x<>0;
        hence (2(#)f +* (0,f.0)).x = (2(#)f).x by FUNCT_7:32
        .= 2*(f.x) by VALUED_1:6
        .= 2*((1/2)*b.x) by A23,A18,A21
        .= b.x;
      end;
    end;
    then
A24: b = 2(#)f +* (0,f.0) by A20;
    then (JsqrtSeries p).f = p.b by Def12;
    then f in Support (JsqrtSeries p) by A12,A19,POLYNOM1:def 4;
    then consider x such that
A25: x in dom CS & CS.x = f by A2,FUNCT_1:def 3;
    reconsider x as Nat by A25;
A26: f = CS/.x by A25,PARTFUN1:def 6;
    S.x = b by A24,A26,A25,A4,A3;
    hence thesis by A25,A4,FUNCT_1:def 3;
  end;
  then
A27: Support p = rng S by A5,XBOOLE_0:def 10;
  S is one-to-one
  proof
    let x1,x2 be object such that
A28: x1 in dom S & x2 in dom S & S.x1=S.x2;
    reconsider x1,x2 as Nat by A28;
    B(CS/.x1)=S.x1 = B(CS/.x2) by A3,A28;
    then CS.x1 = CS/.x1 = CS/.x2 = CS.x2 by Th20,A4,A28,PARTFUN1:def 6;
    hence thesis by A4,A28,FUNCT_1:def 4;
  end;
  then reconsider S as one-to-one FinSequence of Bags m by A27,FINSEQ_1:def 4;
  take S;
  thus thesis by A10,A3,A5,XBOOLE_0:def 10;
end;
