Shared2 Mobius 2 Inversions.sagewsOpen in CoCalc
Mobius Inversions
from sage.combinat.posets.posets import FinitePoset

def leq(p,q):#leq for points in R^2
if p[0]<=q[0] and p[1]<=q[1]:
return True
return False

def less(p,q):#strictly less than for points in R^2
if p[0]<q[0] and p[1]<q[1]:
return true
return False

def isDgm(T):#T is a tuple containing two tuples of points, the 0th being the tuple of minimal points and the 1st being the tuple of maximal points
if len(T[0])==0 or len(T[1])==0:
return False
if all(any(less(p,q) for q in T[1]) for p in T[0]) and all(any(less(p,q) for p in T[0]) for q in T[1]):
return True
return False

def S(k):
return Poset(([(x,y) for x in range(k) for y in range(k)],leq))

def leq_Dgm(A,B):
if all(any(less(a,b) for b in B) for a in A) and all(any(less(a,b) for a in A) for b in B):
return True
return False

def Antichains(k):
return [tuple(A) for A in S(k).antichains() if len(A)>=1]

def anti(k):
return Poset((Antichains(k),leq_Dgm))

def Dgm(k):
return anti(k).incidence_algebra(ZZ)

Dgm(4).moebius()

I[((0, 0),), ((0, 0),)] - I[((0, 0),), ((1, 1),)] - I[((0, 0),), ((1, 2),)] - I[((0, 0),), ((1, 2), (2, 1))] - I[((0, 0),), ((1, 2), (3, 1))] - I[((0, 0),), ((1, 3),)] - I[((0, 0),), ((1, 3), (2, 1))] - I[((0, 0),), ((1, 3), (2, 2))] - I[((0, 0),), ((1, 3), (2, 2), (3, 1))] - I[((0, 0),), ((1, 3), (3, 1))] - I[((0, 0),), ((1, 3), (3, 2))] - I[((0, 0),), ((2, 1),)] - I[((0, 0),), ((2, 2), (3, 1))] + I[((0, 0),), ((2, 3),)] - I[((0, 0),), ((2, 3), (3, 1))] + I[((0, 0),), ((2, 3), (3, 2))] - I[((0, 0),), ((3, 1),)] + I[((0, 0),), ((3, 2),)] + 3*I[((0, 0),), ((3, 3),)] + I[((0, 1),), ((0, 1),)] - I[((0, 1),), ((1, 2),)] - I[((0, 1),), ((1, 3),)] - I[((0, 1),), ((1, 3), (2, 2))] - I[((0, 1),), ((1, 3), (3, 2))] - I[((0, 1),), ((2, 2),)] - I[((0, 1),), ((2, 3), (3, 2))] - I[((0, 1),), ((3, 2),)] + I[((0, 1),), ((3, 3),)] + I[((0, 1), (1, 0)), ((0, 1), (1, 0))] - I[((0, 1), (1, 0)), ((1, 2), (2, 1))] - I[((0, 1), (1, 0)), ((1, 2), (3, 1))] - I[((0, 1), (1, 0)), ((1, 3), (2, 1))] - I[((0, 1), (1, 0)), ((1, 3), (2, 2))] - I[((0, 1), (1, 0)), ((1, 3), (2, 2), (3, 1))] - I[((0, 1), (1, 0)), ((1, 3), (3, 1))] - I[((0, 1), (1, 0)), ((1, 3), (3, 2))] - I[((0, 1), (1, 0)), ((2, 2),)] - I[((0, 1), (1, 0)), ((2, 2), (3, 1))] - I[((0, 1), (1, 0)), ((2, 3),)] - I[((0, 1), (1, 0)), ((2, 3), (3, 1))] - I[((0, 1), (1, 0)), ((3, 2),)] + I[((0, 1), (1, 0)), ((3, 3),)] + I[((0, 1), (2, 0)), ((0, 1), (2, 0))] - I[((0, 1), (2, 0)), ((1, 2), (3, 1))] - I[((0, 1), (2, 0)), ((1, 3), (2, 2), (3, 1))] - I[((0, 1), (2, 0)), ((1, 3), (3, 1))] - I[((0, 1), (2, 0)), ((1, 3), (3, 2))] - I[((0, 1), (2, 0)), ((2, 2), (3, 1))] - I[((0, 1), (2, 0)), ((2, 3), (3, 1))] - I[((0, 1), (2, 0)), ((2, 3), (3, 2))] - I[((0, 1), (2, 0)), ((3, 2),)] - I[((0, 1), (2, 0)), ((3, 3),)] + I[((0, 1), (3, 0)), ((0, 1), (3, 0))] + I[((0, 2),), ((0, 2),)] - I[((0, 2),), ((1, 3),)] - I[((0, 2),), ((2, 3),)] - I[((0, 2),), ((3, 3),)] + I[((0, 2), (1, 0)), ((0, 2), (1, 0))] - I[((0, 2), (1, 0)), ((1, 3), (2, 1))] - I[((0, 2), (1, 0)), ((1, 3), (2, 2))] - I[((0, 2), (1, 0)), ((1, 3), (2, 2), (3, 1))] - I[((0, 2), (1, 0)), ((1, 3), (3, 1))] - I[((0, 2), (1, 0)), ((1, 3), (3, 2))] - I[((0, 2), (1, 0)), ((2, 3),)] - I[((0, 2), (1, 0)), ((2, 3), (3, 1))] - I[((0, 2), (1, 0)), ((2, 3), (3, 2))] - I[((0, 2), (1, 0)), ((3, 3),)] + I[((0, 2), (1, 1)), ((0, 2), (1, 1))] - I[((0, 2), (1, 1)), ((1, 3), (2, 2))] - I[((0, 2), (1, 1)), ((1, 3), (3, 2))] - I[((0, 2), (1, 1)), ((2, 3),)] - I[((0, 2), (1, 1)), ((2, 3), (3, 2))] - I[((0, 2), (1, 1)), ((3, 3),)] + I[((0, 2), (1, 1), (2, 0)), ((0, 2), (1, 1), (2, 0))] - I[((0, 2), (1, 1), (2, 0)), ((1, 3), (2, 2), (3, 1))] - I[((0, 2), (1, 1), (2, 0)), ((1, 3), (3, 2))] - I[((0, 2), (1, 1), (2, 0)), ((2, 3), (3, 1))] - I[((0, 2), (1, 1), (2, 0)), ((2, 3), (3, 2))] - I[((0, 2), (1, 1), (2, 0)), ((3, 3),)] + I[((0, 2), (1, 1), (3, 0)), ((0, 2), (1, 1), (3, 0))] + I[((0, 2), (2, 0)), ((0, 2), (2, 0))] - I[((0, 2), (2, 0)), ((1, 3), (3, 1))] - I[((0, 2), (2, 0)), ((1, 3), (3, 2))] - I[((0, 2), (2, 0)), ((2, 3), (3, 1))] - I[((0, 2), (2, 0)), ((2, 3), (3, 2))] - I[((0, 2), (2, 0)), ((3, 3),)] + I[((0, 2), (2, 1)), ((0, 2), (2, 1))] - I[((0, 2), (2, 1)), ((1, 3), (3, 2))] - I[((0, 2), (2, 1)), ((2, 3), (3, 2))] - I[((0, 2), (2, 1)), ((3, 3),)] + I[((0, 2), (2, 1), (3, 0)), ((0, 2), (2, 1), (3, 0))] + I[((0, 2), (3, 0)), ((0, 2), (3, 0))] + I[((0, 2), (3, 1)), ((0, 2), (3, 1))] + I[((0, 3),), ((0, 3),)] + I[((0, 3), (1, 0)), ((0, 3), (1, 0))] + I[((0, 3), (1, 1)), ((0, 3), (1, 1))] + I[((0, 3), (1, 1), (2, 0)), ((0, 3), (1, 1), (2, 0))] + I[((0, 3), (1, 1), (3, 0)), ((0, 3), (1, 1), (3, 0))] + I[((0, 3), (1, 2)), ((0, 3), (1, 2))] + I[((0, 3), (1, 2), (2, 0)), ((0, 3), (1, 2), (2, 0))] + I[((0, 3), (1, 2), (2, 1)), ((0, 3), (1, 2), (2, 1))] + I[((0, 3), (1, 2), (2, 1), (3, 0)), ((0, 3), (1, 2), (2, 1), (3, 0))] + I[((0, 3), (1, 2), (3, 0)), ((0, 3), (1, 2), (3, 0))] + I[((0, 3), (1, 2), (3, 1)), ((0, 3), (1, 2), (3, 1))] + I[((0, 3), (2, 0)), ((0, 3), (2, 0))] + I[((0, 3), (2, 1)), ((0, 3), (2, 1))] + I[((0, 3), (2, 1), (3, 0)), ((0, 3), (2, 1), (3, 0))] + I[((0, 3), (2, 2)), ((0, 3), (2, 2))] + I[((0, 3), (2, 2), (3, 0)), ((0, 3), (2, 2), (3, 0))] + I[((0, 3), (2, 2), (3, 1)), ((0, 3), (2, 2), (3, 1))] + I[((0, 3), (3, 0)), ((0, 3), (3, 0))] + I[((0, 3), (3, 1)), ((0, 3), (3, 1))] + I[((0, 3), (3, 2)), ((0, 3), (3, 2))] + I[((1, 0),), ((1, 0),)] - I[((1, 0),), ((2, 1),)] - I[((1, 0),), ((2, 2),)] - I[((1, 0),), ((2, 2), (3, 1))] - I[((1, 0),), ((2, 3),)] - I[((1, 0),), ((2, 3), (3, 1))] - I[((1, 0),), ((2, 3), (3, 2))] - I[((1, 0),), ((3, 1),)] + I[((1, 0),), ((3, 3),)] + I[((1, 1),), ((1, 1),)] - I[((1, 1),), ((2, 2),)] - I[((1, 1),), ((2, 3),)] - I[((1, 1),), ((2, 3), (3, 2))] - I[((1, 1),), ((3, 2),)] + I[((1, 1), (2, 0)), ((1, 1), (2, 0))] - I[((1, 1), (2, 0)), ((2, 2), (3, 1))] - I[((1, 1), (2, 0)), ((2, 3), (3, 1))] - I[((1, 1), (2, 0)), ((2, 3), (3, 2))] - I[((1, 1), (2, 0)), ((3, 2),)] - I[((1, 1), (2, 0)), ((3, 3),)] + I[((1, 1), (3, 0)), ((1, 1), (3, 0))] + I[((1, 2),), ((1, 2),)] - I[((1, 2),), ((2, 3),)] - I[((1, 2),), ((3, 3),)] + I[((1, 2), (2, 0)), ((1, 2), (2, 0))] - I[((1, 2), (2, 0)), ((2, 3), (3, 1))] - I[((1, 2), (2, 0)), ((2, 3), (3, 2))] - I[((1, 2), (2, 0)), ((3, 3),)] + I[((1, 2), (2, 1)), ((1, 2), (2, 1))] - I[((1, 2), (2, 1)), ((2, 3), (3, 2))] - I[((1, 2), (2, 1)), ((3, 3),)] + I[((1, 2), (2, 1), (3, 0)), ((1, 2), (2, 1), (3, 0))] + I[((1, 2), (3, 0)), ((1, 2), (3, 0))] + I[((1, 2), (3, 1)), ((1, 2), (3, 1))] + I[((1, 3),), ((1, 3),)] + I[((1, 3), (2, 0)), ((1, 3), (2, 0))] + I[((1, 3), (2, 1)), ((1, 3), (2, 1))] + I[((1, 3), (2, 1), (3, 0)), ((1, 3), (2, 1), (3, 0))] + I[((1, 3), (2, 2)), ((1, 3), (2, 2))] + I[((1, 3), (2, 2), (3, 0)), ((1, 3), (2, 2), (3, 0))] + I[((1, 3), (2, 2), (3, 1)), ((1, 3), (2, 2), (3, 1))] + I[((1, 3), (3, 0)), ((1, 3), (3, 0))] + I[((1, 3), (3, 1)), ((1, 3), (3, 1))] + I[((1, 3), (3, 2)), ((1, 3), (3, 2))] + I[((2, 0),), ((2, 0),)] - I[((2, 0),), ((3, 1),)] - I[((2, 0),), ((3, 2),)] - I[((2, 0),), ((3, 3),)] + I[((2, 1),), ((2, 1),)] - I[((2, 1),), ((3, 2),)] - I[((2, 1),), ((3, 3),)] + I[((2, 1), (3, 0)), ((2, 1), (3, 0))] + I[((2, 2),), ((2, 2),)] - I[((2, 2),), ((3, 3),)] + I[((2, 2), (3, 0)), ((2, 2), (3, 0))] + I[((2, 2), (3, 1)), ((2, 2), (3, 1))] + I[((2, 3),), ((2, 3),)] + I[((2, 3), (3, 0)), ((2, 3), (3, 0))] + I[((2, 3), (3, 1)), ((2, 3), (3, 1))] + I[((2, 3), (3, 2)), ((2, 3), (3, 2))] + I[((3, 0),), ((3, 0),)] + I[((3, 1),), ((3, 1),)] + I[((3, 2),), ((3, 2),)] + I[((3, 3),), ((3, 3),)]