function Apartment (cg,r) return Apartment (cg,r,true); end function; function Apartment (cg,r,stopAfterFound) ok := false; wok := false; G := Group (cg); cardG := #G; rankCG := Rank(cg); if (rankCG eq r) then B := Borel (cg); d,v,e := Diagram (cg); M := MaximalParabolics (cg); coxMat := [[0 : i in [1..rankCG]] : j in [1..rankCG] ]; for i := 1 to rankCG do for j := 1 to rankCG do if i ne j then lab := Label (e!{i,j}); coxMat[i,j] := lab[2]; end if; end for; end for; l := SubgroupLattice (B); for i := 1 to #l do Bi := Group(l!i); Q := Normalizer (G, Bi); lQ := SubgroupLattice (Q); for j := 1 to #lQ do N1 := Group (lQ!j); NN := Normalizer (G,N1); t := Transversal (G,NN); for k in t do N := N1^k; subcg := CosetGeometry(N,{@N meet x : x in M@}); rankSubCG := Rank(subcg); if (N meet B eq Bi and rankSubCG eq rankCG and IsThin(subcg) and IsFTGeometry(subcg) and IsRC(subcg)) then dd,vv,ee := Diagram(subcg); coxMat2 := [[0 : i in [1..rankSubCG]]:j in [1..rankSubCG]]; for k1 := 1 to rankSubCG do for k2 := 1 to rankSubCG do if k1 ne k2 then lab := Label(ee!{k1,k2}); coxMat2[k1,k2] := lab[2]; end if; end for; end for; if coxMat eq coxMat2 then wok := true; if (#sub eq cardG) then if (stopAfterFound) then return true, true, N; else print N; end if; end if; end if; end if; end for; end for; end for; else t := Types(cg); for x in Subsets(Set(t),#t-r) do ok,wok,N := Apartment(Residue(cg,x),r,true); if not(ok) then return ok,wok,N; end if; end for; end if; return ok,wok,G; end function; function ApartmentRes(cg) t:=Types(cg); r:=#t; for k:=2 to r do for x in Subsets(Set(t),r-k) do if not Apartment(Residue(cg,x),k,true) then return false; end if; end for; end for; return true; end function;