/*
"Reflexive polytopes of higher index and the number 12",
Alexander M Kasprzyk and Benjamin Nill
---------------------------------------------------------
The following basic Magma code can be used to regenerate
the classification of l-reflexive polygons.
*/

// Returns true iff P is l-reflexive for some index l. Also returns l.
function is_l_reflexive(P)
    if not IsFano(P) then return false,_; end if;
    l:=GorensteinIndex(P);
    if &and[Denominator(v) eq l : v in Vertices(Dual(P))] then
        return true,l;
    else
        return false,_;
    end if;
end function;

// Compute all non-isomorphic l-reflexive polygons generated by
// the Hermite normal forms with determinant l.
procedure generate_polys(l,~polys)
    if l eq 1 then
        polys[1]:=[PolytopeReflexiveFanoDim2(id) : id in [1..16]];
        return;
    end if;
    polys[l]:=[];
    Hs:=[Matrix(2,2,[l, i, 0, 1]) : i in [1..l-1] | GCD(l,i) eq 1];
    for id in [1..16] do
        P:=PolytopeReflexiveFanoDim2(id);
        for H in Hs do
            Q:=P * H;
            bool,k:=is_l_reflexive(Q);
            if bool and not &or[IsIsomorphic(Q,R) : R in polys[k]] then
                Append(~polys[k],Q);
            end if;
        end for;
    end for;
end procedure;

// The main loop (runs from index 1 to 29, takes approx. 1 minute)
polys:=AssociativeArray(Integers());
for l in [1..29 by 2] do generate_polys(l,~polys); end for;