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;
reserve f,f1,f2 for homogeneous additive Function of TOP-REAL n,TOP-REAL n;

theorem
  n <> 1 & |.p.| = |.q.| implies ex f st f is base_rotation & f.p = q
  proof
    set TR=TOP-REAL n;
    assume A1: n<>1;
    assume A2: |.p.|=|.q.|;
    per cases;
    suppose A3: p=q;
      take I=id TR;
      thus thesis by A3;
    end;
    suppose A4: p<>q;
      A5: n<>0
      proof
        assume A6: n=0;
        then p=0.TR by EUCLID:77;
        hence thesis by A4,A6;
      end;
      then A7: n>=1 by NAT_1:14;
      defpred P[Nat] means
      $1+1<=n implies ex f be base_rotation Function of TR,TR,X be set st
      card X=$1 & X c=Seg n & for k st k in X holds f.p.k=q.k;
      A8: Sum sqr q>=0 by RVSUM_1:86;
      A9: card Seg n=n by FINSEQ_1:57;
      A10: for m st P[m] holds P[m+1]
      proof
        let m such that
        A11: P[m];
        set m1=m+1;
        assume A12: m1+1<=n;
        then consider f be base_rotation Function of TR,TR,Xm be set such that
        A13: card Xm=m and
        A14: Xm c=Seg n and
        A15: for k st k in Xm holds f.p.k=q.k by A11,NAT_1:13;
        set fp=f.p,sfp=sqr fp,sq=sqr q;
        A16: m1<n by A12,NAT_1:13;
        per cases;
        suppose ex k st k in (Seg n)\Xm & sfp.k>=sq.k;
          then consider k such that
          A17: k in (Seg n)\Xm and
          A18: sfp.k>=sq.k;
          A19: k in Seg n by A17,XBOOLE_0:def 5;
          then A20: 1<=k by FINSEQ_1:1;
          set Xmk=Xm\/{k};
          A21: sfp.k=(fp.k)^2 & sq.k=(q.k)^2 by VALUED_1:11;
          A22: {k}c=Seg n by A19,ZFMISC_1:31;
          then A23: Xmk c=Seg n by A14,XBOOLE_1:8;
          A24: not k in Xm by A17,XBOOLE_0:def 5;
          then card Xmk=m1 by A13,A14,CARD_2:41;
          then Xmk c<Seg n by A9,A16,A23,XBOOLE_0:def 8;
          then consider z be object such that
          A25: z in Seg n and
          A26: not z in Xmk by XBOOLE_0:6;
          reconsider z as Nat by A25;
          A27: 1<=z by A25,FINSEQ_1:1;
          (fp.z)^2>=0 by XREAL_1:63;
          then A28: 0+(q.k)^2<=(fp.z)^2+(fp.k)^2 by A18,A21,XREAL_1:7;
          A29: z<=n by A25,FINSEQ_1:1;
          A30: k<=n by A19,FINSEQ_1:1;
          not z in {k} by A26,XBOOLE_0:def 3;
          then A31: z<>k by TARSKI:def 1;
          now per cases by A31,XXREAL_0:1;
            suppose A32: z<k;
              then consider r such that
              A33: (Mx2Tran Rotation(z,k,n,r)).fp.k=q.k by A27,A28,A30,Th25;
              Mx2Tran Rotation(z,k,n,r) is{k,z}-support-yielding base_rotation
              by A27,A30,A32,Th28,Th26;
              hence ex g be base_rotation Function of TR,TR st g is
              {k,z}-support-yielding & g.fp.k=q.k by A33;
            end;
            suppose A34: z>k;
              then consider r such that
              A35: (Mx2Tran Rotation(k,z,n,r)).fp.k=q.k by A20,A28,A29,Th24;
              Mx2Tran Rotation(k,z,n,r) is{z,k}-support-yielding base_rotation
              by A20,A29,A34,Th28,Th26;
              hence ex g be base_rotation Function of TR,TR st g is
              {k,z}-support-yielding & g.fp.k=q.k by A35;
            end;
          end;
          then consider g be base_rotation Function of TR,TR such that
          A36: g is{k,z}-support-yielding and
          A37: g.fp.k=q.k;
          take gf=g*f,Xmk;
          thus card Xmk=m1 & Xmk c=Seg n
            by A13,A14,A22,A24,CARD_2:41,XBOOLE_1:8;
          let m;
          A38: dom gf=the carrier of TR by FUNCT_2:52;
          A39: dom g=the carrier of TR by FUNCT_2:52;
          assume A40: m in Xmk;
          then A41: m in Xm or m in {k} by XBOOLE_0:def 3;
          per cases by A41,TARSKI:def 1;
          suppose A42: m in Xm;
            then m<>k by A17,XBOOLE_0:def 5;
            then not m in {k,z} by A26,A40,TARSKI:def 2;
            then g.(fp).m=fp.m by A36,A39;
            hence gf.p.m=fp.m by A38,FUNCT_1:12
            .=q.m by A15,A42;
          end;
          suppose m=k;
            hence gf.p.m=q.m by A37,A38,FUNCT_1:12;
          end;
        end;
        suppose A43: for k st k in (Seg n)\Xm holds sfp.k<sq.k;
          A44: Sum sfp>=0 by RVSUM_1:86;
          Sum sq>=0 & |.p.|=|.fp.| by Def4,RVSUM_1:86;
          then A45: Sum sfp=Sum sq by A2,A44,SQUARE_1:28;
          A46: len sfp=len fp by RVSUM_1:143;
          A47: len sq=len q by RVSUM_1:143;
          len fp=n & len q=n by CARD_1:def 7;
          then reconsider sfp,sq as Element of n-tuples_on REAL
            by A46,A47,FINSEQ_2:92;
          m<n by A16,NAT_1:13;
          then Xm<>Seg n by A13,FINSEQ_1:57;
          then Xm c<Seg n by A14,XBOOLE_0:def 8;
          then consider z be object such that
          A48: z in Seg n and
          A49: not z in Xm by XBOOLE_0:6;
          reconsider z as Nat by A48;
          A50: z in (Seg n)\Xm by A48,A49,XBOOLE_0:def 5;
          for k st k in Seg n holds sfp.k<=sq.k
          proof
            let k such that
            A51: k in Seg n;
            per cases by A51,XBOOLE_0:def 5;
            suppose k in (Seg n)\Xm;
              hence thesis by A43;
            end;
            suppose k in Xm;
              then fp.k=q.k by A15;
              then sfp.k=(q.k)^2 by VALUED_1:11
              .=sq.k by VALUED_1:11;
              hence thesis;
            end;
          end;
          then sfp.z>=sq.z by A45,A48,RVSUM_1:83;
          hence thesis by A43,A50;
        end;
      end;
      reconsider n1=n-1 as Nat by A5;
      A52: n1+1=n;
      A53: P[0]
      proof
        assume 0+1<=n;
        take f=id TR,X={};
        thus card X=0 & X c=Seg n;
        let k;
        assume k in X;
        hence thesis;
      end;
      for m holds P[m] from NAT_1:sch 2(A53,A10);
      then consider f be base_rotation Function of TR,TR,X be set such that
      A54: card X=n1 & X c=Seg n and
      A55: for k st k in X holds f.p.k=q.k by A52;
      card((Seg n)\X)=n-n1 by A9,A54,CARD_2:44;
      then consider z be object such that
      A56: {z}=(Seg n)\X by CARD_2:42;
      set fp=f.p;
      Sum sqr fp>=0 & |.p.|=|.fp.| by Def4,RVSUM_1:86;
      then A57: Sum sqr q=Sum sqr fp by A2,A8,SQUARE_1:28;
      A58: z in {z} by TARSKI:def 1;
      then A59: z in Seg n by A56,XBOOLE_0:def 5;
      reconsider z as Nat by A56,A58;
      set fpz=fp+*(z,q.z);
      A60: len fp=n by CARD_1:def 7;
      then A61: dom fp=Seg n by FINSEQ_1:def 3;
      A62: for k st 1<=k & k<=n holds fpz.k=q.k
      proof
        let k;
        assume 1<=k & k<=n;
        then A63: k in Seg n;
        per cases;
        suppose k=z;
          hence thesis by A61,A63,FUNCT_7:31;
        end;
        suppose A64: k<>z;
          then not k in (Seg n)\X by A56,TARSKI:def 1;
          then A65: k in X by A63,XBOOLE_0:def 5;
          fpz.k=fp.k by A64,FUNCT_7:32;
          hence thesis by A55,A65;
        end;
      end;
      A66: len fpz=len fp & len q=n by CARD_1:def 7,FUNCT_7:97;
      then A67: fpz=q by A60,A62;
      then A68: Sum sqr q=(Sum sqr fp)-(fp.z)^2+(q.z)^2 by A59,A61,Th3;
      per cases by A68,A57,SQUARE_1:40;
      suppose fp.z=q.z;
        then fp=q by A67,FUNCT_7:35;
        hence thesis;
      end;
      suppose A69: fp.z=-q.z;
        1<n by A1,A7,XXREAL_0:1;
        then 1+1<=n by NAT_1:13;
        then consider h be homogeneous additive Function of TR,TR such that
        A70: h is base_rotation and
        A71: h.fp=fp+*(z,-fp.z) by A59,Th34;
        dom(h*f)=the carrier of TR by FUNCT_2:52;
        then (h*f).p=fp+*(z,-fp.z) by A71,FUNCT_1:12
        .=q by A60,A62,A66,A69;
        hence thesis by A70;
      end;
    end;
end;
