reserve n,i,k,m for Nat;
reserve r,r1,r2,s,s1,s2 for Real;
reserve p,p1,p2,q1,q2 for Point of TOP-REAL n;
reserve P,Q for Subset of TOP-REAL 2,
  f,f1,f2 for FinSequence of the carrier of TOP-REAL 2,
  p,p1,p2,p3,q,q3 for Point of TOP-REAL 2;

theorem Th35:
  f is special alternating & 1<=i & i+2<=len f & f/.(i+1) in LSeg(
  p,q) & LSeg(p,q) c= LSeg(f,i) \/ LSeg(f,i+1) implies f/.(i+1)=p or f/.(i+1)=q
proof
  assume that
A1: f is special & f is alternating and
A2: 1<=i and
A3: i+2<=len f;
  i+1 <= i+2 by XREAL_1:6;
  then
A4: i+1 <= len f by A3,XXREAL_0:2;
  set p1=f/.i, p0=f/.(i+1), p2=f/.(i+2);
A5: i+(1+1) = i+1+1 & 1 <= i+1 by NAT_1:11;
  assume that
A6: p0 in LSeg(p,q) and
A7: LSeg(p,q)c=LSeg(f,i) \/ LSeg(f,i+1);
A8: p in LSeg(p,q) & q in LSeg(p,q) by RLTOPSP1:68;
  now
    per cases by A7,A8,XBOOLE_0:def 3;
    case
      p in LSeg(f,i)& q in LSeg(f,i);
      then p in LSeg(p1,p0) & q in LSeg(p1,p0) by A2,A4,TOPREAL1:def 3;
      then
A9:   LSeg(p,q)c=LSeg(p1,p0) by TOPREAL1:6;
      p0 is_extremal_in LSeg(p1,p0) by Th11;
      hence thesis by A6,A9;
    end;
    case
A10:  p in LSeg(f,i)& q in LSeg(f,i+1);
      then p in LSeg(p1,p0) by A2,A4,TOPREAL1:def 3;
      then consider s such that
A11:  p=(1-s)*p1+s*p0 and
      0<=s and
      s<=1;
A12:  p`1=((1-s)*p1)`1+(s*p0)`1 by A11,TOPREAL3:2
        .=(1-s)*(p1`1)+(s*p0)`1 by TOPREAL3:4
        .=(1-s)*(p1`1)+s*(p0`1) by TOPREAL3:4;
      q in LSeg(p0,p2) by A3,A5,A10,TOPREAL1:def 3;
      then consider s1 such that
A13:  q=(1-s1)*p0+s1*p2 and
      0<=s1 and
      s1<=1;
A14:  q`2=((1-s1)*p0)`2+(s1*p2)`2 by A13,TOPREAL3:2
        .=(1-s1)*(p0`2)+(s1*p2)`2 by TOPREAL3:4
        .=(1-s1)*(p0`2)+s1*(p2`2) by TOPREAL3:4;
A15:  p`2=((1-s)*p1)`2+(s*p0)`2 by A11,TOPREAL3:2
        .=(1-s)*(p1`2)+(s*p0)`2 by TOPREAL3:4
        .=(1-s)*(p1`2)+s*(p0`2) by TOPREAL3:4;
A16:  q`1=((1-s1)*p0)`1+(s1*p2)`1 by A13,TOPREAL3:2
        .=(1-s1)*(p0`1)+(s1*p2)`1 by TOPREAL3:4
        .=(1-s1)*(p0`1)+s1*(p2`1) by TOPREAL3:4;
      now
A17:    f/.(i+2)=f/.(i+2) & f/.i=f/.i;
        per cases by A1,A2,A3,A17,Th29;
        case
A18:      p1`1=p0`1 & p2`1<>p0`1;
          consider r such that
A19:      p0=(1-r)*p+r*q and
          0<=r and
          r<=1 by A6;
          p0`1=((1-r)*p)`1+(r*q)`1 by A19,TOPREAL3:2
            .=(1-r)*(p`1)+(r*q)`1 by TOPREAL3:4
            .=(1-r)*(p0`1)+r*(q`1) by A12,A18,TOPREAL3:4;
          then r*(p0`1-q`1)=0;
          then
A20:      r=0 or p0`1-q`1=0 by XCMPLX_1:6;
          now
            per cases by A20;
            case
              r=0;
              then p0=(1-0)*p+0.TOP-REAL 2 by A19,RLVECT_1:10
                .=1*p by RLVECT_1:4
                .=p by RLVECT_1:def 8;
              hence thesis;
            end;
            case
              p0`1=q`1;
              then s1*(p0`1-p2`1)=0 by A16;
              then
A21:          s1=0 or p0`1-p2`1=0 by XCMPLX_1:6;
              now
                per cases by A21;
                case
                  s1=0;
                  then q=(1-0)*p0+0.TOP-REAL 2 by A13,RLVECT_1:10
                    .=1*p0 by RLVECT_1:4
                    .=p0 by RLVECT_1:def 8;
                  hence thesis;
                end;
                case
                  p0`1=p2`1;
                  hence contradiction by A18;
                end;
              end;
              hence thesis;
            end;
          end;
          hence thesis;
        end;
        case
A22:      p1`2=p0`2 & p2`2<>p0`2;
          consider r such that
A23:      p0=(1-r)*p+r*q and
          0<=r and
          r<=1 by A6;
          p0`2=((1-r)*p)`2+(r*q)`2 by A23,TOPREAL3:2
            .=(1-r)*(p`2)+(r*q)`2 by TOPREAL3:4
            .=(1-r)*(p0`2)+r*(q`2) by A15,A22,TOPREAL3:4;
          then r*(p0`2-q`2)=0;
          then
A24:      r=0 or p0`2-q`2=0 by XCMPLX_1:6;
          now
            per cases by A24;
            case
              r=0;
              then p0=(1-0)*p+0.TOP-REAL 2 by A23,RLVECT_1:10
                .=1*p by RLVECT_1:4
                .=p by RLVECT_1:def 8;
              hence thesis;
            end;
            case
              p0`2=q`2;
              then s1*(p0`2-p2`2)=0 by A14;
              then
A25:          s1=0 or p0`2-p2`2=0 by XCMPLX_1:6;
              now
                per cases by A25;
                case
                  s1=0;
                  then q=(1-0)*p0+0.TOP-REAL 2 by A13,RLVECT_1:10
                    .=1*p0 by RLVECT_1:4
                    .=p0 by RLVECT_1:def 8;
                  hence thesis;
                end;
                case
                  p0`2=p2`2;
                  hence contradiction by A22;
                end;
              end;
              hence thesis;
            end;
          end;
          hence thesis;
        end;
      end;
      hence thesis;
    end;
    case
A26:  p in LSeg(f,i+1)& q in LSeg(f,i);
      then q in LSeg(p1,p0) by A2,A4,TOPREAL1:def 3;
      then consider s such that
A27:  q=(1-s)*p1+s*p0 and
      0<=s and
      s<=1;
A28:  q`1=((1-s)*p1)`1+(s*p0)`1 by A27,TOPREAL3:2
        .=(1-s)*(p1`1)+(s*p0)`1 by TOPREAL3:4
        .=(1-s)*(p1`1)+s*(p0`1) by TOPREAL3:4;
      p in LSeg(p0,p2) by A3,A5,A26,TOPREAL1:def 3;
      then consider s1 such that
A29:  p=(1-s1)*p0+s1*p2 and
      0<=s1 and
      s1<=1;
A30:  p`2=((1-s1)*p0)`2+(s1*p2)`2 by A29,TOPREAL3:2
        .=(1-s1)*(p0`2)+(s1*p2)`2 by TOPREAL3:4
        .=(1-s1)*(p0`2)+s1*(p2`2) by TOPREAL3:4;
A31:  q`2=((1-s)*p1)`2+(s*p0)`2 by A27,TOPREAL3:2
        .=(1-s)*(p1`2)+(s*p0)`2 by TOPREAL3:4
        .=(1-s)*(p1`2)+s*(p0`2) by TOPREAL3:4;
A32:  p`1=((1-s1)*p0)`1+(s1*p2)`1 by A29,TOPREAL3:2
        .=(1-s1)*(p0`1)+(s1*p2)`1 by TOPREAL3:4
        .=(1-s1)*(p0`1)+s1*(p2`1) by TOPREAL3:4;
      now
A33:    f/.(i+2)=f/.(i+2) & f/.i=f/.i;
        per cases by A1,A2,A3,A33,Th29;
        case
A34:      p1`1=p0`1 & p2`1<>p0`1;
          p0 in LSeg(q,p) by A6;
          then consider r such that
A35:      p0=(1-r)*q+r*p and
          0<=r and
          r<=1;
          p0`1=((1-r)*q)`1+(r*p)`1 by A35,TOPREAL3:2
            .=(1-r)*(q`1)+(r*p)`1 by TOPREAL3:4
            .=(1-r)*(p0`1)+r*(p`1) by A28,A34,TOPREAL3:4;
          then r*(p0`1-p`1)=0;
          then
A36:      r=0 or p0`1-p`1=0 by XCMPLX_1:6;
          now
            per cases by A36;
            case
              r=0;
              then p0=(1-0)*q+0.TOP-REAL 2 by A35,RLVECT_1:10
                .=1*q by RLVECT_1:4
                .=q by RLVECT_1:def 8;
              hence thesis;
            end;
            case
              p0`1=p`1;
              then s1*(p0`1-p2`1)=0 by A32;
              then
A37:          s1=0 or p0`1-p2`1=0 by XCMPLX_1:6;
              now
                per cases by A37;
                case
                  s1=0;
                  then p=(1-0)*p0+0.TOP-REAL 2 by A29,RLVECT_1:10
                    .=1*p0 by RLVECT_1:4
                    .=p0 by RLVECT_1:def 8;
                  hence thesis;
                end;
                case
                  p0`1=p2`1;
                  hence contradiction by A34;
                end;
              end;
              hence thesis;
            end;
          end;
          hence thesis;
        end;
        case
A38:      p1`2=p0`2 & p2`2<>p0`2;
          p0 in LSeg(q,p) by A6;
          then consider r such that
A39:      p0=(1-r)*q+r*p and
          0<=r and
          r<=1;
          p0`2=((1-r)*q)`2+(r*p)`2 by A39,TOPREAL3:2
            .=(1-r)*(q`2)+(r*p)`2 by TOPREAL3:4
            .=(1-r)*(p0`2)+r*(p`2) by A31,A38,TOPREAL3:4;
          then r*(p0`2-p`2)=0;
          then
A40:      r=0 or p0`2-p`2=0 by XCMPLX_1:6;
          now
            per cases by A40;
            case
              r=0;
              then p0=(1-0)*q+0.TOP-REAL 2 by A39,RLVECT_1:10
                .=1*q by RLVECT_1:4
                .=q by RLVECT_1:def 8;
              hence thesis;
            end;
            case
              p0`2=p`2;
              then s1*(p0`2-p2`2)=0 by A30;
              then
A41:          s1=0 or p0`2-p2`2=0 by XCMPLX_1:6;
              now
                per cases by A41;
                case
                  s1=0;
                  then p=(1-0)*p0+0.TOP-REAL 2 by A29,RLVECT_1:10
                    .=1*p0 by RLVECT_1:4
                    .=p0 by RLVECT_1:def 8;
                  hence thesis;
                end;
                case
                  p0`2=p2`2;
                  hence contradiction by A38;
                end;
              end;
              hence thesis;
            end;
          end;
          hence thesis;
        end;
      end;
      hence thesis;
    end;
    case
      p in LSeg(f,i+1)& q in LSeg(f,i+1);
      then p in LSeg(p0,p2) & q in LSeg(p0,p2) by A3,A5,TOPREAL1:def 3;
      then
A42:  LSeg(p,q)c=LSeg(p0,p2) by TOPREAL1:6;
      p0 is_extremal_in LSeg(p0,p2) by Th11;
      hence thesis by A6,A42;
    end;
  end;
  hence thesis;
end;
