reserve i,j,l for Nat;

theorem Th5:
  for f being S-Sequence_in_R2, Q being closed Subset of TOP-REAL 2
st L~f meets Q & not f/.len f in Q holds L~L_Cut(f,Last_Point(L~f,f/.1,f/.len f
  ,Q)) /\ Q = { Last_Point(L~f,f/.1,f/.len f,Q) }
proof
  let f be S-Sequence_in_R2, Q be closed Subset of TOP-REAL 2 such that
A1: L~f meets Q and
A2: not f/.len f in Q;
  set p1 = f/.1, p2 = f/.len f, lp = Last_Point(L~f,p1,p2,Q);
A3: L~f /\ Q is closed by TOPS_1:8;
  len f >= 1+1 by TOPREAL1:def 8;
  then
A4: len f > 1 by NAT_1:13; then
AA: len f in dom f by FINSEQ_3:25;
  L~f is_an_arc_of p1,p2 by TOPREAL1:25;
  then
A5: lp in L~f /\ Q by A1,A3,JORDAN5C:def 2;
  then
A6: lp in L~f by XBOOLE_0:def 4;
  then
A7: 1<=Index(lp,f) by JORDAN3:8;
A8: now
    set m = mid(f,Index(lp,f)+1,len f);
    assume not L~L_Cut(f,lp) /\ Q c= { lp };
    then consider q being object such that
A9: q in L~L_Cut(f,lp) /\ Q and
A10: not q in { lp } by TARSKI:def 3;
    reconsider q as Point of TOP-REAL 2 by A9;
A11: q in L~L_Cut(f,lp) by A9,XBOOLE_0:def 4;
A12: L~L_Cut(f,lp) c= L~f by A6,JORDAN3:42;
A13: Index(lp,f) < len f by A6,JORDAN3:8;
    then
A14: Index(lp,f)+1 <= len f by NAT_1:13;
A15: 1 <= Index(lp,f)+1 by NAT_1:11;
    then len m = len f -' (Index(lp,f)+1)+1 by A14,FINSEQ_6:186;
    then
A16: m is non empty by CARD_1:27;
A17: q <> lp by A10,TARSKI:def 1;
    q in Q by A9,XBOOLE_0:def 4;
    then
A18: LE q, lp, L~f, p1, p2 by A3,A11,A12,JORDAN5C:16;
    per cases;
    suppose
      lp=f.(Index(lp,f)+1);
      then
A19:  q in L~m by A11,JORDAN3:def 3;
      now
        assume Index(lp,f)+1 >= len f;
        then Index(lp,f)+1 = len f by A14,XXREAL_0:1;
        then len m = 1 by AA,FINSEQ_6:193;
        hence contradiction by A19,TOPREAL1:22;
      end;
      then
A20:  LE f/.(Index(lp,f)+1), q, L~f, f/.1, f/.len f by A19,Th3,NAT_1:11;
A21:  f/.(Index(lp,f)+1) in LSeg(lp,f/.(Index(lp,f)+1)) by RLTOPSP1:68;
      lp in LSeg(f,Index(lp,f)) by A6,JORDAN3:9;
      then LE lp, f/.(Index(lp,f)+1), L~f, p1, p2 by A7,A13,A21,Th4;
      then LE lp, q, L~f, p1, p2 by A20,JORDAN5C:13;
      hence contradiction by A17,A18,JORDAN5C:12,TOPREAL1:25;
    end;
    suppose
A22:  lp<>f.(Index(lp,f)+1);
A23:  lp in LSeg(f,Index(lp,f)) by A6,JORDAN3:9;
      1 <= Index(lp,f)+1 by NAT_1:11;
      then
A24:  Index(lp,f)+1 in dom f by A14,FINSEQ_3:25;
      q in L~(<*lp*>^m) by A11,A22,JORDAN3:def 3;
      then
A25:  q in L~m \/ LSeg(m/.1,lp) by A16,SPPOL_2:20;
      now
        per cases by A25,XBOOLE_0:def 3;
        suppose
A26:      q in L~m;
          now
            assume Index(lp,f)+1 >= len f;
            then Index(lp,f)+1 = len f by A14,XXREAL_0:1;
            then len m = 1 by AA,FINSEQ_6:193;
            hence contradiction by A26,TOPREAL1:22;
          end;
          then
A27:      LE f/.(Index(lp,f)+1), q, L~f, f/.1, f/.len f by A26,Th3,NAT_1:11;
          f/.(Index(lp,f)+1) in LSeg(lp,f/.(Index(lp,f)+1)) by RLTOPSP1:68;
          then LE lp, f/.(Index(lp,f)+1), L~f, p1, p2 by A7,A13,A23,Th4;
          then LE lp, q, L~f, p1, p2 by A27,JORDAN5C:13;
          hence contradiction by A17,A18,JORDAN5C:12,TOPREAL1:25;
        end;
        suppose
A28:      q in LSeg(lp,m/.1);
          1 in dom m by A16,FINSEQ_5:6;
          then m/.1 = m.1 by PARTFUN1:def 6
            .= f.(Index(lp,f)+1) by A4,A14,A15,FINSEQ_6:118
            .= f/.(Index(lp,f)+1) by A24,PARTFUN1:def 6;
          then LE lp, q, L~f, p1, p2 by A7,A13,A23,A28,Th4;
          hence contradiction by A17,A18,JORDAN5C:12,TOPREAL1:25;
        end;
      end;
      hence contradiction;
    end;
  end;
A29: lp in Q by A5,XBOOLE_0:def 4;
  len f in dom f by A4,FINSEQ_3:25;
  then lp <> f.len f by A2,A29,PARTFUN1:def 6;
  then lp in L~L_Cut(f,lp) by A6,JORDAN5B:19;
  then lp in L~L_Cut(f,lp) /\ Q by A29,XBOOLE_0:def 4;
  hence thesis by A8,ZFMISC_1:33;
end;
