TITLE: How to triangulate real projective spaces (as simplicial complexes in Mathematica)?
QUESTION [8 upvotes]: Hello!
I have written a program in Mathematica 7, which calculates for a (finite abstract) simplicial complex all its homology groups. I would really like to test it on the projective spaces, but cannot find a way to triangulate them. There seem to be very few articles on this matter and none of them states directly how the actual triangulations might be achieved, so I turn to MO for help.
How can the real projective spaces
$$RP^n \approx B^n/_{x\:\sim-x;\;\; x\in\partial B^n}$$
be triangulated as simplicial complexes? A simplicial complex is presented as a list of simplices that aren't a face of any bigger simplex (the "main simplices"). Each k-simplex is just an ordered list of some k+1 integers. 
For example, {0,1,2} is a 2-simplex, as is {1,3,15}, etc. Examples of simplicial complexes: {{0,...,n}} is a n-dimensional ball, {{1,2},{1,3},{2,3}} is an empty triangle, skeleton[{Range[n+2]},n] is a n-sphere, etc.
I have already found a concrete triangulation for the real projective plane, but nothing more general.
It would also be appreciated, that the actual triangulation is reasonably small (not necessarily minimal), so that the program calculates homology groups fast enough. Also, answers in code / pseudocode are much desirable (projectiveSpace[n_]:=???).
P.S. I have already written some functions, which can be used (sc...simplicial complex):

skeleton[sc,k] ...list of all k-faces of all simplices
sum[sc1,sc2]...topological sum (disjoint union)
connected sum[sc1,sc2] ...removes two k-simplicices and adds a tunnel between them
product[sc1,sc2]...staircase triangulation of a product (reorders the vertices)
cone[sc]
suspension[sc]

REPLY [2 votes]: I've managed to find my mistake and here is the final (if I'm not mistaken) correct solution.
ClearAll[faces, skeleton, subseteq, subset, sBarycentricSubdivision, \
scBarycentricSubdivision, sphere, projectiveSpace]
faces[s_, k_] := Reverse@Subsets[s, {k + 1}]
skeleton[sc_, k_] := Union[Sort /@ Flatten[faces[#, k] & /@ sc, 1]]

subseteq[{},A_List] := True
subseteq[{x_,y___}, A_List] := MemberQ[A, x] && subset[{y}, A]
subseteq[A_List,B_List, C__List] := subset[A,B] && subset[B,C]
subset[A_List, B_List] := subseteq[A, B] && Complement[B, A]!={}
subset[A_List, B_List, C__List] := subset[A, B] && subset[B, C]

sBarycentricSubdivision[{x_Integer}] := {{{x}}}
sBarycentricSubdivision[s_List] := 
 Subsets[s, {1, Length@s}] //Subsets[#,{Length@s}]& //
  Select[#,subset@@#&]& 
scBarycentricSubdivision[sc_List] := 
 Flatten[sBarycentricSubdivision /@ sc, 1]

sphere[n_Integer]  := skeleton[{Range[n+2]},n]

projectiveSpace[n_Integer] := Module[
  {sc1, vertices1, k, identification, sc2, vertices2, sc3},
  sc1 = scBarycentricSubdivision[sphere[n]];
  vertices1 = 
   Sort@DeleteDuplicates@
     Flatten[sc1, 
      1]; (*the vertices (lists) are ordered antipodally with respect \
to complement, ie. vertices1[i]={1,...,n+2}-vertices1[-i]*)
  k = Length@vertices1;
  identification = 
   Table[vertices1[[-i]] -> vertices1[[i]], {i, 1, k/2}];
  sc2 = DeleteDuplicates[Sort /@ (sc1/.identification)];
  vertices2 = Flatten[sc2, 1] //Sort //DeleteDuplicates;
  sc3 = Map[Position[vertices2, #][[1, 1]] &, sc2, {2}] //Sort //
    DeleteDuplicates;
  sc3
  ]

And now, the command projectiveSpace[2] indeed returns a triangulation of the projective plane with 7 vertices and 12 faces. Also, the homology groups of $RP^0$,..., $RP^3$ all seem to be correct.
Thank you, mr. Palmieri, greetings from Slovenia.