> restart; #Computation in the Fano plane > # The program contains some parts, called "tests". Running > # these parts can increase your trust in the program. > # To run these parts, delete the hash marks (#) from them. > > # PART 1: ENTERING THE DESCRIPTION OF THE FANO PLANE > > pnam:=array(1..7): #The names of the points in the paper > pnam[1]:="a1": pnam[2]:="a2": pnam[3]:="a3": > pnam[4]:="b1": pnam[5]:="b2": pnam[6]:="b3": > pnam[7]:="c": > lnam:=array(8..14): #Lines names in the paper; > lnam[8]:="u1": lnam[9]:="u2": > lnam[10]:="u3": lnam[11]:="v1": > lnam[12]:="v2": lnam[13]:="v3": lnam[14]:="w": > line:=array(8..14): #The lines in the paper > line[7+1]:={2,3,3+1}: line[7+2]:={1,3,3+2}: > line[7+3]:={1,2,3+3}: line[7+3+1]:={1,3+1,7}: > line[7+3+2]:={2,3+2,7}:line[7+3+3]:={3,3+3,7}: > line[7+7]:={3+1,3+2,3+3}: #Each line is a set of points; > #the program treats the points numbers while computing > #but uses their names, stored in pnam, when printing. > L:=array(0..15): #The subspace lattice of the Fano plane > for i from 1 to 7 do L[i]:={i} od:# > for i from 8 to 14 do L[i]:=line[i] od: L[0]:={}: L[15]:={}: > for i from 1 to 7 do L[15]:=L[15] union {i} od:# > lnotat:=array(0..15): > #The notations of the subspaces in the paper > #like "0", "a1", "u2", or "1". > lnotat[0]:="0":lnotat[15]:="1": > for i from 1 to 7 do lnotat[i]:=pnam[i] od: > for i from 8 to 14 do lnotat[i]:=lnam[i] od: > leq:=proc(x,y) local r; #Describing the order > if x=x intersect y then r:=1 else r:=0 fi > end:# > SetToName:=proc(x) local i,r; #Name: what the paper uses > #E.g., SetToName=({2,4,3}) = "u1" > r:="Non-recognizable": > for i from 0 to 15 do if x=L[i] then r:=lnotat[i] fi > od: r:=r: > end: #End of SetToName > SetToStr:=proc(x) > #E.g., SetToStr({2,3,4})="{a2,a3,b1}" > local i,r,needscomma; > r:="{": needscomma:=0: > for i from 1 to 7 do > if leq(L[i],x)=1 then > if needscomma=1 then r:=cat(r,",",lnotat[i]) > else r:=cat(r,lnotat[i]): needscomma:=1 > fi: > fi: > od: #end of "for i" loop > r:=cat(r,"}"): > end: #End of procedure SetToStr > > # PART 2: LISTING THE DETAILS OF THE FANO PLANE > > lstr:=array(0..15):#The subspaces in string forms > # like "u1={a2,a2,b1}", "a1={a1}", or "0={}" > for i from 0 to 15 do > lstr[i]:=cat(lnotat[i],"=",SetToStr(L[i])) > od: #end of the "for i" loop print("The details of the subspace lattice L"): print(" of the Fano plane are as follows:"): for i from 0 to 15 do print(cat(lstr[i], " (stored in L(",i,")")) od: "The details of the subspace lattice L" " of the Fano plane are as follows:" "0={} (stored in L(0)" "a1={a1} (stored in L(1)" "a2={a2} (stored in L(2)" "a3={a3} (stored in L(3)" "b1={b1} (stored in L(4)" "b2={b2} (stored in L(5)" "b3={b3} (stored in L(6)" "c={c} (stored in L(7)" "u1={a2,a3,b1} (stored in L(8)" "u2={a1,a3,b2} (stored in L(9)" "u3={a1,a2,b3} (stored in L(10)" "v1={a1,b1,c} (stored in L(11)" "v2={a2,b2,c} (stored in L(12)" "v3={a3,b3,c} (stored in L(13)" "w={b1,b2,b3} (stored in L(14)" "1={a1,a2,a3,b1,b2,b3,c} (stored in L(15)" > # > # PART 3: COMPUTING THE JOIN IN L > # > which:=proc(x) local i,r; # x is subspace > r:=-1; for i from 0 to 15 do if x=L[i] then r:=i fi od; > # if r=-1 then print(" !!! -1 means: NOT IN L !!!"): fi: > r:=r; > end: #And now a few tests with "which": > #The built-in operation "intersect" is good for meet. > join:=proc(x,y) local z,i,r: > z:=L[15]: #The top element > for i from 0 to 14 do > if (leq(x,L[i])=1) and (leq(y,L[i])=1) > then z:=z intersect L[i] > fi > od: #End of the "for i" loop > r:=z: > end: #End of procedure join > > # Test: in the next two lines, we test some joins in L: > #a:={1}:b:={2,4,3}: c:=join(a,b); print(cat > #(SetToName(a)," join ",SetToName(b),"=",SetToName(c))): > > > # PART 4: SEARCH IN S > > S:=array(1..257,1..2):#The sublattice to be generated > Ssize:=0: #At present, S is the emptyset > whereInS:=proc(x,y) local r,i: > #Finds an element of L^2 in S > r:=-1: > for i from 1 to Ssize do > if (x=S[i,1]) and (y=S[i,2]) then r:=i > fi: > od: r:=r: > end: #End of procedure whereInS; it will be tested later. > > # PART 5: COMPUTING WHAT S GENERATES > > generating:=proc() local i,j,z1,z2,m1,m2,found,oldSize; > global S,Ssize; > #Computes what (S[1,1],S[1,2]), ... , > # (S[Ssize,1],S[Size,2]) generates, puts it into S, > # and increases Ssize > found:=true: > while found=true > do found:=false: oldSize:=Ssize: > for i from 1 to oldSize-1 > do for j from i+1 to oldSize > do z1:=join(S[i,1],S[j,1]): z2:=join(S[i,2],S[j,2]): > m1:=S[i,1] intersect S[j,1]: > m2:=S[i,2] intersect S[j,2]: > if whereInS(z1,z2)=-1 then > found:=true: Ssize:=Ssize+1: > S[Ssize,1]:=z1: S[Ssize,2]:=z2: > fi: # New join added > if whereInS(m1,m2)=-1 then > found:=true: Ssize:=Ssize+1: > S[Ssize,1]:=m1: S[Ssize,2]:=m2: > fi: # New meet added > od: # for j > od: # for i > od: #while found; now S is the sublattice generated. > end: #End of procedure generating; > #it will be tested later, after initialization > > # PART 6: CONVERTING A ROW OF S TO TEXT > > Sname:=proc(i) local i1,i2,r:#E.g, Sname(1)="(a1,a1)" > i1:=which(S[i,1]); i2:=which(S[i,2]); > if (i1=-1) or (i2=-1) > then print("Something is wrong here"): r:="" > else r:=cat("(",lnotat[i1],",",lnotat[i2],")") > fi: r:=r: > end: #End of proceture Sname, to be tested later. > # > #Test: FIRST TEST (OPTIONAL) > > #Testing what 3 points on a line and a further point > #generate; and testing Sname and whereInS, too. > #for i from 1 to 4 do S[i,1]:=L[i]: S[i,2]:=L[i]: > #od: Ssize:=4: print(cat("The subset of L^2:")): > #for i from 1 to Ssize do print(Sname(i)) od: > #generating(): > #print(cat("generates the following ", > # Ssize,"-element sublattice:")); > #for i from 1 to Ssize do print(Sname(i)) od: > #print("(A whereInS-test:"): > #print(cat(Sname(L[8]),"=",L[8]," it is the ", > # whereInS(L[8],L[8]),"-th" )): > > #Test: SECOND TEST (OPTIONAL) > #Testing what 4 points in general position generate > #for i from 1 to 3 do S[i,1]:=L[i]: S[i,2]:=L[i]: > #od: S[4,1]:=L[7]: S[4,2]:=L[7]: Ssize:=4: generating(): > #print(cat("The following ",Ssize, > # "-element sublattice is generated", > # " by its first four elements:")); > #for i from 1 to Ssize do print(Sname(i)) od: > > # PART 7: THE MAIN COMPUTATION > # > for i from 1 to 3 do S[i,1]:=L[i]: S[i,2]:=L[i]: > od: S[4,1]:=L[7]: S[4,2]:=L[14]: Ssize:=4: > print("The following 4 elements of L^2:"): > txt:=Sname(1):for i from 2 to Ssize do > txt:=cat(txt,", ", Sname(i)) od: print(txt): > generating():print("generate a ", > Ssize,"-element sublattice,"): txt:="": > print("which consists of the following elements:"): > for i from 1 by 5 to Ssize do txt:="": > for j from 0 to 4 do > if i+j fi: > if i+j=Ssize then txt:=cat(txt,Sname(i+j),"."): > fi > od: print(txt): > od: > a1:=lnotat[15]: a2:=lnotat[0]: > print(cat("The position of (", a1, ",", a2, > ") is ",whereInS(L[15],L[0]))): > print("(-1 means that not found)"): "The following 4 elements of L^2:" "(a1,a1), (a2,a2), (a3,a3), (c,w)" "generate a ", 50, "-element sublattice," "which consists of the following elements:" "(a1,a1), (a2,a2), (a3,a3), (c,w), (u3,u3), " "(0,0), (u2,u2), (v1,1), (u1,u1), (v2,1), " "(v3,1), (1,1), (0,a1), (0,a2), (0,a3), " "(0,b3), (0,b2), (0,b1), (a1,u3), (a2,u3), " "(b3,u3), (a1,u2), (b2,u2), (a3,u2), (b1,u1), " "(c,1), (a2,u1), (a3,u1), (a1,v1), (u3,1), " "(u2,1), (a2,v2), (u1,1), (a3,v3), (0,u3), " "(0,u2), (0,u1), (0,v1), (b1,1), (a2,1), " "(a3,1), (0,v2), (a1,1), (b2,1), (0,v3), " "(b3,1), (0,w), (w,1), (0,1), (0,c)." "The position of (1,0) is -1" "(-1 means that not found)" >