reserve P,P1,P2,R for Subset of TOP-REAL 2,
  p,p1,p2,p3,p11,p22,q,q1,q2,q3,q4 for Point of TOP-REAL 2,
  f,h for FinSequence of TOP-REAL 2,
  r for Real,
  u for Point of Euclid 2,
  n,m,i,j,k for Nat,
  x,y for set;

theorem Th21:
  f/.len f in Ball(u,r) & p in Ball(u,r) & |[(f/.len f)`1,p`2]| in
Ball(u,r) & f is being_S-Seq & p`1<>(f/.len f)`1 & p`2<>(f/.len f)`2 & h=f^<*|[
(f/.len f)`1,p`2]|,p*> & (LSeg(f/.len f,|[(f/.len f)`1,p`2]|) \/ LSeg(|[(f/.len
f)`1,p`2]|,p)) /\ L~f = {f/.len f} implies L~h is_S-P_arc_joining f/.1,p & L~h
  c= L~f \/ Ball(u,r)
proof
  set p1 = f/.1, p2 = f/.len f;
  assume that
A1: p2 in Ball(u,r) and
A2: p in Ball(u,r) and
A3: |[p2`1,p`2]| in Ball(u,r) and
A4: f is being_S-Seq and
A5: p`1<>p2`1 and
A6: p`2<>p2`2 and
A7: h=f^<*|[p2`1,p`2]|,p*> and
A8: (LSeg(p2,|[p2`1,p`2]|) \/ LSeg(|[p2`1,p`2]|,p)) /\ L~f = {p2};
  set p3 = |[p2`1,p`2]|, f1 = f^<* p3 *>, h1 = f1^<* p *>;
  reconsider Lf = L~f as non empty Subset of TOP-REAL 2 by A8;
A9: p2 in LSeg(p2,p3) by RLTOPSP1:68;
  L~f is_S-P_arc_joining p1,p2 by A4;
  then Lf is_an_arc_of p1,p2 by Th2;
  then p2 in L~f by TOPREAL1:1;
  then p2 in LSeg(p2,p3) /\ L~f by A9,XBOOLE_0:def 4;
  then
A10: LSeg(p2,p3) /\ L~f c= (LSeg(p2,p3) /\ L~f) \/ (LSeg(p3,p) /\ L~f) & {p2
  } c= LSeg(p2,p3) /\ L~f by XBOOLE_1:7,ZFMISC_1:31;
  {p2} = (LSeg(p2,p3) /\ L~f) \/ (LSeg(p3,p) /\ L~f) by A8,XBOOLE_1:23;
  then
A11: LSeg(p2,p3) /\ L~f = {p2} by A10;
A12: len f1 = len f + len <*p3*> by FINSEQ_1:22
    .= len f + 1 by FINSEQ_1:39;
  then
A13: f1/.len f1 = p3 by FINSEQ_4:67;
A14: p=|[p`1,p`2]| by EUCLID:53;
A15: Seg len f = dom f by FINSEQ_1:def 3;
  len f>=2 by A4;
  then
A16: 1<=len f by XXREAL_0:2;
  then len f in dom f by A15,FINSEQ_1:1;
  then
A17: f1/.len f = p2 by FINSEQ_4:68;
A18: LSeg(p3,p) /\ L~f1 c= {p3}
  proof
    set M1 = {LSeg(f1,i): 1<=i & i+1<=len f1}, Mf = {LSeg(f,j): 1<=j & j+1<=
    len f};
    assume not thesis;
    then consider x being object such that
A19: x in LSeg(p3,p) /\ L~f1 and
A20: not x in {p3};
    x in L~f1 by A19,XBOOLE_0:def 4;
    then consider X be set such that
A21: x in X and
A22: X in M1 by TARSKI:def 4;
    consider k such that
A23: X=LSeg(f1,k) and
A24: 1<=k and
A25: k+1<=len f1 by A22;
A26: x in LSeg(p3,p) by A19,XBOOLE_0:def 4;
    now
      per cases by A25,XXREAL_0:1;
      suppose
        k+1 = len f1;
        then LSeg(f1,k) = LSeg(p2,p3) by A12,A13,A17,A24,TOPREAL1:def 3;
        then x in LSeg(p2,p3) /\ LSeg(p3,p) by A26,A21,A23,XBOOLE_0:def 4;
        hence contradiction by A20,TOPREAL3:29;
      end;
      suppose
        k+1 < len f1;
        then
A27:    k+1<=len f by A12,NAT_1:13;
        k<=k+1 by NAT_1:11;
        then k<=len f by A27,XXREAL_0:2;
        then
A28:    k in dom f by A15,A24,FINSEQ_1:1;
        1<=k+1 by A24,NAT_1:13;
        then k+1 in dom f by A15,A27,FINSEQ_1:1;
        then X=LSeg(f,k) by A23,A28,TOPREAL3:18;
        then X in Mf by A24,A27;
        then
A29:    x in L~f by A21,TARSKI:def 4;
        x in LSeg(p2,p3) \/ LSeg(p3,p) by A26,XBOOLE_0:def 3;
        then x in {p2} by A8,A29,XBOOLE_0:def 4;
        then x = p2 by TARSKI:def 1;
        hence contradiction by A6,A14,A26,TOPREAL3:12;
      end;
    end;
    hence contradiction;
  end;
A30: h1 = f^(<*p3*>^<*p*>) by FINSEQ_1:32
    .= h by A7,FINSEQ_1:def 9;
A31: p3`2 = p`2 & p3`1 = p2`1 by EUCLID:52;
  then
A32: f1 is being_S-Seq by A1,A3,A4,A6,A11,Th19;
A33: L~f1 is_S-P_arc_joining p1,p3 by A1,A3,A4,A6,A31,A11,Th19;
  then reconsider Lf1 = L~f1 as non empty Subset of TOP-REAL 2 by Th1,
TOPREAL1:26;
A34: p3 in LSeg(p3,p) by RLTOPSP1:68;
A35: f1/.len f1=p3 by A12,FINSEQ_4:67;
  L~f1 c= L~f \/ Ball(u,r) by A1,A3,A4,A6,A31,A11,Th19;
  then L~f1 \/ Ball(u,r) c= L~f \/ Ball(u,r) \/ Ball(u,r) by XBOOLE_1:9;
  then
A36: L~f1 \/ Ball(u,r) c= L~f \/ (Ball(u,r) \/ Ball(u,r)) by XBOOLE_1:4;
A37: p`1=p3`1 & p`2<>p3`2 or p`1<>p3`1 & p`2=p3`2 by A5,EUCLID:52;
  Lf1 is_an_arc_of p1,p3 by A33,Th2;
  then p3 in L~f1 by TOPREAL1:1;
  then p3 in LSeg(p3,p) /\ L~f1 by A34,XBOOLE_0:def 4;
  then {p3} c= LSeg(p3,p) /\ L~f1 by ZFMISC_1:31;
  then
A38: LSeg(p3,p) /\ L~f1 = {p3} by A18;
  1 in dom f by A15,A16,FINSEQ_1:1;
  then f1/.1=p1 by FINSEQ_4:68;
  hence L~h is_S-P_arc_joining p1,p by A2,A3,A37,A32,A35,A38,A30,Th19;
  L~h1 c= L~f1 \/ Ball(u,r) by A2,A3,A37,A32,A35,A38,Th19;
  hence thesis by A30,A36;
end;
