Skip to content

Commit d9c7bba

Browse files
committed
initial shape lattice
1 parent af839c0 commit d9c7bba

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

src/bloqade/squin/analysis/shape/__init__.py

Whitespace-only changes.

src/bloqade/squin/analysis/shape/impls.py

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from typing import final
2+
from dataclasses import dataclass
3+
4+
from kirin.lattice import (
5+
SingletonMeta,
6+
BoundedLattice,
7+
SimpleJoinMixin,
8+
SimpleMeetMixin,
9+
)
10+
11+
12+
@dataclass
13+
class Shape(
14+
SimpleJoinMixin["Shape"], SimpleMeetMixin["Shape"], BoundedLattice["Shape"]
15+
):
16+
@classmethod
17+
def bottom(cls) -> "Shape":
18+
return NoShape()
19+
20+
@classmethod
21+
def top(cls) -> "Shape":
22+
return AnyShape()
23+
24+
25+
@final
26+
@dataclass
27+
class NoShape(Shape, metaclass=SingletonMeta):
28+
29+
def is_subseteq(self, other: Shape) -> bool:
30+
return True
31+
32+
33+
@final
34+
@dataclass
35+
class AnyShape(Shape, metaclass=SingletonMeta):
36+
37+
def is_subseteq(self, other: Shape) -> bool:
38+
return isinstance(other, Shape)
39+
40+
41+
@final
42+
@dataclass
43+
class OpShape(Shape):
44+
size: int
45+
46+
def is_subseteq(self, other: Shape) -> bool:
47+
if isinstance(other, OpShape):
48+
return self.size == other.size
49+
return False

0 commit comments

Comments
 (0)