reserve n for Nat;

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