 reserve n,m for Nat,
      o for object,
      p for pair object,
      x,y,z for Surreal;

theorem Th15:
  sqrt x = [Union sqrtL(sqrt_0 x,x),Union sqrtR (sqrt_0 x,x)]
proof
  set A=born x,Nx=NonNegativePart x;
  consider S be c=-monotone Function-yielding Sequence such that
A1:dom S = succ A & No_sqrt_op A = S.A and
A2:for B be Ordinal st B in succ A
       ex SB be ManySortedSet of Day B st S.B = SB &
       for o be object st o in Day B holds
         SB.o = [Union sqrtL([(union rng (S|B)).: L_NonNegativePart o,
                              (union rng (S|B)).: R_NonNegativePart o],o),
                 Union sqrtR([(union rng (S|B)).: L_NonNegativePart o,
                              (union rng (S|B)).: R_NonNegativePart o],o)]
            by Def6;
  set UA=union rng (S|A);
  consider SB be ManySortedSet of Day A such that
A3:S.A = SB and
A4:for o st o in Day A holds
  SB.o = [Union sqrtL([UA.: L_NonNegativePart o,UA.: R_NonNegativePart o],o),
          Union sqrtR([UA.: L_NonNegativePart o,UA.:R_NonNegativePart o],o)]
    by A2,ORDINAL1:6;
  x in Day A by SURREAL0:def 18;
  then
A5: sqrt x = [Union sqrtL([UA.: L_Nx,UA.: R_Nx],x),
              Union sqrtR([UA.: L_Nx,UA.: R_Nx],x)] by A4,A1,A3;
A6: UA.: L_Nx c= L_(sqrt_0 x)
  proof
    let y be object such that
A7: y in UA.: L_Nx;
    consider o be object such that
A8: o in dom UA & o in L_Nx & UA.o = y by A7,FUNCT_1:def 6;
    reconsider o as Surreal by SURREAL0:def 16,A8;
    set b = born o;
A9: o in L_x by Th2,A8;
A10:o in Day b by SURREAL0:def 18;
A11:o in L_x \/ R_x by A9,XBOOLE_0:def 3;
    then
A12: b in A by SURREALO:1;
A13: b in succ A by A11,SURREALO:1,ORDINAL1:8;
    then ex SB be ManySortedSet of Day b st S.b = SB &
      for o be object st o in Day b holds
      SB.o = [Union sqrtL([(union rng (S|b)).: L_NonNegativePart o,
                           (union rng (S|b)).: R_NonNegativePart o],o),
              Union sqrtR([(union rng (S|b)).: L_NonNegativePart o,
                           (union rng (S|b)).: R_NonNegativePart o],o)] by A2;
    then
A14: o in dom (S.b) by A10,PARTFUN1:def 2;
    then
A15: UA.o = (union rng S).o by A12,SURREALR:5;
A16: No_sqrt_op b = S.b by A1,A2,Th14,A13;
    y = sqrt o by A8,A15,A13,A1,A14,SURREALR:2,A16;
    hence thesis by Def9,A8;
  end;
A17: L_(sqrt_0 x) c= UA.: L_Nx
  proof
    let y be object;
    assume y in L_(sqrt_0 x);
    then consider o be Surreal such that
A18:y = sqrt o & o in L_Nx by Def9;
    set b =born o;
A19: o in L_x by Th2,A18;
A20:o in Day b by SURREAL0:def 18;
A21: o in L_x \/ R_x by A19,XBOOLE_0:def 3;
    then
A22: b in A by SURREALO:1;
A23: b in succ A by SURREALO:1,A21,ORDINAL1:8;
    then ex SB be ManySortedSet of Day b st S.b = SB &
    for o be object st o in Day b holds
    SB.o = [Union sqrtL([(union rng (S|b)).: (L_NonNegativePart o),
                        (union rng (S|b)).: R_NonNegativePart o],o),
            Union sqrtR([(union rng (S|b)).: (L_NonNegativePart o),
                         (union rng (S|b)).: R_NonNegativePart o],o)] by A2;
    then
A24: o in dom (S.b) by A20,PARTFUN1:def 2;
    then
A25: UA.o = (union rng S).o by A22,SURREALR:5;
A26: b in dom S by SURREALO:1,A21,ORDINAL1:8, A1;
A27: No_sqrt_op b = S.b by A1,A2,Th14,A23;
A28: y = (union rng S).o by A18,A24,A26,SURREALR:2,A27;
    o in dom UA by SURREALR:5,A22,A24;
    hence thesis by A18,A28,A25,FUNCT_1:def 6;
  end;
A29: UA.: (R_Nx) c= R_(sqrt_0 x)
  proof
    let y be object such that
A30:y in UA.: R_Nx;
    consider o be object such that
A31:o in dom UA & o in (R_Nx) & UA.o = y by A30,FUNCT_1:def 6;
    reconsider o as Surreal by A31,SURREAL0:def 16;
    set b =born o;
A32: o in R_x by Th2,A31;
A33: o in Day b by SURREAL0:def 18;
A34: o in L_x \/ R_x by A32,XBOOLE_0:def 3;
    then
A35: b in A by SURREALO:1;
A36: b in succ A by A34,SURREALO:1,ORDINAL1:8;
    then ex SB be ManySortedSet of Day b st S.b = SB &
    for o be object st o in Day b holds
    SB.o = [Union sqrtL([(union rng (S|b)).: (L_NonNegativePart o),
                         (union rng (S|b)).: R_NonNegativePart o],o),
            Union sqrtR([(union rng (S|b)).: (L_NonNegativePart o),
                         (union rng (S|b)).: R_NonNegativePart o],o)] by A2;
    then
A37: o in dom (S.b) by A33,PARTFUN1:def 2;
A38: b in dom S by A34,SURREALO:1,ORDINAL1:8, A1;
A39: No_sqrt_op b = S.b by A1,A2,Th14,A36;
    (S.b).o = (union rng S).o by A37,A38,SURREALR:2;
    then y = sqrt o by A39,A31,A37,A35,SURREALR:5;
    hence thesis by Def9,A31;
  end;
A40: R_(sqrt_0 x) c= UA.: (R_Nx)
  proof
    let y be object;
    assume y in R_(sqrt_0 x);
    then consider o be Surreal such that
A41:y = sqrt o & o in R_Nx by Def9;
    set b =born o;
A42: o in R_x by Th2,A41;
A43: o in Day b by SURREAL0:def 18;
A44: o in L_x \/ R_x by A42,XBOOLE_0:def 3;
    then
A45: b in A by SURREALO:1;
A46: b in succ A by A44,ORDINAL1:8,SURREALO:1;
    then ex SB be ManySortedSet of Day b st S.b = SB &
    for o be object st o in Day b holds
    SB.o = [Union sqrtL([(union rng (S|b)).: (L_NonNegativePart o),
                         (union rng (S|b)).: R_NonNegativePart o],o),
            Union sqrtR([(union rng (S|b)).: (L_NonNegativePart o),
                         (union rng (S|b)).: R_NonNegativePart o],o)] by A2;
    then
A47: o in dom (S.b) by A43,PARTFUN1:def 2;
    then
A48: UA.o = (union rng S).o by A45,SURREALR:5;
A49: b in dom S by A44,ORDINAL1:8,SURREALO:1,A1;
A50: No_sqrt_op b = S.b by A1,A2,Th14,A46;
A51: y = (union rng S).o by A41,A47,A49,SURREALR:2,A50;
    o in dom UA by SURREALR:5,A45,A47;
    hence thesis by A41,A51,A48,FUNCT_1:def 6;
  end;
A52:UA.: L_Nx = L_(sqrt_0 x) by A6,A17,XBOOLE_0:def 10;
  UA.: (R_Nx) = R_(sqrt_0 x) by A29,A40,XBOOLE_0:def 10;
  hence thesis by A5, A52;
end;
