reserve V for RealLinearSpace,
  o,p,q,r,s,u,v,w,y,y1,u1,v1,w1,u2,v2,w2 for Element of V,
  a,b,c,d,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3 for Real,
  z for set;
reserve A for non empty set;
reserve f,g,h,f1 for Element of Funcs(A,REAL);
reserve x1,x2,x3,x4 for Element of A;
reserve V for non trivial RealLinearSpace;
reserve u,v,w,y,u1,v1,w1,u2,w2 for Element of V;
reserve p,p1,p2,p3,q,q1,q2,q3,r,r1,r2,r3 for Element of ProjectiveSpace(V);
reserve x,z,x1,y1,z1,x2,x3,y2,z2,p4,q4 for Element of ProjectiveSpace(V);

theorem Th31:
  ProjectiveSpace(V) is proper at_least_3rank & (ex p,q1,q2 st not
p,q1,q2 are_collinear & (for r1,r2 ex q3,r3 st r1,r2,r3 are_collinear &
  q1,q2,q3
  are_collinear & p,r3,q3 are_collinear)) implies
 ex CS being CollProjectiveSpace
  st CS = ProjectiveSpace(V) & CS is at_most-3-dimensional
proof
  assume that
A1: ProjectiveSpace(V) is proper and
A2: for p,q holds ex r st p<>r & q<>r & p,q,r are_collinear;
  defpred P[Element of ProjectiveSpace(V), Element of ProjectiveSpace(V),
  Element of ProjectiveSpace(V)] means for y1,y2 ex x2,x1 st y1,y2,x1
  are_collinear & $2,$3,x2 are_collinear & $1,x1,x2 are_collinear;
A3: for p,q1,q2 st q1,q2,p are_collinear holds P[p,q1,q2]
  proof
    let p,q1,q2 such that
A4: q1,q2,p are_collinear;
    now
      let y1,y2;
      y1,y2,y2 are_collinear & p,y2,p are_collinear by Def7;
      hence
      ex x2,x1 st y1,y2,x1 are_collinear & q1,q2,x2 are_collinear & p,x1,x2
      are_collinear by A4;
    end;
    hence thesis;
  end;
A5: for q,q1,q2,p1,p2,x st P[q,q1,q2] & not q1,q2,q are_collinear & q1,q2,x
are_collinear & not p1,p2,q are_collinear & p1,p2,x are_collinear
   holds P[q,p1,p2]
  proof
    let q,q1,q2,p1,p2,x;
    assume that
A6: P[q,q1,q2] and
A7: not q1,q2,q are_collinear and
A8: q1,q2,x are_collinear and
A9: not p1,p2,q are_collinear and
A10: p1,p2,x are_collinear;
A11: q1<>q2 by A7,Def7;
A12: p1<>p2 by A9,Def7;
    now
      let y1,y2;
A13:  now
        ex a being Element of ProjectiveSpace(V) st p1,p2,a are_collinear
    & x<>a
        proof
A14:      now
            assume
A15:        x<>p2;
            take p2;
            p1,p2,p2 are_collinear by Def7;
            hence thesis by A15;
          end;
          now
            assume
A16:        x<>p1;
            take p1;
            p1,p2,p1 are_collinear by Def7;
            hence thesis by A16;
          end;
          hence thesis by A9,A14,Def7;
        end;
        then consider x1 such that
A17:    p1,p2,x1 are_collinear and
A18:    x<>x1;
        consider b,b9 being Element of ProjectiveSpace(V) such that
A19:    y1,y2,b9 are_collinear and
A20:    q1,q2,b are_collinear and
A21:    q,b9,b are_collinear by A6;
        assume
A22:    y1<>y2;
        ex a being Element of ProjectiveSpace(V) st y1,y2,a are_collinear
        & b9<>a
        proof
A23:      now
            assume
A24:        b9<>y2;
            take y2;
            y1,y2,y2 are_collinear by Def7;
            hence thesis by A24;
          end;
          now
            assume
A25:        b9<>y1;
            take y1;
            y1,y2,y1 are_collinear by Def7;
            hence thesis by A25;
          end;
          hence thesis by A22,A23;
        end;
        then consider x3 such that
A26:    b9<>x3 and
A27:    y1,y2,x3 are_collinear;
        consider d,d9 being Element of ProjectiveSpace(V) such that
A28:    x1,x3,d9 are_collinear and
A29:    q1,q2,d are_collinear and
A30:    q,d9,d are_collinear by A6;
A31:    b,d,x are_collinear by A8,A11,A20,A29,Def8;
A32:    now
          assume
A33:      b<>d;
          not q,b,d are_collinear
          proof
            q1,q2,q2 are_collinear by Def7;
            then
A34:        b,d,q2 are_collinear by A11,A20,A29,Def8;
            assume not thesis;
            then
A35:        b,d,q are_collinear by Th24;
            q1,q2,q1 are_collinear by Def7;
            then b,d,q1 are_collinear by A11,A20,A29,Def8;
            hence contradiction by A7,A33,A35,A34,Def8;
          end;
          then consider o being Element of ProjectiveSpace(V) such that
A36:      b9,d9,o are_collinear and
A37:      q,x,o are_collinear by A21,A30,A31,Lm44;
A38:      o,x,q are_collinear by A37,Th24;
          d9,x3,x1 are_collinear by A28,Th24;
          then consider z1 such that
A39:      b9,x3,z1 are_collinear and
A40:      o,x1,z1 are_collinear by A36,Def9;
          x1,o,z1 are_collinear by A40,Th24;
          then consider z2 such that
A41:      x1,x,z2 are_collinear and
A42:      z1,q,z2 are_collinear by A38,Def9;
A43:      q,z1,z2 are_collinear by A42,Th24;
          p1,p2,p2 are_collinear by Def7;
          then
A44:      x1,x,p2 are_collinear by A10,A12,A17,Def8;
          y1,y2,y2 are_collinear by Def7;
          then
A45:      b9,x3,y2 are_collinear by A22,A19,A27,Def8;
          p1,p2,p1 are_collinear by Def7;
          then x1,x,p1 are_collinear by A10,A12,A17,Def8;
          then
A46:      p1,p2,z2 are_collinear by A18,A41,A44,Def8;
          y1,y2,y1 are_collinear by Def7;
          then b9,x3,y1 are_collinear by A22,A19,A27,Def8;
          then y1,y2,z1 are_collinear by A26,A39,A45,Def8;
          hence ex z2,z1 st y1,y2,z1 are_collinear & p1,p2,z2 are_collinear &
  q,
          z1,z2 are_collinear by A46,A43;
        end;
        now
          assume b=d;
          then
A47:      b,q,d9 are_collinear by A30,Th24;
          y1,y2,y2 are_collinear by Def7;
          then
A48:      b9,x3,y2 are_collinear by A22,A19,A27,Def8;
A49:      d9,x3,x1 are_collinear by A28,Th24;
          b,q,b9 are_collinear & b,q,q are_collinear by A21,Def7,Th24;
          then b9,d9,q are_collinear by A7,A20,A47,Def8;
          then consider z1 such that
A50:      b9,x3,z1 are_collinear and
A51:      q,x1,z1 are_collinear by A49,Def9;
A52:      q,z1,x1 are_collinear by A51,Th24;
          y1,y2,y1 are_collinear by Def7;
          then b9,x3,y1 are_collinear by A22,A19,A27,Def8;
          then y1,y2,z1 are_collinear by A26,A50,A48,Def8;
          hence ex z2,z1 st y1,y2,z1 are_collinear & p1,p2,z2 are_collinear &
q,
          z1,z2 are_collinear by A17,A52;
        end;
        hence
        ex z2,z1 st y1,y2,z1 are_collinear & p1,p2,z2 are_collinear & q,z1,
        z2 are_collinear by A32;
      end;
      now
        assume y1=y2;
        then
A53:    y1,y2,q are_collinear by Def7;
        p1,p2,p1 are_collinear & q,q,p1 are_collinear by Def7;
        hence
        ex z2,z1 st y1,y2,z1 are_collinear & p1,p2,z2 are_collinear & q,z1,
        z2 are_collinear by A53;
      end;
      hence
      ex z2,z1 st y1,y2,z1 are_collinear & p1,p2,z2 are_collinear & q,z1,z2
      are_collinear by A13;
    end;
    hence thesis;
  end;
A54: for q1,q2,p1,p2,q st not q1,q2,q are_collinear & not p1,p2,q
  are_collinear & (not ex x st (q1,q2,x are_collinear & p1,p2,x are_collinear))
  ex
  q3,p3 st p1,p2,p3 are_collinear & q1,q2,q3 are_collinear & not q3,p3,q
  are_collinear
  proof
    let q1,q2,p1,p2,q such that
A55: not q1,q2,q are_collinear and
A56: not p1,p2,q are_collinear and
    not ex x st (q1,q2,x are_collinear & p1,p2,x are_collinear);
A57: q<>q1 by A55,Def7;
A58: not q1,p1,q are_collinear or not q1,p2,q are_collinear
    proof
      assume not thesis;
      then
A59:  q,q1,p1 are_collinear & q,q1,p2 are_collinear by Th24;
      q,q1,q are_collinear by Def7;
      hence contradiction by A56,A57,A59,Def8;
    end;
A60: p1,p2,p2 are_collinear by Def7;
    q1,q2,q1 are_collinear & p1,p2,p1 are_collinear by Def7;
    hence thesis by A60,A58;
  end;
A61: for q,q1,q2,p1,p2 st P[q,q1,q2] & not q1,q2,q are_collinear & not p1,p2
  ,q are_collinear &
   not ex x st (q1,q2,x are_collinear & p1,p2,x are_collinear)
  holds P[q,p1,p2]
  proof
    let q,q1,q2,p1,p2;
    assume that
A62: P[q,q1,q2] and
A63: not q1,q2,q are_collinear and
A64: not p1,p2,q are_collinear and
A65: not ex x st (q1,q2,x are_collinear & p1,p2,x are_collinear);
    consider q3,p3 such that
A66: p1,p2,p3 are_collinear and
A67: q1,q2,q3 are_collinear and
A68: not q3,p3,q are_collinear by A54,A63,A64,A65;
    q3,p3,q3 are_collinear by Def7;
    then
A69: P[q,q3,p3] by A5,A62,A63,A67,A68;
    q3,p3,p3 are_collinear by Def7;
    hence thesis by A5,A64,A66,A68,A69;
  end;
A70: for q,q1,q2 st P[q,q1,q2] & not q1,q2,q are_collinear holds for p1,p2
  holds P[q,p1,p2]
  proof
    let q,q1,q2 such that
A71: ( P[q,q1,q2])& not q1,q2,q are_collinear;
    let p1,p2;
A72: not p1,p2,q are_collinear & (not ex x st q1,q2,x are_collinear & p1,p2
    ,x are_collinear) implies P[q,p1,p2] by A61,A71;
    not p1,p2,q are_collinear & (ex x st q1,q2,x are_collinear & p1,p2,x
    are_collinear) implies P[q,p1,p2] by A5,A71;
    hence thesis by A3,A72;
  end;
  reconsider CS = ProjectiveSpace(V) as CollProjectiveSpace by A1,A2,Def10;
  given p,q1,q2 such that
A73: not p,q1,q2 are_collinear and
A74: for r1,r2 ex q3,r3 st r1,r2,r3 are_collinear & q1,q2,q3 are_collinear
  & p,r3,q3 are_collinear;
  take CS;
A75: for q,q1,q2,x,q3 st P[q,q1,q2] & not q1,q2,q are_collinear & q1,q2,x
  are_collinear & q,q3,x are_collinear holds P[q3,q1,q2]
  proof
    let q,q1,q2,x,q3 such that
A76: P[q,q1,q2] and
A77: not q1,q2,q are_collinear and
A78: q1,q2,x are_collinear and
A79: q,q3,x are_collinear;
    now
      let y1,y2;
      consider z2,z1 such that
A80:  y1,y2,z1 are_collinear and
A81:  q1,q2,z2 are_collinear and
A82:  q,z1,z2 are_collinear by A76;
A83:  now
        q3,q,x are_collinear by A79,Th24;
        then consider x2 such that
A84:    q3,z1,x2 are_collinear and
A85:    x,z2,x2 are_collinear by A82,Def9;
A86:    q1<>q2 by A77,Def7;
        q1,q2,q2 are_collinear by Def7;
        then
A87:    x,z2,q2 are_collinear by A78,A81,A86,Def8;
        q1,q2,q1 are_collinear by Def7;
        then
A88:    x,z2,q1 are_collinear by A78,A81,A86,Def8;
        assume x<>z2;
        then q1,q2,x2 are_collinear by A85,A88,A87,Def8;
        hence
        ex x2,x1 st y1,y2,x1 are_collinear & q1,q2,x2 are_collinear & q3,x1
        ,x2 are_collinear by A80,A84;
      end;
      now
A89:    q,x,q3 are_collinear & q,x,x are_collinear by A79,Def7,Th24;
        assume
A90:    x=z2;
        then q,x,z1 are_collinear by A82,Th24;
        then q3,z1,z2 are_collinear by A77,A78,A90,A89,Def8;
        hence
        ex x2,x1 st y1,y2,x1 are_collinear & q1,q2,x2 are_collinear & q3,x1
        ,x2 are_collinear by A80,A81;
      end;
      hence ex x2,x1 st y1,y2,x1 are_collinear & q1,q2,x2 are_collinear &
q3,x1,
      x2 are_collinear by A83;
    end;
    hence thesis;
  end;
A91: for q,p holds ((for q1,q2 holds P[q,q1,q2]) implies ex p1,p2 st P[p,p1
  ,p2] & not p1,p2,p are_collinear )
  proof
    let q,p such that
A92: for q1,q2 holds P[q,q1,q2];
    consider x1 such that
A93: p<>x1 and
A94: q<>x1 and
A95: p,q,x1 are_collinear by A2;
    consider x2 such that
A96: not p,x1,x2 are_collinear by A1,A93,COLLSP:12;
A97: not x1,x2,q are_collinear
    proof
      assume not thesis;
      then
A98:  q,x1,x2 are_collinear by Th24;
      q,x1,x1 are_collinear & q,x1,p are_collinear by A95,Def7,Th24;
      hence contradiction by A94,A96,A98,Def8;
    end;
A99: x1,x2,x1 are_collinear by Def7;
A100: not x1,x2,p are_collinear by A96,Th24;
A101: P[q,x1,x2] by A92;
    q,p,x1 are_collinear by A95,Th24;
    then P[p,x1,x2] by A75,A97,A99,A101;
    hence thesis by A100;
  end;
A102: for x,y1,z holds P[x,y1,z]
  proof
    let x,y1,z;
    not q1,q2,p are_collinear by A73,Th24;
    then for p1,p2 holds P[p,p1,p2] by A74,A70;
    then ex r1,r2 st P[x,r1,r2] & not r1,r2,x are_collinear by A91;
    hence thesis by A70;
  end;
  for p4,p1,q,q4,r2 ex r,r1 st p4,q,r are_collinear & p1,q4,r1
  are_collinear & r2,r,r1 are_collinear
  proof
    let p4,p1,q,q4,r2;
    ex r1,r st p4,q,r are_collinear & p1,q4,r1 are_collinear & r2,r,r1
    are_collinear by A102;
    hence thesis;
  end;
  hence thesis;
end;
