egglog 0.4.0__pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of egglog might be problematic. Click here for more details.
- egglog/__init__.py +5 -0
- egglog/bindings.pyi +415 -0
- egglog/bindings.pypy310-pp73-x86_64-linux-gnu.so +0 -0
- egglog/builtins.py +345 -0
- egglog/config.py +8 -0
- egglog/declarations.py +934 -0
- egglog/egraph.py +1041 -0
- egglog/examples/README.rst +5 -0
- egglog/examples/__init__.py +0 -0
- egglog/examples/eqsat_basic.py +43 -0
- egglog/examples/fib.py +28 -0
- egglog/examples/lambda.py +310 -0
- egglog/examples/matrix.py +184 -0
- egglog/examples/ndarrays.py +159 -0
- egglog/examples/resolution.py +84 -0
- egglog/examples/schedule_demo.py +33 -0
- egglog/ipython_magic.py +40 -0
- egglog/monkeypatch.py +33 -0
- egglog/py.typed +0 -0
- egglog/runtime.py +304 -0
- egglog/type_constraint_solver.py +79 -0
- egglog-0.4.0.dist-info/METADATA +53 -0
- egglog-0.4.0.dist-info/RECORD +25 -0
- egglog-0.4.0.dist-info/WHEEL +4 -0
- egglog-0.4.0.dist-info/license_files/LICENSE +21 -0
egglog/builtins.py
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Builtin sorts and function to egg.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Generic, TypeVar, Union
|
|
9
|
+
|
|
10
|
+
from .egraph import BUILTINS, BaseExpr, Unit
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"BUILTINS",
|
|
14
|
+
"i64",
|
|
15
|
+
"i64Like",
|
|
16
|
+
"f64",
|
|
17
|
+
"f64Like",
|
|
18
|
+
"String",
|
|
19
|
+
"StringLike",
|
|
20
|
+
"Map",
|
|
21
|
+
"Rational",
|
|
22
|
+
"Set",
|
|
23
|
+
"Vec",
|
|
24
|
+
"join",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# The types which can be converted into an i64
|
|
29
|
+
i64Like = Union[int, "i64"]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@BUILTINS.class_(egg_sort="i64")
|
|
33
|
+
class i64(BaseExpr):
|
|
34
|
+
def __init__(self, value: int):
|
|
35
|
+
...
|
|
36
|
+
|
|
37
|
+
@BUILTINS.method(egg_fn="+")
|
|
38
|
+
def __add__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
@BUILTINS.method(egg_fn="-")
|
|
42
|
+
def __sub__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
43
|
+
...
|
|
44
|
+
|
|
45
|
+
@BUILTINS.method(egg_fn="*")
|
|
46
|
+
def __mul__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
@BUILTINS.method(egg_fn="/")
|
|
50
|
+
def __truediv__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
51
|
+
...
|
|
52
|
+
|
|
53
|
+
@BUILTINS.method(egg_fn="%")
|
|
54
|
+
def __mod__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
@BUILTINS.method(egg_fn="&")
|
|
58
|
+
def __and__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
@BUILTINS.method(egg_fn="|")
|
|
62
|
+
def __or__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
63
|
+
...
|
|
64
|
+
|
|
65
|
+
@BUILTINS.method(egg_fn="^")
|
|
66
|
+
def __xor__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
67
|
+
...
|
|
68
|
+
|
|
69
|
+
@BUILTINS.method(egg_fn="<<")
|
|
70
|
+
def __lshift__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
71
|
+
...
|
|
72
|
+
|
|
73
|
+
@BUILTINS.method(egg_fn=">>")
|
|
74
|
+
def __rshift__(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
75
|
+
...
|
|
76
|
+
|
|
77
|
+
@BUILTINS.method(egg_fn="not-64")
|
|
78
|
+
def __invert__(self) -> i64: # type: ignore[empty-body]
|
|
79
|
+
...
|
|
80
|
+
|
|
81
|
+
@BUILTINS.method(egg_fn="<")
|
|
82
|
+
def __lt__(self, other: i64Like) -> Unit: # type: ignore[empty-body,has-type]
|
|
83
|
+
...
|
|
84
|
+
|
|
85
|
+
@BUILTINS.method(egg_fn=">")
|
|
86
|
+
def __gt__(self, other: i64Like) -> Unit: # type: ignore[empty-body]
|
|
87
|
+
...
|
|
88
|
+
|
|
89
|
+
@BUILTINS.method(egg_fn="min")
|
|
90
|
+
def min(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
91
|
+
...
|
|
92
|
+
|
|
93
|
+
@BUILTINS.method(egg_fn="max")
|
|
94
|
+
def max(self, other: i64Like) -> i64: # type: ignore[empty-body]
|
|
95
|
+
...
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
f64Like = Union[float, "f64"]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@BUILTINS.class_(egg_sort="f64")
|
|
102
|
+
class f64(BaseExpr):
|
|
103
|
+
def __init__(self, value: float):
|
|
104
|
+
...
|
|
105
|
+
|
|
106
|
+
@BUILTINS.method(egg_fn="+")
|
|
107
|
+
def __add__(self, other: f64Like) -> f64: # type: ignore[empty-body]
|
|
108
|
+
...
|
|
109
|
+
|
|
110
|
+
@BUILTINS.method(egg_fn="-")
|
|
111
|
+
def __sub__(self, other: f64Like) -> f64: # type: ignore[empty-body]
|
|
112
|
+
...
|
|
113
|
+
|
|
114
|
+
@BUILTINS.method(egg_fn="*")
|
|
115
|
+
def __mul__(self, other: f64Like) -> f64: # type: ignore[empty-body]
|
|
116
|
+
...
|
|
117
|
+
|
|
118
|
+
@BUILTINS.method(egg_fn="/")
|
|
119
|
+
def __truediv__(self, other: f64Like) -> f64: # type: ignore[empty-body]
|
|
120
|
+
...
|
|
121
|
+
|
|
122
|
+
@BUILTINS.method(egg_fn="%")
|
|
123
|
+
def __mod__(self, other: f64Like) -> f64: # type: ignore[empty-body]
|
|
124
|
+
...
|
|
125
|
+
|
|
126
|
+
@BUILTINS.method(egg_fn="<")
|
|
127
|
+
def __lt__(self, other: f64Like) -> Unit: # type: ignore[empty-body,has-type]
|
|
128
|
+
...
|
|
129
|
+
|
|
130
|
+
@BUILTINS.method(egg_fn=">")
|
|
131
|
+
def __gt__(self, other: f64Like) -> Unit: # type: ignore[empty-body]
|
|
132
|
+
...
|
|
133
|
+
|
|
134
|
+
@BUILTINS.method(egg_fn="<=")
|
|
135
|
+
def __le__(self, other: f64Like) -> Unit: # type: ignore[empty-body,has-type]
|
|
136
|
+
...
|
|
137
|
+
|
|
138
|
+
@BUILTINS.method(egg_fn=">=")
|
|
139
|
+
def __ge__(self, other: f64Like) -> Unit: # type: ignore[empty-body]
|
|
140
|
+
...
|
|
141
|
+
|
|
142
|
+
@BUILTINS.method(egg_fn="min")
|
|
143
|
+
def min(self, other: f64Like) -> f64: # type: ignore[empty-body]
|
|
144
|
+
...
|
|
145
|
+
|
|
146
|
+
@BUILTINS.method(egg_fn="max")
|
|
147
|
+
def max(self, other: f64Like) -> f64: # type: ignore[empty-body]
|
|
148
|
+
...
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
StringLike = Union[str, "String"]
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@BUILTINS.class_
|
|
155
|
+
class String(BaseExpr):
|
|
156
|
+
def __init__(self, value: str):
|
|
157
|
+
...
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
@BUILTINS.function(egg_fn="+")
|
|
161
|
+
def join(*strings: StringLike) -> String: # type: ignore[empty-body]
|
|
162
|
+
...
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
T = TypeVar("T", bound=BaseExpr)
|
|
166
|
+
V = TypeVar("V", bound=BaseExpr)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@BUILTINS.class_(egg_sort="Map")
|
|
170
|
+
class Map(BaseExpr, Generic[T, V]):
|
|
171
|
+
@BUILTINS.method(egg_fn="map-empty")
|
|
172
|
+
@classmethod
|
|
173
|
+
def empty(cls) -> Map[T, V]: # type: ignore[empty-body]
|
|
174
|
+
...
|
|
175
|
+
|
|
176
|
+
@BUILTINS.method(egg_fn="map-insert")
|
|
177
|
+
def insert(self, key: T, value: V) -> Map[T, V]: # type: ignore[empty-body]
|
|
178
|
+
...
|
|
179
|
+
|
|
180
|
+
@BUILTINS.method(egg_fn="map-get")
|
|
181
|
+
def __getitem__(self, key: T) -> V: # type: ignore[empty-body]
|
|
182
|
+
...
|
|
183
|
+
|
|
184
|
+
@BUILTINS.method(egg_fn="map-not-contains")
|
|
185
|
+
def not_contains(self, key: T) -> Unit: # type: ignore[empty-body]
|
|
186
|
+
...
|
|
187
|
+
|
|
188
|
+
@BUILTINS.method(egg_fn="map-contains")
|
|
189
|
+
def contains(self, key: T) -> Unit: # type: ignore[empty-body]
|
|
190
|
+
...
|
|
191
|
+
|
|
192
|
+
@BUILTINS.method(egg_fn="map-remove")
|
|
193
|
+
def remove(self, key: T) -> Map[T, V]: # type: ignore[empty-body]
|
|
194
|
+
...
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@BUILTINS.class_(egg_sort="Set")
|
|
198
|
+
class Set(BaseExpr, Generic[T]):
|
|
199
|
+
@BUILTINS.method(egg_fn="set-of")
|
|
200
|
+
def __init__(self, *args: T) -> None:
|
|
201
|
+
...
|
|
202
|
+
|
|
203
|
+
@BUILTINS.method(egg_fn="set-empty")
|
|
204
|
+
@classmethod
|
|
205
|
+
def empty(cls) -> Set[T]: # type: ignore[empty-body]
|
|
206
|
+
...
|
|
207
|
+
|
|
208
|
+
@BUILTINS.method(egg_fn="set-insert")
|
|
209
|
+
def insert(self, value: T) -> Set[T]: # type: ignore[empty-body]
|
|
210
|
+
...
|
|
211
|
+
|
|
212
|
+
@BUILTINS.method(egg_fn="set-not-contains")
|
|
213
|
+
def not_contains(self, value: T) -> Unit: # type: ignore[empty-body]
|
|
214
|
+
...
|
|
215
|
+
|
|
216
|
+
@BUILTINS.method(egg_fn="set-contains")
|
|
217
|
+
def contains(self, value: T) -> Unit: # type: ignore[empty-body]
|
|
218
|
+
...
|
|
219
|
+
|
|
220
|
+
@BUILTINS.method(egg_fn="set-remove")
|
|
221
|
+
def remove(self, value: T) -> Set[T]: # type: ignore[empty-body]
|
|
222
|
+
...
|
|
223
|
+
|
|
224
|
+
@BUILTINS.method(egg_fn="set-union")
|
|
225
|
+
def __or__(self, other: Set[T]) -> Set[T]: # type: ignore[empty-body]
|
|
226
|
+
...
|
|
227
|
+
|
|
228
|
+
@BUILTINS.method(egg_fn="set-diff")
|
|
229
|
+
def __sub__(self, other: Set[T]) -> Set[T]: # type: ignore[empty-body]
|
|
230
|
+
...
|
|
231
|
+
|
|
232
|
+
@BUILTINS.method(egg_fn="set-intersect")
|
|
233
|
+
def __and__(self, other: Set[T]) -> Set[T]: # type: ignore[empty-body]
|
|
234
|
+
...
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
@BUILTINS.class_(egg_sort="Rational")
|
|
238
|
+
class Rational(BaseExpr):
|
|
239
|
+
@BUILTINS.method(egg_fn="rational")
|
|
240
|
+
def __init__(self, num: i64Like, den: i64Like):
|
|
241
|
+
...
|
|
242
|
+
|
|
243
|
+
@BUILTINS.method(egg_fn="to-f64")
|
|
244
|
+
def to_f64(self) -> f64: # type: ignore[empty-body]
|
|
245
|
+
...
|
|
246
|
+
|
|
247
|
+
@BUILTINS.method(egg_fn="+")
|
|
248
|
+
def __add__(self, other: Rational) -> Rational: # type: ignore[empty-body]
|
|
249
|
+
...
|
|
250
|
+
|
|
251
|
+
@BUILTINS.method(egg_fn="-")
|
|
252
|
+
def __sub__(self, other: Rational) -> Rational: # type: ignore[empty-body]
|
|
253
|
+
...
|
|
254
|
+
|
|
255
|
+
@BUILTINS.method(egg_fn="*")
|
|
256
|
+
def __mul__(self, other: Rational) -> Rational: # type: ignore[empty-body]
|
|
257
|
+
...
|
|
258
|
+
|
|
259
|
+
@BUILTINS.method(egg_fn="/")
|
|
260
|
+
def __truediv__(self, other: Rational) -> Rational: # type: ignore[empty-body]
|
|
261
|
+
...
|
|
262
|
+
|
|
263
|
+
@BUILTINS.method(egg_fn="min")
|
|
264
|
+
def min(self, other: Rational) -> Rational: # type: ignore[empty-body]
|
|
265
|
+
...
|
|
266
|
+
|
|
267
|
+
@BUILTINS.method(egg_fn="max")
|
|
268
|
+
def max(self, other: Rational) -> Rational: # type: ignore[empty-body]
|
|
269
|
+
...
|
|
270
|
+
|
|
271
|
+
@BUILTINS.method(egg_fn="neg")
|
|
272
|
+
def __neg__(self) -> Rational: # type: ignore[empty-body]
|
|
273
|
+
...
|
|
274
|
+
|
|
275
|
+
@BUILTINS.method(egg_fn="abs")
|
|
276
|
+
def __abs__(self) -> Rational: # type: ignore[empty-body]
|
|
277
|
+
...
|
|
278
|
+
|
|
279
|
+
@BUILTINS.method(egg_fn="floor")
|
|
280
|
+
def floor(self) -> Rational: # type: ignore[empty-body]
|
|
281
|
+
...
|
|
282
|
+
|
|
283
|
+
@BUILTINS.method(egg_fn="ceil")
|
|
284
|
+
def ceil(self) -> Rational: # type: ignore[empty-body]
|
|
285
|
+
...
|
|
286
|
+
|
|
287
|
+
@BUILTINS.method(egg_fn="round")
|
|
288
|
+
def round(self) -> Rational: # type: ignore[empty-body]
|
|
289
|
+
...
|
|
290
|
+
|
|
291
|
+
@BUILTINS.method(egg_fn="pow")
|
|
292
|
+
def __pow__(self, other: Rational) -> Rational: # type: ignore[empty-body]
|
|
293
|
+
...
|
|
294
|
+
|
|
295
|
+
@BUILTINS.method(egg_fn="log")
|
|
296
|
+
def log(self) -> Rational: # type: ignore[empty-body]
|
|
297
|
+
...
|
|
298
|
+
|
|
299
|
+
@BUILTINS.method(egg_fn="sqrt")
|
|
300
|
+
def sqrt(self) -> Rational: # type: ignore[empty-body]
|
|
301
|
+
...
|
|
302
|
+
|
|
303
|
+
@BUILTINS.method(egg_fn="cbrt")
|
|
304
|
+
def cbrt(self) -> Rational: # type: ignore[empty-body]
|
|
305
|
+
...
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
@BUILTINS.class_(egg_sort="Vec")
|
|
309
|
+
class Vec(BaseExpr, Generic[T]):
|
|
310
|
+
@BUILTINS.method(egg_fn="vec-of")
|
|
311
|
+
def __init__(self, *args: T) -> None:
|
|
312
|
+
...
|
|
313
|
+
|
|
314
|
+
@BUILTINS.method(egg_fn="vec-empty")
|
|
315
|
+
@classmethod
|
|
316
|
+
def empty(cls) -> Vec[T]: # type: ignore[empty-body]
|
|
317
|
+
...
|
|
318
|
+
|
|
319
|
+
@BUILTINS.method(egg_fn="vec-append")
|
|
320
|
+
def append(self, *others: Vec[T]) -> Vec[T]: # type: ignore[empty-body]
|
|
321
|
+
...
|
|
322
|
+
|
|
323
|
+
@BUILTINS.method(egg_fn="vec-push")
|
|
324
|
+
def push(self, value: T) -> Vec[T]: # type: ignore[empty-body]
|
|
325
|
+
...
|
|
326
|
+
|
|
327
|
+
@BUILTINS.method(egg_fn="vec-pop")
|
|
328
|
+
def pop(self) -> Vec[T]: # type: ignore[empty-body]
|
|
329
|
+
...
|
|
330
|
+
|
|
331
|
+
@BUILTINS.method(egg_fn="vec-not-contains")
|
|
332
|
+
def not_contains(self, value: T) -> Unit: # type: ignore[empty-body]
|
|
333
|
+
...
|
|
334
|
+
|
|
335
|
+
@BUILTINS.method(egg_fn="vec-contains")
|
|
336
|
+
def contains(self, value: T) -> Unit: # type: ignore[empty-body]
|
|
337
|
+
...
|
|
338
|
+
|
|
339
|
+
@BUILTINS.method(egg_fn="vec-length")
|
|
340
|
+
def length(self) -> i64: # type: ignore[empty-body]
|
|
341
|
+
...
|
|
342
|
+
|
|
343
|
+
@BUILTINS.method(egg_fn="vec-get")
|
|
344
|
+
def __getitem__(self, index: i64Like) -> T: # type: ignore[empty-body]
|
|
345
|
+
...
|