Skip to content

Mixin

IsSubsetEqMixin

Bases: BoundedLattice[BoundedLatticeType]

A special mixin for lattices that provides a default implementation for is_subseteq by using the visitor pattern. This is useful if the lattice has a lot of different subclasses that need to be compared.

Must be used before BoundedLattice in the inheritance chain.

is_subseteq

is_subseteq(other: BoundedLatticeType) -> bool

Subseteq operation.

Source code in src/kirin/lattice/mixin.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def is_subseteq(self, other: BoundedLatticeType) -> bool:
    if other is self.top():
        return True
    elif other is self.bottom():
        return False

    method = getattr(
        self,
        "is_subseteq_" + other.__class__.__name__,
        getattr(self, "is_subseteq_fallback", None),
    )
    if method is not None:
        return method(other)
    return False

SimpleJoinMixin

Bases: BoundedLattice[BoundedLatticeType]

A mixin that provides a simple implementation for the join operation.

join

join(other: BoundedLatticeType) -> BoundedLatticeType

Join operation.

Source code in src/kirin/lattice/mixin.py
35
36
37
38
39
40
def join(self, other: BoundedLatticeType) -> BoundedLatticeType:
    if self.is_subseteq(other):
        return other
    elif other.is_subseteq(self):
        return self  # type: ignore
    return self.top()

SimpleMeetMixin

Bases: BoundedLattice[BoundedLatticeType]

A mixin that provides a simple implementation for the meet operation.

meet

meet(other: BoundedLatticeType) -> BoundedLatticeType

Meet operation.

Source code in src/kirin/lattice/mixin.py
46
47
48
49
50
51
def meet(self, other: BoundedLatticeType) -> BoundedLatticeType:
    if self.is_subseteq(other):
        return self  # type: ignore
    elif other.is_subseteq(self):
        return other
    return self.bottom()