egglog 8.0.1__cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.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 ADDED
@@ -0,0 +1,10 @@
1
+ """
2
+ Package for creating e-graphs in Python.
3
+ """
4
+
5
+ from . import config, ipython_magic # noqa: F401
6
+ from .builtins import * # noqa: UP029
7
+ from .conversion import convert, converter # noqa: F401
8
+ from .egraph import *
9
+
10
+ del ipython_magic
Binary file
egglog/bindings.pyi ADDED
@@ -0,0 +1,587 @@
1
+ from datetime import timedelta
2
+ from fractions import Fraction
3
+ from pathlib import Path
4
+ from typing import TypeAlias
5
+
6
+ from typing_extensions import final
7
+
8
+ @final
9
+ class SerializedEGraph:
10
+ def inline_leaves(self) -> None: ...
11
+ def saturate_inline_leaves(self) -> None: ...
12
+ def to_dot(self) -> str: ...
13
+ def to_json(self) -> str: ...
14
+ def map_ops(self, map: dict[str, str]) -> None: ...
15
+ def split_classes(self, egraph: EGraph, ops: set[str]) -> None: ...
16
+
17
+ @final
18
+ class PyObjectSort:
19
+ def __init__(self) -> None: ...
20
+ def store(self, __o: object, /) -> _Expr: ...
21
+
22
+ def parse_program(__input: str, /, filename: str | None = None) -> list[_Command]: ...
23
+ @final
24
+ class EGraph:
25
+ def __init__(
26
+ self,
27
+ __py_object_sort: PyObjectSort | None = None,
28
+ *,
29
+ fact_directory: str | Path | None = None,
30
+ seminaive: bool = True,
31
+ record: bool = False,
32
+ ) -> None: ...
33
+ def commands(self) -> str | None: ...
34
+ def run_program(self, *commands: _Command) -> list[str]: ...
35
+ def extract_report(self) -> _ExtractReport | None: ...
36
+ def run_report(self) -> RunReport | None: ...
37
+ def serialize(
38
+ self,
39
+ root_eclasses: list[_Expr],
40
+ *,
41
+ max_functions: int | None = None,
42
+ max_calls_per_function: int | None = None,
43
+ include_temporary_functions: bool = False,
44
+ ) -> SerializedEGraph: ...
45
+ def eval_py_object(self, __expr: _Expr) -> object: ...
46
+ def eval_i64(self, __expr: _Expr) -> int: ...
47
+ def eval_f64(self, __expr: _Expr) -> float: ...
48
+ def eval_string(self, __expr: _Expr) -> str: ...
49
+ def eval_bool(self, __expr: _Expr) -> bool: ...
50
+ def eval_rational(self, __expr: _Expr) -> Fraction: ...
51
+
52
+ @final
53
+ class EggSmolError(Exception):
54
+ context: str
55
+
56
+ ##
57
+ # Spans
58
+ ##
59
+
60
+ @final
61
+ class SrcFile:
62
+ def __init__(self, name: str, contents: str | None = None) -> None: ...
63
+ name: str
64
+ contents: str | None
65
+
66
+ @final
67
+ class Span:
68
+ def __init__(self, file: SrcFile, start: int, end: int) -> None: ...
69
+ file: SrcFile
70
+ start: int
71
+ end: int
72
+
73
+ DUMMY_SPAN: Span = ...
74
+
75
+ ##
76
+ # Literals
77
+ ##
78
+
79
+ @final
80
+ class Int:
81
+ def __init__(self, value: int) -> None: ...
82
+ value: int
83
+
84
+ @final
85
+ class F64:
86
+ value: float
87
+ def __init__(self, value: float) -> None: ...
88
+
89
+ @final
90
+ class String:
91
+ def __init__(self, value: str) -> None: ...
92
+ value: str
93
+
94
+ @final
95
+ class Unit:
96
+ def __init__(self) -> None: ...
97
+
98
+ @final
99
+ class Bool:
100
+ def __init__(self, b: bool) -> None: ...
101
+ value: bool
102
+
103
+ _Literal: TypeAlias = Int | F64 | String | Bool | Unit
104
+
105
+ ##
106
+ # Expressions
107
+ ##
108
+
109
+ @final
110
+ class Lit:
111
+ def __init__(self, span: Span, value: _Literal) -> None: ...
112
+ span: Span
113
+ value: _Literal
114
+
115
+ @final
116
+ class Var:
117
+ def __init__(self, span: Span, name: str) -> None: ...
118
+ span: Span
119
+ name: str
120
+
121
+ @final
122
+ class Call:
123
+ def __init__(self, span: Span, name: str, args: list[_Expr]) -> None: ...
124
+ span: Span
125
+ name: str
126
+ args: list[_Expr]
127
+
128
+ # Unions must be private becuase it is not actually exposed by the runtime library.
129
+ _Expr: TypeAlias = Lit | Var | Call
130
+
131
+ ##
132
+ # Terms
133
+ ##
134
+
135
+ @final
136
+ class TermLit:
137
+ def __init__(self, value: _Literal) -> None: ...
138
+ value: _Literal
139
+
140
+ @final
141
+ class TermVar:
142
+ def __init__(self, name: str) -> None: ...
143
+ name: str
144
+
145
+ @final
146
+ class TermApp:
147
+ def __init__(self, name: str, args: list[int]) -> None: ...
148
+ name: str
149
+ args: list[int]
150
+
151
+ _Term: TypeAlias = TermLit | TermVar | TermApp
152
+
153
+ @final
154
+ class TermDag:
155
+ nodes: list[_Term]
156
+ hashcons: dict[_Term, int]
157
+
158
+ ##
159
+ # Facts
160
+ ##
161
+
162
+ @final
163
+ class Eq:
164
+ def __init__(self, span: Span, exprs: list[_Expr]) -> None: ...
165
+ span: Span
166
+ exprs: list[_Expr]
167
+
168
+ @final
169
+ class Fact:
170
+ def __init__(self, expr: _Expr) -> None: ...
171
+ expr: _Expr
172
+
173
+ _Fact: TypeAlias = Fact | Eq
174
+
175
+ ##
176
+ # Change
177
+ ##
178
+
179
+ @final
180
+ class Delete:
181
+ def __init__(self) -> None: ...
182
+
183
+ @final
184
+ class Subsume:
185
+ def __init__(self) -> None: ...
186
+
187
+ _Change: TypeAlias = Delete | Subsume
188
+
189
+ ##
190
+ # Actions
191
+ ##
192
+
193
+ @final
194
+ class Let:
195
+ def __init__(self, span: Span, lhs: str, rhs: _Expr) -> None: ...
196
+ span: Span
197
+ lhs: str
198
+ rhs: _Expr
199
+
200
+ @final
201
+ class Set:
202
+ def __init__(self, span: Span, lhs: str, args: list[_Expr], rhs: _Expr) -> None: ...
203
+ span: Span
204
+ lhs: str
205
+ args: list[_Expr]
206
+ rhs: _Expr
207
+
208
+ @final
209
+ class Change:
210
+ span: Span
211
+ change: _Change
212
+ sym: str
213
+ args: list[_Expr]
214
+ def __init__(self, span: Span, change: _Change, sym: str, args: list[_Expr]) -> None: ...
215
+
216
+ @final
217
+ class Union:
218
+ def __init__(self, span: Span, lhs: _Expr, rhs: _Expr) -> None: ...
219
+ span: Span
220
+ lhs: _Expr
221
+ rhs: _Expr
222
+
223
+ @final
224
+ class Panic:
225
+ def __init__(self, span: Span, msg: str) -> None: ...
226
+ span: Span
227
+ msg: str
228
+
229
+ @final
230
+ class Expr_: # noqa: N801
231
+ def __init__(self, span: Span, expr: _Expr) -> None: ...
232
+ span: Span
233
+ expr: _Expr
234
+
235
+ @final
236
+ class Extract:
237
+ def __init__(self, span: Span, expr: _Expr, variants: _Expr) -> None: ...
238
+ span: Span
239
+ expr: _Expr
240
+ variants: _Expr
241
+
242
+ _Action: TypeAlias = Let | Set | Change | Union | Panic | Expr_ | Extract
243
+
244
+ ##
245
+ # Other Structs
246
+ ##
247
+
248
+ @final
249
+ class FunctionDecl:
250
+ span: Span
251
+ name: str
252
+ schema: Schema
253
+ default: _Expr | None
254
+ merge: _Expr | None
255
+ merge_action: list[_Action]
256
+ cost: int | None
257
+ unextractable: bool
258
+ ignore_viz: bool
259
+
260
+ def __init__(
261
+ self,
262
+ span: Span,
263
+ name: str,
264
+ schema: Schema,
265
+ default: _Expr | None = None,
266
+ merge: _Expr | None = None,
267
+ merge_action: list[_Action] = [], # noqa: B006
268
+ cost: int | None = None,
269
+ unextractable: bool = False,
270
+ ignore_viz: bool = False,
271
+ ) -> None: ...
272
+
273
+ @final
274
+ class Variant:
275
+ def __init__(self, span: Span, name: str, types: list[str], cost: int | None = None) -> None: ...
276
+ span: Span
277
+ name: str
278
+ types: list[str]
279
+ cost: int | None
280
+
281
+ @final
282
+ class Schema:
283
+ input: list[str]
284
+ output: str
285
+ def __init__(self, input: list[str], output: str) -> None: ...
286
+
287
+ @final
288
+ class Rule:
289
+ span: Span
290
+ head: list[_Action]
291
+ body: list[_Fact]
292
+ def __init__(self, span: Span, head: list[_Action], body: list[_Fact]) -> None: ...
293
+
294
+ @final
295
+ class Rewrite:
296
+ span: Span
297
+ lhs: _Expr
298
+ rhs: _Expr
299
+ conditions: list[_Fact]
300
+
301
+ def __init__(self, span: Span, lhs: _Expr, rhs: _Expr, conditions: list[_Fact] = []) -> None: ... # noqa: B006
302
+
303
+ @final
304
+ class RunConfig:
305
+ ruleset: str
306
+ until: list[_Fact] | None
307
+ def __init__(self, ruleset: str, until: list[_Fact] | None = None) -> None: ...
308
+
309
+ @final
310
+ class IdentSort:
311
+ ident: str
312
+ sort: str
313
+ def __init__(self, ident: str, sort: str) -> None: ...
314
+
315
+ @final
316
+ class RunReport:
317
+ updated: bool
318
+ search_time_per_rule: dict[str, timedelta]
319
+ apply_time_per_rule: dict[str, timedelta]
320
+ search_time_per_ruleset: dict[str, timedelta]
321
+ apply_time_per_ruleset: dict[str, timedelta]
322
+ rebuild_time_per_ruleset: dict[str, timedelta]
323
+ num_matches_per_rule: dict[str, int]
324
+
325
+ def __init__(
326
+ self,
327
+ updated: bool,
328
+ search_time_per_rule: dict[str, timedelta],
329
+ apply_time_per_rule: dict[str, timedelta],
330
+ search_time_per_ruleset: dict[str, timedelta],
331
+ apply_time_per_ruleset: dict[str, timedelta],
332
+ rebuild_time_per_ruleset: dict[str, timedelta],
333
+ num_matches_per_rule: dict[str, int],
334
+ ) -> None: ...
335
+
336
+ @final
337
+ class Variants:
338
+ termdag: TermDag
339
+ terms: list[_Term]
340
+ def __init__(self, termdag: TermDag, terms: list[_Term]) -> None: ...
341
+
342
+ @final
343
+ class Best:
344
+ termdag: TermDag
345
+ cost: int
346
+ term: _Term
347
+ def __init__(self, termdag: TermDag, cost: int, term: _Term) -> None: ...
348
+
349
+ _ExtractReport: TypeAlias = Variants | Best
350
+
351
+ ##
352
+ # Schedules
353
+ ##
354
+
355
+ @final
356
+ class Saturate:
357
+ span: Span
358
+ schedule: _Schedule
359
+ def __init__(self, span: Span, schedule: _Schedule) -> None: ...
360
+
361
+ @final
362
+ class Repeat:
363
+ span: Span
364
+ length: int
365
+ schedule: _Schedule
366
+ def __init__(self, span: Span, length: int, schedule: _Schedule) -> None: ...
367
+
368
+ @final
369
+ class Run:
370
+ span: Span
371
+ config: RunConfig
372
+ def __init__(self, span: Span, config: RunConfig) -> None: ...
373
+
374
+ @final
375
+ class Sequence:
376
+ span: Span
377
+ schedules: list[_Schedule]
378
+ def __init__(self, span: Span, schedules: list[_Schedule]) -> None: ...
379
+
380
+ _Schedule: TypeAlias = Saturate | Repeat | Run | Sequence
381
+
382
+ ##
383
+ # Subdatatypes
384
+ ##
385
+
386
+ @final
387
+ class SubVariants:
388
+ def __init__(self, variants: list[Variant]) -> None: ...
389
+ variants: list[Variant]
390
+
391
+ @final
392
+ class NewSort:
393
+ def __init__(self, name: str, args: list[_Expr]) -> None: ...
394
+ name: str
395
+ args: list[_Expr]
396
+
397
+ _Subdatatypes: TypeAlias = SubVariants | NewSort
398
+
399
+ ##
400
+ # Commands
401
+ ##
402
+
403
+ @final
404
+ class SetOption:
405
+ name: str
406
+ value: _Expr
407
+ def __init__(self, name: str, value: _Expr) -> None: ...
408
+
409
+ @final
410
+ class Datatype:
411
+ span: Span
412
+ name: str
413
+ variants: list[Variant]
414
+ def __init__(self, span: Span, name: str, variants: list[Variant]) -> None: ...
415
+
416
+ @final
417
+ class Datatypes:
418
+ span: Span
419
+ datatypes: list[tuple[Span, str, _Subdatatypes]]
420
+ def __init__(self, span: Span, datatypes: list[tuple[Span, str, _Subdatatypes]]) -> None: ...
421
+
422
+ @final
423
+ class Sort:
424
+ span: Span
425
+ name: str
426
+ presort_and_args: tuple[str, list[_Expr]] | None
427
+ def __init__(self, span: Span, name: str, presort_and_args: tuple[str, list[_Expr]] | None = None) -> None: ...
428
+
429
+ @final
430
+ class Function:
431
+ decl: FunctionDecl
432
+ def __init__(self, decl: FunctionDecl) -> None: ...
433
+
434
+ @final
435
+ class AddRuleset:
436
+ name: str
437
+ def __init__(self, name: str) -> None: ...
438
+
439
+ @final
440
+ class RuleCommand:
441
+ name: str
442
+ ruleset: str
443
+ rule: Rule
444
+ def __init__(self, name: str, ruleset: str, rule: Rule) -> None: ...
445
+
446
+ @final
447
+ class RewriteCommand:
448
+ # TODO: Rename to ruleset
449
+ name: str
450
+ rewrite: Rewrite
451
+ subsume: bool
452
+ def __init__(self, name: str, rewrite: Rewrite, subsume: bool) -> None: ...
453
+
454
+ @final
455
+ class BiRewriteCommand:
456
+ # TODO: Rename to ruleset
457
+ name: str
458
+ rewrite: Rewrite
459
+ def __init__(self, name: str, rewrite: Rewrite) -> None: ...
460
+
461
+ @final
462
+ class ActionCommand:
463
+ action: _Action
464
+ def __init__(self, action: _Action) -> None: ...
465
+
466
+ @final
467
+ class RunSchedule:
468
+ schedule: _Schedule
469
+ def __init__(self, schedule: _Schedule) -> None: ...
470
+
471
+ @final
472
+ class Simplify:
473
+ span: Span
474
+ expr: _Expr
475
+ schedule: _Schedule
476
+ def __init__(self, span: Span, expr: _Expr, schedule: _Schedule) -> None: ...
477
+
478
+ @final
479
+ class QueryExtract:
480
+ span: Span
481
+ variants: int
482
+ expr: _Expr
483
+ def __init__(self, span: Span, variants: int, expr: _Expr) -> None: ...
484
+
485
+ @final
486
+ class Check:
487
+ span: Span
488
+ facts: list[_Fact]
489
+ def __init__(self, span: Span, facts: list[_Fact]) -> None: ...
490
+
491
+ @final
492
+ class PrintFunction:
493
+ span: Span
494
+ name: str
495
+ length: int
496
+ def __init__(self, span: Span, name: str, length: int) -> None: ...
497
+
498
+ @final
499
+ class PrintSize:
500
+ span: Span
501
+ name: str | None
502
+ def __init__(self, span: Span, name: str | None) -> None: ...
503
+
504
+ @final
505
+ class Output:
506
+ span: Span
507
+ file: str
508
+ exprs: list[_Expr]
509
+ def __init__(self, span: Span, file: str, exprs: list[_Expr]) -> None: ...
510
+
511
+ @final
512
+ class Input:
513
+ span: Span
514
+ name: str
515
+ file: str
516
+ def __init__(self, span: Span, name: str, file: str) -> None: ...
517
+
518
+ @final
519
+ class Push:
520
+ length: int
521
+ def __init__(self, length: int) -> None: ...
522
+
523
+ @final
524
+ class Pop:
525
+ span: Span
526
+ length: int
527
+ def __init__(self, span: Span, length: int) -> None: ...
528
+
529
+ @final
530
+ class Fail:
531
+ span: Span
532
+ command: _Command
533
+ def __init__(self, span: Span, command: _Command) -> None: ...
534
+
535
+ @final
536
+ class Include:
537
+ span: Span
538
+ path: str
539
+ def __init__(self, span: Span, path: str) -> None: ...
540
+
541
+ @final
542
+ class Relation:
543
+ span: Span
544
+ constructor: str
545
+ inputs: list[str]
546
+
547
+ def __init__(self, span: Span, constructor: str, inputs: list[str]) -> None: ...
548
+
549
+ @final
550
+ class PrintOverallStatistics:
551
+ def __init__(self) -> None: ...
552
+
553
+ @final
554
+ class UnstableCombinedRuleset:
555
+ name: str
556
+ rulesets: list[str]
557
+ def __init__(self, name: str, rulesets: list[str]) -> None: ...
558
+
559
+ _Command: TypeAlias = (
560
+ SetOption
561
+ | Datatype
562
+ | Datatypes
563
+ | Sort
564
+ | Function
565
+ | AddRuleset
566
+ | RuleCommand
567
+ | RewriteCommand
568
+ | BiRewriteCommand
569
+ | ActionCommand
570
+ | RunSchedule
571
+ | Simplify
572
+ | QueryExtract
573
+ | Check
574
+ | PrintFunction
575
+ | PrintSize
576
+ | Output
577
+ | Input
578
+ | Push
579
+ | Pop
580
+ | Fail
581
+ | Include
582
+ | Relation
583
+ | PrintOverallStatistics
584
+ | UnstableCombinedRuleset
585
+ )
586
+
587
+ def termdag_term_to_expr(termdag: TermDag, term: _Term) -> _Expr: ...