reserve p,p1,p2,p3,p11,p22,q,q1,q2 for Point of TOP-REAL 2,
  f,h for FinSequence of TOP-REAL 2,
  r,r1,r2,s,s1,s2 for Real,
  u,u1,u2,u5 for Point of Euclid 2,
  n,m,i,j,k for Nat,
  N for Nat,
  x,y,z for set;
reserve lambda for Real;

theorem
  not p1 in Ball(u,r) & q in Ball(u,r) & p in Ball(u,r) & not p in LSeg(
p1,q ) & ( q`1=p`1 & q`2<>p`2 or q`1<>p`1 & q`2=p`2 ) & (p1`1=q`1 or p1`2=q`2)
  implies LSeg(p1,q) /\ LSeg(q,p) = {q}
proof
  assume that
A1: not p1 in Ball(u,r) and
A2: q in Ball(u,r) and
A3: p in Ball(u,r) and
A4: not p in LSeg(p1,q);
  assume
A5: q`1=p`1 & q`2<>p`2 or q`1<>p`1 & q`2=p`2;
  assume
A6: p1`1=q`1 or p1`2=q`2;
A7: now
    per cases by A6;
    suppose
      p1`1=q`1;
      hence p1`1=q`1 & p1`2<>q`2 or p1`1<>q`1 & p1`2=q`2 by A1,A2,Th6;
    end;
    suppose
      p1`2=q`2;
      hence p1`1=q`1 & p1`2<>q`2 or p1`1<>q`1 & p1`2=q`2 by A1,A2,Th6;
    end;
  end;
A8: p=|[p`1,p`2]| by EUCLID:53;
A9: p1=|[p1`1,p1`2]| by EUCLID:53;
A10: q=|[q`1,q`2]| by EUCLID:53;
A11: LSeg(p,q) c= Ball(u,r) by A2,A3,Th21;
  now
    per cases by A5;
    suppose
A12:  q`1=p`1 & q`2<>p`2;
      set r = p`1, pq = {p2: p2`1=r & p`2<=p2`2 & p2`2<=q`2}, qp = {p3: p3`1=r
& q`2<=p3`2 & p3`2<=p`2}, pp1 = {p11: p11`1=r & p`2<=p11`2 & p11`2<=p1`2}, p1p
= {p22: p22`1=r & p1`2<=p22`2 & p22`2<=p`2}, qp1 = {q1: q1`1=r & q`2<=q1`2 & q1
      `2<=p1`2}, p1q = {q2: q2`1=r & p1`2<=q2`2 & q2`2<=q`2};
      now
        per cases by A12,XXREAL_0:1;
        suppose
A13:      q`2>p`2;
          now
            per cases by A7;
            suppose
A14:          p1`1=q`1 & p1`2<>q`2;
              now
                per cases by A14,XXREAL_0:1;
                case
A15:              p1`2>q`2;
                  then q in pp1 by A12,A13;
                  then q in LSeg(p,p1) by A8,A9,A12,A13,A14,A15,Th9,XXREAL_0:2;
                  hence thesis by TOPREAL1:8;
                end;
                case
A16:              p1`2<q`2;
                  now
                    per cases by XXREAL_0:1;
                    suppose
A17:                  p1`2>p`2;
                      then p1 in pq by A12,A14,A16;
                      then p1 in LSeg(p,q) by A8,A10,A12,A16,A17,Th9,XXREAL_0:2
;
                      hence contradiction by A1,A11;
                    end;
                    suppose
                      p1`2=p`2;
                      hence contradiction by A1,A3,A12,A14,Th6;
                    end;
                    suppose
                      p1`2<p`2;
                      then p in p1q by A13;
                      hence contradiction by A4,A9,A10,A12,A14,A16,Th9;
                    end;
                  end;
                  hence contradiction;
                end;
              end;
              hence thesis;
            end;
            suppose
              p1`1<>q`1 & p1`2=q`2;
              hence thesis by A10,A12,Th30;
            end;
          end;
          hence thesis;
        end;
        suppose
A18:      q`2<p`2;
          now
            per cases by A7;
            suppose
A19:          p1`1=q`1 & p1`2<>q`2;
              now
                per cases by A19,XXREAL_0:1;
                case
A20:              p1`2>q`2;
                  now
                    per cases by XXREAL_0:1;
                    suppose
                      p1`2>p`2;
                      then p in qp1 by A18;
                      hence contradiction by A4,A9,A10,A12,A19,A20,Th9;
                    end;
                    suppose
                      p1`2=p`2;
                      hence contradiction by A1,A3,A12,A19,Th6;
                    end;
                    suppose
                      p1`2<p`2;
                      then p1 in qp by A12,A19,A20;
                      then p1 in LSeg(p,q) by A8,A10,A12,A18,Th9;
                      hence contradiction by A1,A11;
                    end;
                  end;
                  hence contradiction;
                end;
                case
A21:              p1`2<q`2;
                  then q in p1p by A12,A18;
                  then q in LSeg(p1,p) by A8,A9,A12,A18,A19,A21,Th9,XXREAL_0:2;
                  hence thesis by TOPREAL1:8;
                end;
              end;
              hence thesis;
            end;
            suppose
              p1`1<>q`1 & p1`2=q`2;
              hence thesis by A10,A12,Th30;
            end;
          end;
          hence thesis;
        end;
      end;
      hence thesis;
    end;
    suppose
A22:  q`1<>p`1 & q`2=p`2;
      set r = p`2, pq = {p2: p2`2=r & p`1<=p2`1 & p2`1<=q`1}, qp = {p3: p3`2=r
& q`1<=p3`1 & p3`1<=p`1}, pp1 = {p11: p11`2=r & p`1<=p11`1 & p11`1<=p1`1}, p1p
= {p22: p22`2=r & p1`1<=p22`1 & p22`1<=p`1}, qp1 = {q1: q1`2=r & q`1<=q1`1 & q1
      `1<=p1`1}, p1q = {q2: q2`2=r & p1`1<=q2`1 & q2`1<=q`1};
      now
        per cases by A22,XXREAL_0:1;
        suppose
A23:      q`1>p`1;
          now
            per cases by A7;
            suppose
              p1`1=q`1 & p1`2<>q`2;
              hence thesis by A10,A22,Th29;
            end;
            suppose
A24:          p1`1<>q`1 & p1`2=q`2;
              now
                per cases by A24,XXREAL_0:1;
                case
A25:              p1`1>q`1;
                  then q in pp1 by A22,A23;
                  then q in LSeg(p,p1) by A8,A9,A22,A23,A24,A25,Th10,XXREAL_0:2
;
                  hence thesis by TOPREAL1:8;
                end;
                case
A26:              p1`1<q`1;
                  now
                    per cases by XXREAL_0:1;
                    suppose
A27:                  p1`1>p`1;
                      then p1 in pq by A22,A24,A26;
                      then p1 in LSeg(p,q) by A8,A10,A22,A26,A27,Th10,
XXREAL_0:2;
                      hence contradiction by A1,A11;
                    end;
                    suppose
                      p1`1=p`1;
                      hence contradiction by A1,A3,A22,A24,Th6;
                    end;
                    suppose
                      p1`1<p`1;
                      then p in p1q by A23;
                      hence contradiction by A4,A9,A10,A22,A24,A26,Th10;
                    end;
                  end;
                  hence contradiction;
                end;
              end;
              hence thesis;
            end;
          end;
          hence thesis;
        end;
        suppose
A28:      q`1<p`1;
          now
            per cases by A7;
            suppose
              p1`1=q`1 & p1`2<>q`2;
              hence thesis by A10,A22,Th29;
            end;
            suppose
A29:          p1`1<>q`1 & p1`2=q`2;
              now
                per cases by A29,XXREAL_0:1;
                case
A30:              p1`1>q`1;
                  now
                    per cases by XXREAL_0:1;
                    suppose
                      p1`1>p`1;
                      then p in qp1 by A28;
                      hence contradiction by A4,A9,A10,A22,A29,A30,Th10;
                    end;
                    suppose
                      p1`1=p`1;
                      hence contradiction by A1,A3,A22,A29,Th6;
                    end;
                    suppose
                      p1`1<p`1;
                      then p1 in qp by A22,A29,A30;
                      then p1 in LSeg(p,q) by A8,A10,A22,A28,Th10;
                      hence contradiction by A1,A11;
                    end;
                  end;
                  hence contradiction;
                end;
                case
A31:              p1`1<q`1;
                  then q in p1p by A22,A28;
                  then q in LSeg(p1,p) by A8,A9,A22,A28,A29,A31,Th10,XXREAL_0:2
;
                  hence thesis by TOPREAL1:8;
                end;
              end;
              hence thesis;
            end;
          end;
          hence thesis;
        end;
      end;
      hence thesis;
    end;
  end;
  hence thesis;
end;
