reserve n for Nat;

theorem Th3:
  for C be compact connected non vertical non horizontal Subset of
TOP-REAL 2 for n be Nat holds L~(Cage(C,n)-:E-max L~Cage(C,n)) /\ L~
  (Cage(C,n):-E-max L~Cage(C,n)) = {N-min L~Cage(C,n),E-max L~Cage(C,n)}
proof
  let C be compact connected non vertical non horizontal Subset of TOP-REAL 2;
  let n be Nat;
  set US = Cage(C,n)-:E-max L~Cage(C,n);
  set LS = Cage(C,n):-E-max L~Cage(C,n);
  set f=Cage(C,n);
  set pW=E-max L~Cage(C,n);
  set pN=N-min L~Cage(C,n);
A1: pW`1 = E-bound L~f by EUCLID:52;
A2: pW in rng Cage(C,n) by SPRECT_2:46;
  then
A3: Cage(C,n)-:pW <> {} by FINSEQ_5:47;
  (Cage(C,n):-pW)/.1 = pW by FINSEQ_5:53;
  then
A4: E-max L~Cage(C,n) in rng (Cage(C,n):-E-max L~Cage(C,n)) by FINSEQ_6:42;
  (f:-pW)/.len(f:-pW) = f/.len f by A2,FINSEQ_5:54
    .= f/.1 by FINSEQ_6:def 1
    .= pN by JORDAN9:32;
  then
A5: pN in rng (Cage(C,n):-pW) by FINSEQ_6:168;
  {pN,pW} c= rng LS
  by A5,A4,TARSKI:def 2;
  then
A6: card {pN,pW} c= card rng LS by CARD_1:11;
  card rng LS c= card dom LS by CARD_2:61;
  then
A7: card rng LS c= len LS by CARD_1:62;
  N-max L~f in L~f by SPRECT_1:11;
  then (N-max L~f)`1 <= pW`1 by A1,PSCOMP_1:24;
  then
A8: pN <> pW by SPRECT_2:51;
  then card {pN,pW} = 2 by CARD_2:57;
  then Segm 2 c= Segm len LS by A6,A7;
  then len LS >= 2 by NAT_1:39;
  then
A9: rng LS c= L~LS by SPPOL_2:18;
  len(f-:pW) = pW..f by A2,FINSEQ_5:42;
  then (f-:pW)/.len (f-:pW) = pW by A2,FINSEQ_5:45;
  then
A10: pW in rng (Cage(C,n)-:pW) by A3,FINSEQ_6:168;
  (Cage(C,n)-:pW)/.1 = Cage(C,n)/.1 by A2,FINSEQ_5:44
    .= pN by JORDAN9:32;
  then
A11: N-min L~Cage(C,n) in rng (Cage(C,n)-:E-max L~Cage(C,n)) by A3,FINSEQ_6:42;
  {pN,pW} c= rng US
  by A11,A10,TARSKI:def 2;
  then
A12: card {pN,pW} c= card rng US by CARD_1:11;
  card rng US c= card dom US by CARD_2:61;
  then
A13: card rng US c= len US by CARD_1:62;
  LS/.(len LS) = Cage(C,n)/.len Cage(C,n) by A2,FINSEQ_5:54
    .= Cage(C,n)/.1 by FINSEQ_6:def 1
    .= N-min L~Cage(C,n) by JORDAN9:32;
  then
A14: N-min L~Cage(C,n) in rng LS by FINSEQ_6:168;
  pW..Cage(C,n) <= pW..Cage(C,n);
  then
A15: E-max L~Cage(C,n) in rng US by A2,FINSEQ_5:46;
  card {pN,pW} = 2 by A8,CARD_2:57;
  then
A16: Segm 2 c= Segm len US by A12,A13;
  then
A17: len US >= 2 by NAT_1:39;
  then
A18: rng US c= L~US by SPPOL_2:18;
  thus L~US /\ L~LS c= {N-min L~Cage(C,n),E-max L~Cage(C,n)}
  proof
    let x be object;
    assume
A19: x in L~US /\ L~LS;
    then reconsider x1=x as Point of TOP-REAL 2;
    assume
A20: not x in {N-min L~Cage(C,n),E-max L~Cage(C,n)};
    x in L~US by A19,XBOOLE_0:def 4;
    then consider i1 be Nat such that
A21: 1 <= i1 and
A22: i1+1 <= len US and
A23: x1 in LSeg(US,i1) by SPPOL_2:13;
A24: LSeg(US,i1) = LSeg(f,i1) by A22,SPPOL_2:9;
    x in L~LS by A19,XBOOLE_0:def 4;
    then consider i2 be Nat such that
A25: 1 <= i2 and
A26: i2+1 <= len LS and
A27: x1 in LSeg(LS,i2) by SPPOL_2:13;
    set i3=i2-'1;
A28: i3+1 = i2 by A25,XREAL_1:235;
    then
A29: 1+pW..f <= i3+1+pW..f by A25,XREAL_1:7;
A30: len LS = len f-pW..f+1 by A2,FINSEQ_5:50;
    then i2 < len f-pW..f+1 by A26,NAT_1:13;
    then i2-1 < len f-pW..f by XREAL_1:19;
    then
A31: i2-1+pW..f < len f by XREAL_1:20;
    i2-1 >= 1-1 by A25,XREAL_1:9;
    then
A32: i3+pW..f < len f by A31,XREAL_0:def 2;
A33: LSeg(LS,i2) = LSeg(f,i3+pW..f) by A2,A28,SPPOL_2:10;
A34: len US = pW..f by A2,FINSEQ_5:42;
    then i1+1 < pW..f+1 by A22,NAT_1:13;
    then i1+1 < i3+pW..f+1 by A29,XXREAL_0:2;
    then
A35: i1+1 <= i3+pW..f by NAT_1:13;
A36: pW..f-'1+1 = pW..f by A2,FINSEQ_4:21,XREAL_1:235;
    i3+1 < len f-pW..f+1 by A26,A28,A30,NAT_1:13;
    then i3 < len f-pW..f by XREAL_1:7;
    then
A37: i3+pW..f < len f by XREAL_1:20;
    then
A38: i3+pW..f+1 <= len f by NAT_1:13;
    now
      per cases by A21,A35,XXREAL_0:1;
      suppose
        i1+1 < i3+pW..f & i1 > 1;
        then LSeg(f,i1) misses LSeg(f,i3+pW..f) by A37,GOBOARD5:def 4;
        then LSeg(f,i1) /\ LSeg(f,i3+pW..f) = {};
        hence contradiction by A23,A27,A24,A33,XBOOLE_0:def 4;
      end;
      suppose
A39:    i1 = 1;
A40:    i3+pW..f >= 0+2 by A17,A34,XREAL_1:7;
        now
          per cases by A40,XXREAL_0:1;
          suppose
            i3+pW..f > 2;
            then
A41:        i1+1 < i3+pW..f by A39;
            now
              per cases by A38,XXREAL_0:1;
              suppose
                i3+pW..f+1 < len f;
                then LSeg(f,i1) misses LSeg(f,i3+pW..f) by A41,GOBOARD5:def 4;
                then LSeg(f,i1) /\ LSeg(f,i3+pW..f) = {};
                hence contradiction by A23,A27,A24,A33,XBOOLE_0:def 4;
              end;
              suppose
                i3+pW..f+1 = len f;
                then i3+pW..f = len f-1;
                then i3+pW..f = len f-'1 by XREAL_0:def 2;
                then LSeg(f,i1) /\ LSeg(f,i3+pW..f) = {f/.1} by A39,GOBOARD7:34
,REVROT_1:30;
                then x1 in {f/.1} by A23,A27,A24,A33,XBOOLE_0:def 4;
                then x1 = f/.1 by TARSKI:def 1
                  .= pN by JORDAN9:32;
                hence contradiction by A20,TARSKI:def 2;
              end;
            end;
            hence contradiction;
          end;
          suppose
A42:        i3+pW..f = 2;
A43:        1 + 2 <= len f by GOBOARD7:34,XXREAL_0:2;
            x1 in LSeg(f,1) /\ LSeg(f,1+1) by A23,A27,A24,A33,A39,A42,
XBOOLE_0:def 4;
            then x1 in {f/.(1+1)} by A43,TOPREAL1:def 6;
            then
A44:        x1 = f/.(1+1) by TARSKI:def 1;
            0+pW..f >= i3+pW..f by A16,A34,A42,NAT_1:39;
            then
A45:        i3 = 0 by XREAL_1:6;
            0+1 in dom LS by FINSEQ_5:6;
            then LS/.1 = x1 by A2,A42,A44,A45,FINSEQ_5:52;
            then x1 = pW by FINSEQ_5:53;
            hence contradiction by A20,TARSKI:def 2;
          end;
        end;
        hence contradiction;
      end;
      suppose
A46:    i1+1 = i3+pW..f;
        i3+pW..f >= pW..f by NAT_1:11;
        then pW..f < len f by A32,XXREAL_0:2;
        then pW..f+1 <= len f by NAT_1:13;
        then
A47:    pW..f-'1 + (1+1) <= len f by A36;
        0+pW..f <= i3+pW..f by XREAL_1:7;
        then pW..f = i1+1 by A22,A34,A46,XXREAL_0:1;
        then LSeg(f,i1) /\ LSeg(f,i3+(pW..f)) = {f/.(pW..f)} by A21,A36,A46,A47
,TOPREAL1:def 6;
        then x1 in {f/.(pW..f)} by A23,A27,A24,A33,XBOOLE_0:def 4;
        then x1 = f/.(pW..f) by TARSKI:def 1
          .= pW by A2,FINSEQ_5:38;
        hence contradiction by A20,TARSKI:def 2;
      end;
    end;
    hence contradiction;
  end;
A48: US/.1 = Cage(C,n)/.1 by A2,FINSEQ_5:44
    .= N-min L~Cage(C,n) by JORDAN9:32;
  US is non empty by A16,NAT_1:39;
  then
A49: N-min L~Cage(C,n) in rng US by A48,FINSEQ_6:42;
A50: E-max L~Cage(C,n) in rng LS by FINSEQ_6:61;
  thus {N-min L~Cage(C,n),E-max L~Cage(C,n)} c= L~US /\ L~LS
  proof
    let x be object;
    assume
A51: x in {N-min L~Cage(C,n),E-max L~Cage(C,n)};
    per cases by A51,TARSKI:def 2;
    suppose
      x = N-min L~Cage(C,n);
      hence thesis by A9,A18,A49,A14,XBOOLE_0:def 4;
    end;
    suppose
      x = E-max L~Cage(C,n);
      hence thesis by A9,A50,A18,A15,XBOOLE_0:def 4;
    end;
  end;
end;
