reserve i,j,k,n for Nat;

theorem
  for C being compact connected non vertical non horizontal non empty
Subset of TOP-REAL 2 holds S-max C in right_cell(Rotate(Cage(C,n),S-max L~Cage(
  C,n)),1)
proof
  let C be compact connected non vertical non horizontal non empty Subset of
  TOP-REAL 2;
  set f = Cage(C,n);
  set G = Gauge(C,n);
  consider j being Nat such that
A1: 1 <= j and
A2: j <= len G and
A3: S-max L~f = G*(j,1) by JORDAN1D:28;
A4: f is_sequence_on G by JORDAN9:def 1;
  set k = (S-max L~f)..f;
A5: S-max L~f in rng f by SPRECT_2:42;
  then
A6: k in dom f & f.k = S-max L~f by FINSEQ_4:19,20;
  then
A7: f/.k = S-max L~f by PARTFUN1:def 6;
A8: now
A9: 1 < (S-max L~f)..f by Th3;
A10: 1 in dom f by A5,FINSEQ_3:31;
    assume k = len f;
    then f/.1 = S-max L~f by A7,FINSEQ_6:def 1;
    then f.1 = S-max L~f by A10,PARTFUN1:def 6;
    hence contradiction by A10,A9,FINSEQ_4:24;
  end;
  k <= len f by A5,FINSEQ_4:21;
  then k < len f by A8,XXREAL_0:1;
  then
A11: k+1 <= len f by NAT_1:13;
A12: f/.k = G*(j-'1+1,1) by A1,A3,A7,XREAL_1:235;
  f/.k = G*(j,1) by A3,A6,PARTFUN1:def 6;
  then
A13: f/.k = (GoB f)*(j,1) by JORDAN1H:44;
  set p = S-max C;
A14: len G = width G by JORDAN8:def 1;
A15: len G >= 4 by JORDAN8:10;
  then
A16: 1 <= len G by XXREAL_0:2;
A17: 1 <= k+1 by NAT_1:11;
  then
A18: k+1 in dom f by A11,FINSEQ_3:25;
A19: k+1 in dom f by A11,A17,FINSEQ_3:25;
  then consider kj,ki being Nat such that
A20: [kj,ki] in Indices G and
A21: f/.(k+1) = G*(kj,ki) by A4,GOBOARD1:def 9;
A22: [kj,ki] in Indices GoB f & f/.(k+1) = (GoB f)*(kj,ki) by A20,A21,
JORDAN1H:44;
A23: ki <= width G by A20,MATRIX_0:32;
A24: 1 <= kj by A20,MATRIX_0:32;
  len G = width G by JORDAN8:def 1;
  then
A25: [j,1] in Indices G by A1,A2,A16,MATRIX_0:30;
  then
A26: [j-'1+1,1] in Indices G by A1,XREAL_1:235;
A27: 1 <= k by Th3;
  then
A28: (f/.(k+1))`2 = S-bound L~Cage(C,n) by A7,A11,JORDAN1E:21;
  then G*(j,1)`2 = G*(kj,ki)`2 by A3,A21,EUCLID:52;
  then
A29: ki = 1 by A20,A25,JORDAN1G:6;
  [j,1] in Indices GoB f by A25,JORDAN1H:44;
  then |.1-ki.|+|.j-kj.| = 1 by A5,A18,A13,A22,FINSEQ_4:20,GOBOARD5:12;
  then
A30: 0+|.j-kj.| = 1 by A29,ABSVALUE:2;
A31: kj <= len G by A20,MATRIX_0:32;
  2 <= len f by GOBOARD7:34,XXREAL_0:2;
  then f/.(k+1) in S-most L~f by A28,A19,GOBOARD1:1,SPRECT_2:11;
  then G*(j,1)`1 >= G*(kj,ki)`1 by A3,A21,PSCOMP_1:55;
  then kj <= j by A1,A29,A23,A31,GOBOARD5:3;
  then kj+1 = j by A30,SEQM_3:41;
  then
A32: kj = j-1;
  then kj = j-'1 by A24,NAT_D:39;
  then
A33: [j-'1,1] in Indices G by A16,A24,A31,A14,MATRIX_0:30;
  f/.(k+1) = G*(j-'1,1) by A21,A29,A24,A32,NAT_D:39;
  then
A34: right_cell(f,k,G) = cell(G,j-'1,1) by A4,A27,A11,A33,A26,A12,GOBRD13:26;
A35: now
    1 < len G by A15,XXREAL_0:2;
    then
A36: 1 < width G by JORDAN8:def 1;
    assume
A37: not p in right_cell(f,k,G);
A38: 1 <= j-'1 by A24,A32,NAT_D:39;
    then j-'1 < j by NAT_D:51;
    then j-'1 < len G by A2,XXREAL_0:2;
    then LSeg(G*(j-'1,1+1),G*(j-'1+1,1+1)) c= cell(G,j-'1,1) by A36,A38,
GOBOARD5:21;
    then LSeg(G*(j-'1,2),G*(j,2)) c= cell(G,j-'1,1) by A1,XREAL_1:235;
    then
A39: not p in LSeg(G*(j-'1,2),G*(j,2)) by A34,A37;
    len G = width G by JORDAN8:def 1;
    then
A40: 2 <= width G by A15,XXREAL_0:2;
A41: len G = width G by JORDAN8:def 1;
A42: j-'1 <= len G by A24,A31,A32,NAT_D:39;
    then
A43: G*(j-'1,2)`2 = S-bound C by A38,JORDAN8:13;
    G*(j,2)`2 = S-bound C & p`2 = S-bound C by A1,A2,EUCLID:52,JORDAN8:13;
    then
A44: p`1 > G*(j,2)`1 or p`1 < G*(j-'1,2)`1 by A39,A43,GOBOARD7:8;
    per cases by A1,A2,A38,A42,A44,A40,GOBOARD5:2;
    suppose
A45:  p`1 < G*(j-'1,1)`1;
      cell(G,j-'1,1) meets C by A27,A11,A34,JORDAN9:31;
      then cell(G,j-'1,1) /\ C <> {} by XBOOLE_0:def 7;
      then consider c being object such that
A46:  c in cell(G,j-'1,1) /\ C by XBOOLE_0:def 1;
      reconsider c as Element of TOP-REAL 2 by A46;
A47:  c in cell(G,j-'1,1) by A46,XBOOLE_0:def 4;
A48:  c in C by A46,XBOOLE_0:def 4;
      then
A49:  c`2 >= S-bound C by PSCOMP_1:24;
A50:  j-'1+1 <= len G & 1+1 <= width G by A1,A2,A15,A41,XREAL_1:235,XXREAL_0:2;
      then c`2 <= G*(j-'1,1+1)`2 by A38,A47,JORDAN9:17;
      then c in S-most C by A43,A48,A49,SPRECT_2:11,XXREAL_0:1;
      then
A51:  c`1 <= p`1 by PSCOMP_1:55;
      G*(j-'1,1)`1 <= c`1 by A38,A47,A50,JORDAN9:17;
      hence contradiction by A45,A51,XXREAL_0:2;
    end;
    suppose
A52:  p`1 > G*(j,1)`1;
      south_halfline p meets L~f by JORDAN1A:53,SPRECT_1:12;
      then consider r being object such that
A53:  r in south_halfline p and
A54:  r in L~f by XBOOLE_0:3;
      reconsider r as Element of TOP-REAL 2 by A53;
      r in south_halfline p /\ L~f by A53,A54,XBOOLE_0:def 4;
      then r`2 = S-bound L~f by JORDAN1A:84,PSCOMP_1:58;
      then r in S-most L~f by A54,SPRECT_2:11;
      then (S-max L~f)`1 >= r`1 by PSCOMP_1:55;
      hence contradiction by A3,A52,A53,TOPREAL1:def 12;
    end;
  end;
  GoB f = G by JORDAN1H:44;
  then p in right_cell(f,k) by A27,A11,A35,JORDAN1H:23;
  hence thesis by A5,Th5;
end;
