reserve x,X for set,
        r,r1,r2,s for Real,
        i,j,k,m,n for Nat;
reserve p,q for Point of TOP-REAL n;

theorem Th24:
  1 <= i & i < j & j <= n & s^2 <= (p.i)^2+(p.j)^2 implies
    ex r st (Mx2Tran Rotation(i,j,n,r)).p.i = s
proof
  set pk=p.i,pj=p.j,pkj=pk^2+pj^2,P=sqrt pkj;
  assume that
  A1: 1<=i & i<j & j<=n and
  A2: s^2<=(p.i)^2+(p.j)^2;
  A3: 0<=pk*pk & 0<=pj*pj by XREAL_1:63;
  per cases;
  suppose A4: pk<>0 or pj<>0;
    A5: 0<=pk*pk by XREAL_1:63;
    A6: P>0 by A3,A4,SQUARE_1:25;
    then A7: s/P*P=s by XCMPLX_1:87;
    A8: 0<=pj*pj by XREAL_1:63;
    then pk^2+0<=pk^2+pj^2 by XREAL_1:6;
    then A9: sqrt(pk^2)<=P by A5,SQUARE_1:26;
    now per cases;
      suppose A10: pk>=0;
        then A11: pk<=P by A9,SQUARE_1:22;
        then pk/P<=1 by A6,XREAL_1:185;
        hence pk/P in [.-1,1 .] by A10,A11,XXREAL_1:1;
      end;
      suppose A12: pk<=0;
        then -pk<=P by A9,SQUARE_1:23;
        then -1<=pk/P by A6,XREAL_1:194;
        hence pk/P in [.-1,1 .] by A6,A12,XXREAL_1:1;
      end;
    end;
    then consider x be object such that
    A13: x in dom sin and
    x in [.-PI/2,PI/2.] and
    A14: sin.x=pk/P by FUNCT_1:def 6,SIN_COS6:45;
    A15: P*P=P^2
    .=pkj by A5,A8,SQUARE_1:def 2;
    0<=s*s by XREAL_1:63;
    then A16: sqrt(s^2)<=P by A2,SQUARE_1:26;
    now per cases;
      suppose A17: s>=0;
        then A18: s<=P by A16,SQUARE_1:22;
        then s/P<=1 by A6,XREAL_1:185;
        hence s/P in [.-1,1 .] by A17,A18,XXREAL_1:1;
      end;
      suppose A19: s<=0;
        then -s<=P by A16,SQUARE_1:23;
        then -1<=s/P by A6,XREAL_1:194;
        hence s/P in [.-1,1 .] by A6,A19,XXREAL_1:1;
      end;
    end;
    then consider y be object such that
    y in dom sin and
    A20: y in [.-PI/2,PI/2.] and
    A21: sin.y=s/P by FUNCT_1:def 6,SIN_COS6:45;
    reconsider y as Real by A20;
    A22: P*pk/P=pk by A6,XCMPLX_1:89;
    reconsider x as Element of REAL by A13,FUNCT_2:def 1;
    A23: sin.x=sin x by SIN_COS:def 17;
    (pk/P)*(pk/P)=(pk*pk)/pkj by A15,XCMPLX_1:76;
    then (cos x)*(cos x)+(pk*pk)/pkj=1 by A14,A23,SIN_COS:29;
    then (cos x)*(cos x)=1-(pk*pk)/pkj
    .=pkj/pkj-(pk*pk)/pkj by A3,A4,XCMPLX_1:60
    .=(pj*pj)/pkj
    .=(pj/P)^2 by A15,XCMPLX_1:76;
    then A24: (cos x)^2=(pj/P)^2;
    per cases by A24,SQUARE_1:40;
    suppose A25: cos x=pj/P;
      take r=x-y;
      -sin y=sin(-x+r) by SIN_COS:31
      .=sin(-x)*cos r+cos(-x)*sin r by SIN_COS:75
      .=(-sin x)*cos r+cos(-x)*sin r by SIN_COS:31
      .=-(sin x)*cos r+(cos x)*sin r by SIN_COS:31
      .=-(sin x)*cos r+-(cos x)*(-sin r);
      then sin y=(sin x)*cos r+(cos x)*(-sin r);
      hence s=P*(pk/P*cos r+pj/P*(-sin r))
        by A7,A14,A21,A23,A25,SIN_COS:def 17
      .=P*pk/P*cos r+P*pj/P*(-sin r)
      .=pk*(cos r)+pj*(-sin r) by A6,A22,XCMPLX_1:89
      .=(Mx2Tran Rotation(i,j,n,r)).p.i by A1,Th21;
    end;
    suppose A26: cos x=-(pj/P);
      take r=y-x;
      sin y=sin(x+r)
      .=(sin x)*cos r+(cos x)*sin r by SIN_COS:75
      .=pk/P*(cos r)+(pj/P)*(-sin r) by A14,A26,SIN_COS:def 17;
      hence s=P*(pk/P*(cos r)+(pj/P)*(-sin r)) by A7,A21,SIN_COS:def 17
      .=(P*pk/P)*cos r+(P*pj/P)*(-sin r)
      .=pk*(cos r)+pj*(-sin r) by A6,A22,XCMPLX_1:89
      .=(Mx2Tran Rotation(i,j,n,r)).p.i by A1,Th21;
    end;
  end;
  suppose A27: pk=0 & pj=0;
    take r=0;
    set M=Mx2Tran Rotation(i,j,n,r);
    M=Mx2Tran 1.(F_Real,n) by A1,Th18;
    then A28: M=id TOP-REAL n by MATRTOP1:33;
    s=0 by A2,A27,XREAL_1:63;
    hence thesis by A27,A28;
  end;
end;
