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 Th36:
  f1 is rotation implies
    ex f2 st f2 is base_rotation & f2*f1 is {n}-support-yielding
proof
  set TR=TOP-REAL n;
  assume A1: f1 is rotation;
  set cTR=the carrier of TR;
  set f=f1;
  A2: dom f=cTR by FUNCT_2:52;
  A3: rng f c=cTR by RELAT_1:def 19;
  per cases;
  suppose A4: n=0;
    take I=id TR;
    A5: dom id cTR=cTR;
    A6:for h be Function,x be set st h in dom I & I.h.x<>h.x
         holds x in {n} by FUNCT_1:17;
    A7: cTR ={0.TR} by A4,EUCLID:22,77;
    then rng id cTR=cTR & rng f=cTR by A3,ZFMISC_1:33;
    then f=id cTR by A2,A5,A7,FUNCT_1:7;
    then I*f=I by A2,RELAT_1:52;
    hence thesis by A6;
  end;
  suppose n>0;
    then reconsider n1=n-1 as Nat;
    defpred P[Nat] means
    $1<=n-1 implies for S be Subset of TR st S={Base_FinSeq(n,i) where i is
    Element of NAT:1<=i & i<=$1}ex g be base_rotation Function of TR,TR st
    (g*f) |S=id S;
    set S={Base_FinSeq(n,i) where i is Element of NAT:1<=i & i<=n1};
    S c=the carrier of TR
    proof
      let x be object;
      assume x in S;
      then consider j be Element of NAT such that
      A8: x=Base_FinSeq(n,j) and
      1<=j and
      j<=n1;
      len Base_FinSeq(n,j)=n by MATRIXR2:74;
      hence thesis by A8,TOPREAL3:46;
    end;
    then reconsider S as Subset of TR;
    A9: for k st P[k] holds P[k+1]
    proof
      let z be Nat;
      assume A10: P[z];
      set z1=z+1;
      set SS={Base_FinSeq(n,i) where i is Element of NAT:1<=i & i<=z};
      assume A11: z1<=n-1;
      then reconsider n1=n-1 as Element of NAT by INT_1:3;
      A12: n1<n1+1 by NAT_1:13;
      then A13: z1<n by A11,XXREAL_0:2;
      set B=Base_FinSeq(n,z1);
      set X={i where i is Element of NAT:z1<=i & i<=n};
      let S be Subset of TR such that
      A14: S={Base_FinSeq(n,i) where i is Element of NAT:1<=i & i<=z1};
      SS c=S
      proof
        let x be object;
        assume x in SS;
        then consider i be Element of NAT such that
        A15: x=Base_FinSeq(n,i) & 1<=i and
        A16: i<=z;
        i<z1 by A16,NAT_1:13;
        hence thesis by A14,A15;
      end;
      then reconsider SS as Subset of TR by XBOOLE_1:1;
      z<n1 by A11,NAT_1:13;
      then consider g be base_rotation Function of TR,TR such that
      A17: (g*f) |SS=id SS by A10;
       n in NAT by ORDINAL1:def 12;
      then A18: n in X by A13;
      n>=1 by A12,NAT_1:14;
      then n in Seg n;
      then A19: n in X/\Seg n by A18,XBOOLE_0:def 4;
      A20: card{z1,n}=2 by A11,A12,CARD_2:57;
      A21: 1<=z1 by NAT_1:11;
      then A22: z1 in Seg n by A13;
      B in S by A14,A21;
      then reconsider B as Point of TR;
      set gfB=(g*f).B;
      A23: z1 in X by A13;
      then consider h be homogeneous additive Function of TR,TR such that
      A24: h is X-support-yielding base_rotation and
      A25: card(X/\Seg n)>1 implies h.gfB.z1>=0 and
      A26: for i st i in X/\Seg n & i<>z1 holds h.gfB.i=0 by A22,Th30;
      reconsider hg=h*g as base_rotation Function of TR,TR by A24;
      A27: dom(hg*f)=the carrier of TR by FUNCT_2:52;
      A28: for x st x in SS holds(h*g*f).x=x & h.x=x
      proof
        let x such that
        A29: x in SS;
        reconsider B=x as Point of TR by A29;
        ((g*f) |SS).x=(g*f).x by A29,FUNCT_1:49;
        then A30: (g*f).x=x by A17,A29,FUNCT_1:17;
        A31: ex i be Element of NAT st x=Base_FinSeq(n,i) & 1<=i & i<=z by A29;
        A32: for j st j in X/\Seg n holds B.j=0
        proof
          let j;
          assume A33: j in X/\Seg n;
          then j in X by XBOOLE_0:def 4;
          then ex I be Element of NAT st I=j & z1<=I & I<=n;
          then A34: z<j by NAT_1:13;
          j in Seg n by A33,XBOOLE_0:def 4;
          then 1<=j & j<=n by FINSEQ_1:1;
          hence thesis by A31,A34,MATRIXR2:76;
        end;
        A35: hg*f=h*(g*f) by RELAT_1:36;
        then (h*(g*f)).x=h.((g*f).x) by A27,A29,FUNCT_1:12;
        hence thesis by A24,A30,A32,A35,Th33;
      end;
      z1 in X/\Seg n by A22,A23,XBOOLE_0:def 4;
      then {z1,n}c=X/\Seg n by A19,ZFMISC_1:32;
      then A36: 1+1<=card(X/\Seg n) by A20,NAT_1:43;
      A37: for x being object st x in S holds((hg*f) |S).x=(id S).x
      proof
        let x be object such that
        A38: x in S;
        A39: (id S).x=x by A38,FUNCT_1:17;
        A40: hg*f=h*(g*f) by RELAT_1:36;
        A41: ((hg*f) |S).x=(hg*f).x by A38,FUNCT_1:49;
        consider i be Element of NAT such that
        A42: x=Base_FinSeq(n,i) and
        A43: 1<=i and
        A44: i<=z1 by A14,A38;
        per cases by A44,NAT_1:8;
        suppose i<=z;
          then x in SS by A42,A43;
          hence thesis by A28,A39,A41;
        end;
        suppose A45: i=z1;
          set H=h.gfB;
          A46: (h*(g*f)).x=h.gfB by A27,A40,A42,A45,FUNCT_1:12;
          A47: len H=n by CARD_1:def 7;
          A48: for j st j in Seg n & j<z1 holds h.gfB.j=0
          proof
            let j;
            assume that
            A49: j in Seg n and
            A50: j<z1;
            A51: 1<=j by A49,FINSEQ_1:1;
            j<=z by A50,NAT_1:13;
            then A52: Base_FinSeq(n,j) in SS by A49,A51;
            then reconsider Bnj=Base_FinSeq(n,j) as Point of TR;
            (h*g*f).Bnj=Bnj by A28,A52;
            then A53: Bnj+H=(h*g*f).(Bnj+B) by A40,A42,A45,A46,VECTSP_1:def 20;
            A54: len Bnj=n by CARD_1:def 7;
            |.(h*g*f).(Bnj+B).|=|.Bnj+B.| by A1,A24,Def4;
            then A55: |.Bnj+B.|^2=|.Bnj.|^2+2*|(H,Bnj)|+|.H.|^2
              by A47,A53,A54,EUCLID_2:11;
            A56: Bnj=0*n+*(j,1) by MATRIXR2:def 4;
            len B=n by CARD_1:def 7;
            then A57: |.Bnj+B.|^2=|.Bnj.|^2+2*|(B,Bnj)|+|.B.|^2
              by A54,EUCLID_2:11;
            A58: j<=n by A49,FINSEQ_1:1;
            |.H.|=|.B.| by A1,A24,A42,A45,A46,Def4;
            then (B.j)*1=|(H,Bnj)| by A55,A56,A57,TOPREALC:16
            .=(H.j)*1 by A56,TOPREALC:16;
            hence thesis by A50,A51,A58,MATRIXR2:76;
          end;
          set H=h.gfB;
          set 0H=0*n+*(z1,H.z1);
          A59: len(0*n)=n by CARD_1:def 7;
          A60: for j st j in Seg n & j>z1 holds h.gfB.j=0
          proof
            let j;
            assume that
            A61: j in Seg n and
            A62: j>z1;
            j<=n by A61,FINSEQ_1:1;
            then j in X by A61,A62;
            then j in X/\Seg n by A61,XBOOLE_0:def 4;
            hence thesis by A26,A62;
          end;
          A63: for j st 1<=j & j<=n holds H.j=0H.j
          proof
            let j;
            assume 1<=j & j<=n;
            then A64: j in Seg n;
            then A65: j in dom(0*n) by A59,FINSEQ_1:def 3;
            per cases;
            suppose j=z1;
              hence thesis by A65,FUNCT_7:31;
            end;
            suppose A66: j<>z1;
              then j>z1 or j<z1 by XXREAL_0:1;
              then A67: H.j=0 by A48,A60,A64;
              0H.j=(0*n).j by A66,FUNCT_7:32;
              hence thesis by A67;
            end;
          end;
          len H=n & len 0H=len(0*n) by CARD_1:def 7,FUNCT_7:97;
          then A68: 0H=H by A59,A63;
          A69: |.gfB.|=|.B.| by A1,Def4;
          A70: B=0*n+*(z1,1) by MATRIXR2:def 4;
          then A71: |.B.|=|.1 .| by A22,TOPREALC:13
          .=1 by ABSVALUE:def 1;
          |.H.|=|.gfB.| & |.H.z1.|=H.z1
            by A24,A25,A36,Def4,ABSVALUE:def 1,NAT_1:13;
          then H=B by A22,A68,A70,A71,A69,TOPREALC:13;
          hence thesis by A38,A39,A40,A42,A45,A46,FUNCT_1:49;
        end;
      end;
      take hg;
      dom(id S)=S & dom((hg*f) |S)=S by A27,RELAT_1:62;
      hence thesis by A37,FUNCT_1:2;
    end;
    A72: P[0]
    proof
      assume 0<=n-1;
      let S be Subset of TR such that
      A73: S={Base_FinSeq(n,i) where i is Element of NAT:1<=i & i<=0};
      A74: S={}
      proof
        assume S<>{};
        then consider x be object such that
        A75: x in S by XBOOLE_0:def 1;
        ex i be Element of NAT st x=Base_FinSeq(n,i) & 1<=i & i<=0 by A73,A75;
        hence contradiction;
      end;
      take g=id TOP-REAL n;
      (g*f) |S={} by A74;
      hence thesis by A74;
    end;
    for k holds P[k] from NAT_1:sch 2(A72,A9);
    then consider g be base_rotation Function of TR,TR such that
    A76: (g*f) |S=id S;
    take g;
    set gf=g*f;
    thus g is base_rotation;
    let p be Function;
    let x be set;
    assume that
    A77: p in dom gf and
    A78: gf.p.x<>p.x;
    reconsider p as Point of TR by A77,FUNCT_2:52;
    len(gf.p)=n by CARD_1:def 7;
    then dom(gf.p)=Seg n by FINSEQ_1:def 3;
    then A79: not x in Seg n implies (gf.p).x={} by FUNCT_1:def 2;
    len p=n by CARD_1:def 7;
    then dom p=Seg n by FINSEQ_1:def 3;
    then A80: x in Seg n by A78,A79,FUNCT_1:def 2;
    assume A81: not x in {n};
    reconsider x as Nat by A80;
    A82: x<=n by A80,FINSEQ_1:1;
    x<>n by A81,TARSKI:def 1;
    then x<n1+1 by A82,XXREAL_0:1;
    then A83: x<=n1 by NAT_1:13;
    x in NAT & 1<=x by A80,FINSEQ_1:1;
    then Base_FinSeq(n,x) in S by A83;
    then Base_FinSeq(n,x) in Lin S by RLVECT_3:15;
    then gf.p.x=p.x by A1,A76,A80,Th32;
    hence contradiction by A78;
  end;
end;
