reserve n for Nat;

theorem Th18:
  for C be compact connected non vertical non horizontal Subset of
TOP-REAL 2 for i,j,k be Nat st 1 <= j & j <= k & k <= len Gauge(C,n)
  & 1 <= i & i <= width Gauge(C,n) & Gauge(C,n)*(j,i) in L~Upper_Seq(C,n) ex j1
be Nat st j <= j1 & j1 <= k & LSeg(Gauge(C,n)*(j1,i),Gauge(C,n)*(k,i
  )) /\ L~Upper_Seq(C,n) = {Gauge(C,n)*(j1,i)}
proof
  let C be compact connected non vertical non horizontal Subset of TOP-REAL 2;
  let i,j,k be Nat;
  assume that
A1: 1 <= j and
A2: j <= k and
A3: k <= len Gauge(C,n) and
A4: 1 <= i and
A5: i <= width Gauge(C,n) and
A6: Gauge(C,n)*(j,i) in L~Upper_Seq(C,n);
  set G = Gauge(C,n);
A7: k >= 1 by A1,A2,XXREAL_0:2;
  then
A8: [k,i] in Indices G by A3,A4,A5,MATRIX_0:30;
  set X = LSeg(G*(j,i),G*(k,i)) /\ L~Upper_Seq(C,n);
A9: G*(j,i) in LSeg(G*(j,i),G*(k,i)) by RLTOPSP1:68;
  then reconsider X1=X as non empty compact Subset of TOP-REAL 2 by A6,
XBOOLE_0:def 4;
A10: LSeg(G*(j,i),G*(k,i)) meets L~Upper_Seq(C,n) by A6,A9,XBOOLE_0:3;
  set s = G*(1,i)`2;
  set e = G*(k,i);
  set f = G*(j,i);
  set w2 = upper_bound(proj1.:(LSeg(f,e) /\ L~Upper_Seq(C,n)));
A11: len G = width G by JORDAN8:def 1;
  then
A12: j <= width G by A2,A3,XXREAL_0:2;
  then [j,i] in Indices G by A1,A4,A5,A11,MATRIX_0:30;
  then consider j1 be Nat such that
A13: j <= j1 and
A14: j1 <= k and
A15: G*(j1,i)`1 = w2 by A2,A10,A8,JORDAN1F:4,JORDAN1G:4;
  set q = |[w2,s]|;
A16: 1 <= j1 by A1,A13,XXREAL_0:2;
  take j1;
  thus j <= j1 & j1 <= k by A13,A14;
  consider pp be object such that
A17: pp in E-most X1 by XBOOLE_0:def 1;
  reconsider pp as Point of TOP-REAL 2 by A17;
A18: pp in X by A17,XBOOLE_0:def 4;
  then
A19: pp in L~Upper_Seq(C,n) by XBOOLE_0:def 4;
A20: j1 <= width G by A3,A11,A14,XXREAL_0:2;
  then
A21: G*(j1,i)`2 = s by A4,A5,A11,A16,GOBOARD5:1;
  then
A22: q = G*(j1,i) by A15,EUCLID:53;
  then
A23: q`1 <= e`1 by A3,A4,A5,A14,A16,SPRECT_3:13;
A24: G*(k,i)`2 = s by A3,A4,A5,A7,GOBOARD5:1;
  then f`2 = e`2 by A1,A4,A5,A11,A12,GOBOARD5:1;
  then
A25: LSeg(f,e) is horizontal by SPPOL_1:15;
A26: q`1 = E-bound X by A15,A22,SPRECT_1:46
    .= (E-min X)`1 by EUCLID:52
    .= pp`1 by A17,PSCOMP_1:47;
  pp in LSeg(G*(j,i),G*(k,i)) by A18,XBOOLE_0:def 4;
  then pp`2 = q`2 by A24,A21,A22,A25,SPPOL_1:40;
  then
A27: q in L~Upper_Seq(C,n) by A19,A26,TOPREAL3:6;
  for x be object holds x in LSeg(e,q) /\ L~Upper_Seq(C,n) iff x = q
  proof
    let x be object;
    thus x in LSeg(e,q) /\ L~Upper_Seq(C,n) implies x = q
    proof
A28:  f`1 <= q`1 by A1,A4,A5,A11,A13,A20,A22,SPRECT_3:13;
      f`2 = q`2 by A1,A4,A5,A11,A12,A21,A22,GOBOARD5:1;
      then
A29:  q in LSeg(e,f) by A24,A21,A22,A23,A28,GOBOARD7:8;
      e in LSeg(f,e) by RLTOPSP1:68;
      then
A30:  LSeg(e,q) c= LSeg(f,e) by A29,TOPREAL1:6;
      reconsider EE = LSeg(f,e) /\ L~Upper_Seq(C,n) as compact Subset of
      TOP-REAL 2;
      reconsider E0 = proj1.:EE as compact Subset of REAL by Th4;
      assume
A31:  x in LSeg(e,q) /\ L~Upper_Seq(C,n);
      then reconsider pp = x as Point of TOP-REAL 2;
A32:  pp in LSeg(e,q) by A31,XBOOLE_0:def 4;
      then
A33:  pp`1 >= q`1 by A23,TOPREAL1:3;
      pp in L~Upper_Seq(C,n) by A31,XBOOLE_0:def 4;
      then pp in EE by A32,A30,XBOOLE_0:def 4;
      then proj1.pp in E0 by FUNCT_2:35;
      then
A34:  pp`1 in E0 by PSCOMP_1:def 5;
      E0 is real-bounded by RCOMP_1:10;
      then E0 is bounded_above by XXREAL_2:def 11;
      then q`1 >= pp`1 by A15,A22,A34,SEQ_4:def 1;
      then
A35:  pp`1 = q`1 by A33,XXREAL_0:1;
      pp`2 = q`2 by A24,A21,A22,A32,GOBOARD7:6;
      hence thesis by A35,TOPREAL3:6;
    end;
    assume
A36: x = q;
    then x in LSeg(e,q) by RLTOPSP1:68;
    hence thesis by A27,A36,XBOOLE_0:def 4;
  end;
  hence thesis by A22,TARSKI:def 1;
end;
