forked from egraphs-good/egglog-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbindings.pyi
More file actions
973 lines (825 loc) · 21.5 KB
/
Copy pathbindings.pyi
File metadata and controls
973 lines (825 loc) · 21.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
from collections.abc import Callable
from datetime import timedelta
from fractions import Fraction
from pathlib import Path
from typing import Any, Generic, Literal, Protocol, TypeAlias, TypeVar, final
__all__ = [
"ActionCommand",
"AddRuleset",
"BiRewriteCommand",
"Bool",
"CSVPrintFunctionMode",
"Call",
"Change",
"Check",
"Constructor",
"CostModel",
"Datatype",
"Datatypes",
"DefaultPrintFunctionMode",
"Delete",
"EGraph",
"EggSmolError",
"EgglogSpan",
"Eq",
"Expr_",
"Extract",
"ExtractBest",
"ExtractVariants",
"Extractor",
"Fact",
"Fail",
"Float",
"FrozenEGraph",
"FrozenFunction",
"FrozenRow",
"Function",
"FunctionCommand",
"FusedIntersect",
"IdentSort",
"Include",
"Input",
"Int",
"Intersect",
"IterationReport",
"Let",
"Lit",
"NewSort",
"Output",
"OverallStatistics",
"Panic",
"PanicSpan",
"Plan",
"Pop",
"PrintAllFunctionsSize",
"PrintFunction",
"PrintFunctionOutput",
"PrintFunctionSize",
"PrintOverallStatistics",
"PrintSize",
"Prove",
"ProveExists",
"ProveExistsOutput",
"Push",
"Relation",
"Repeat",
"Rewrite",
"RewriteCommand",
"Rule",
"RuleCommand",
"RuleReport",
"RuleSetReport",
"Run",
"RunConfig",
"RunReport",
"RunSchedule",
"RunScheduleOutput",
"RustSpan",
"Saturate",
"Scan",
"Schema",
"Sequence",
"SerializedEGraph",
"Set",
"SingleScan",
"Sort",
"SrcFile",
"StageInfo",
"StageStats",
"String",
"SubVariants",
"Subsume",
"TermApp",
"TermDag",
"TermLit",
"TermVar",
"TimeOnly",
"Union",
"Unit",
"UnstableCombinedRuleset",
"UserDefined",
"UserDefinedCommandOutput",
"UserDefinedOutput",
"Value",
"Var",
"Variant",
"WithPlan",
"setup_tracing",
"shutdown_tracing",
]
def setup_tracing(*, exporter: Literal["console", "http"], endpoint: str | None = None) -> None: ...
def shutdown_tracing() -> None: ...
@final
class SerializedEGraph:
@property
def truncated_functions(self) -> list[str]: ...
@property
def discarded_functions(self) -> list[str]: ...
def inline_leaves(self) -> None: ...
def saturate_inline_leaves(self) -> None: ...
def to_dot(self) -> str: ...
def to_json(self) -> str: ...
def map_ops(self, map: dict[str, str]) -> None: ...
def split_classes(self, egraph: EGraph, ops: set[str]) -> None: ...
@final
class EGraph:
def __new__(
cls, *, fact_directory: str | Path | None = None, seminaive: bool = True, record: bool = False
) -> EGraph: ...
def parse_program(self, __input: str, /, filename: str | None = None) -> list[_Command]: ...
def commands(self) -> str | None: ...
def run_program(
self, *commands: _Command, traceparent: str | None = None, tracestate: str | None = None
) -> list[_CommandOutput]: ...
def serialize(
self,
root_eclasses: list[_Expr],
*,
max_functions: int | None = None,
max_calls_per_function: int | None = None,
include_temporary_functions: bool = False,
traceparent: str | None = None,
tracestate: str | None = None,
) -> SerializedEGraph: ...
def set_report_level(self, level: _ReportLevel) -> None: ...
def lookup_function(self, name: str, key: list[Value]) -> Value | None: ...
def eval_expr(
self, expr: _Expr, *, traceparent: str | None = None, tracestate: str | None = None
) -> tuple[str, Value]: ...
def value_to_i64(self, v: Value) -> int: ...
def value_to_f64(self, v: Value) -> float: ...
def value_to_string(self, v: Value) -> str: ...
def value_to_bool(self, v: Value) -> bool: ...
def value_to_rational(self, v: Value) -> Fraction: ...
def value_to_bigint(self, v: Value) -> int: ...
def value_to_bigrat(self, v: Value) -> Fraction: ...
def value_to_pyobject(self, v: Value) -> object: ...
def value_to_map(self, v: Value) -> dict[Value, Value]: ...
def value_to_multiset(self, v: Value) -> list[Value]: ...
def value_to_vec(self, v: Value) -> list[Value]: ...
def value_to_function(self, v: Value) -> tuple[str, list[Value]]: ...
def value_to_set(self, v: Value) -> set[Value]: ...
# def dynamic_cost_model_enode_cost(self, func: str, args: list[Value]) -> int: ...
def freeze(self) -> FrozenEGraph: ...
@final
class Value:
def __hash__(self) -> int: ...
def __eq__(self, value: object) -> bool: ...
def __lt__(self, other: object) -> bool: ...
def __le__(self, other: object) -> bool: ...
def __gt__(self, other: object) -> bool: ...
def __ge__(self, other: object) -> bool: ...
@final
class EggSmolError(Exception):
context: str
def __new__(cls, context: str) -> EggSmolError: ...
def __init__(self, /, *args: Any, **kwargs: Any) -> None: ...
##
# Spans
##
@final
class PanicSpan: ...
@final
class SrcFile:
name: str | None
contents: str
def __new__(cls, name: str | None, contents: str) -> SrcFile: ...
@final
class EgglogSpan:
file: SrcFile
i: int
j: int
def __new__(cls, file: SrcFile, i: int, j: int) -> EgglogSpan: ...
@final
class RustSpan:
file: str
line: int
column: int
def __new__(cls, file: str, line: int, column: int) -> RustSpan: ...
_Span: TypeAlias = PanicSpan | EgglogSpan | RustSpan
##
# Literals
##
@final
class Int:
value: int
def __new__(cls, value: int) -> Int: ...
@final
class Float:
value: float
def __new__(cls, value: float) -> Float: ...
@final
class String:
value: str
def __new__(cls, value: str) -> String: ...
@final
class Unit: ...
@final
class Bool:
value: bool
def __new__(cls, value: bool) -> Bool: ...
_Literal: TypeAlias = Int | Float | String | Bool | Unit
##
# Expressions
##
@final
class Lit:
span: _Span
value: _Literal
def __new__(cls, span: _Span, value: _Literal) -> Lit: ...
@final
class Var:
span: _Span
name: str
def __new__(cls, span: _Span, name: str) -> Var: ...
@final
class Call:
span: _Span
name: str
args: list[_Expr]
def __new__(cls, span: _Span, name: str, args: list[_Expr]) -> Call: ...
# Unions must be private becuase it is not actually exposed by the runtime library.
_Expr: TypeAlias = Lit | Var | Call
##
# Terms
##
@final
class TermLit:
value: _Literal
def __new__(cls, value: _Literal) -> TermLit: ...
@final
class TermVar:
name: str
def __new__(cls, name: str) -> TermVar: ...
@final
class TermApp:
name: str
args: list[int]
def __new__(cls, name: str, args: list[int]) -> TermApp: ...
_Term: TypeAlias = TermLit | TermVar | TermApp
_TermId: TypeAlias = int
##
# Facts
##
@final
class Eq:
span: _Span
left: _Expr
right: _Expr
def __new__(cls, span: _Span, left: _Expr, right: _Expr) -> Eq: ...
@final
class Fact:
expr: _Expr
def __new__(cls, expr: _Expr) -> Fact: ...
_Fact: TypeAlias = Fact | Eq
##
# Change
##
@final
class Delete: ...
@final
class Subsume: ...
_Change: TypeAlias = Delete | Subsume
##
# Actions
##
@final
class Let:
span: _Span
lhs: str
rhs: _Expr
def __new__(cls, span: _Span, lhs: str, rhs: _Expr) -> Let: ...
@final
class Set:
span: _Span
lhs: str
args: list[_Expr]
rhs: _Expr
def __new__(cls, span: _Span, lhs: str, args: list[_Expr], rhs: _Expr) -> Set: ...
@final
class Change:
span: _Span
change: _Change
sym: str
args: list[_Expr]
def __new__(cls, span: _Span, change: _Change, sym: str, args: list[_Expr]) -> Change: ...
@final
class Union:
span: _Span
lhs: _Expr
rhs: _Expr
def __new__(cls, span: _Span, lhs: _Expr, rhs: _Expr) -> Union: ...
@final
class Panic:
span: _Span
msg: str
def __new__(cls, span: _Span, msg: str) -> Panic: ...
@final
class Expr_: # noqa: N801
span: _Span
expr: _Expr
def __new__(cls, span: _Span, expr: _Expr) -> Expr_: ...
_Action: TypeAlias = Let | Set | Change | Union | Panic | Expr_
##
# Other Structs
##
@final
class Variant:
def __new__(
cls, span: _Span, name: str, types: list[str], cost: int | None = ..., unextractable: bool = ...
) -> Variant: ...
span: _Span
name: str
types: list[str]
cost: int | None
unextractable: bool
@final
class Schema:
input: list[str]
output: str
def __new__(cls, input: list[str], output: str) -> Schema: ...
@final
class Rule:
span: _Span
head: list[_Action]
body: list[_Fact]
name: str
ruleset: str
def __new__(cls, span: _Span, head: list[_Action], body: list[_Fact], name: str, ruleset: str) -> Rule: ...
@final
class Rewrite:
span: _Span
lhs: _Expr
rhs: _Expr
conditions: list[_Fact]
name: str
def __new__(
cls, span: _Span, lhs: _Expr, rhs: _Expr, conditions: list[_Fact] = ..., name: str = ...
) -> Rewrite: ...
@final
class RunConfig:
ruleset: str
until: list[_Fact] | None
def __new__(cls, ruleset: str, until: list[_Fact] | None = ...) -> RunConfig: ...
@final
class IdentSort:
ident: str
sort: str
def __new__(cls, ident: str, sort: str) -> IdentSort: ...
@final
class UserDefinedCommandOutput: ...
@final
class SingleScan:
atom: str
column: tuple[str, int]
def __new__(cls, atom: str, column: tuple[str, int]) -> SingleScan: ...
@final
class Scan:
atom: str
columns: list[tuple[str, int]]
def __new__(cls, atom: str, columns: list[tuple[str, int]]) -> Scan: ...
@final
class StageStats:
num_candidates: int
num_succeeded: int
def __new__(cls, num_candidates: int, num_succeeded: int) -> StageStats: ...
@final
class TimeOnly:
def __new__(cls) -> TimeOnly: ...
@final
class WithPlan:
def __new__(cls) -> WithPlan: ...
@final
class StageInfo:
def __new__(cls) -> StageInfo: ...
_ReportLevel: TypeAlias = TimeOnly | WithPlan | StageInfo
@final
class Intersect:
scans: list[SingleScan]
def __new__(cls, scans: list[SingleScan]) -> Intersect: ...
@final
class FusedIntersect:
cover: Scan
to_intersect: list[Scan]
def __new__(cls, cover: Scan, to_intersect: list[Scan]) -> FusedIntersect: ...
_Stage: TypeAlias = Intersect | FusedIntersect
@final
class Plan:
stages: list[tuple[_Stage, StageStats | None, list[int]]]
def __new__(cls, stages: list[tuple[_Stage, StageStats | None, list[int]]]) -> Plan: ...
@final
class RuleReport:
plan: Plan | None
search_and_apply_time: timedelta
num_matches: int
def __new__(cls, plan: Plan | None, search_and_apply_time: timedelta, num_matches: int) -> RuleReport: ...
@final
class RuleSetReport:
changed: bool
rule_reports: dict[str, list[RuleReport]]
search_and_apply_time: timedelta
merge_time: timedelta
def __new__(
cls,
changed: bool,
rule_reports: dict[str, list[RuleReport]],
search_and_apply_time: timedelta,
merge_time: timedelta,
) -> RuleSetReport: ...
@final
class IterationReport:
rule_set_report: RuleSetReport
rebuild_time: timedelta
def __new__(cls, rule_set_report: RuleSetReport, rebuild_time: timedelta) -> IterationReport: ...
@final
class Function:
name: str
@final
class RunReport:
iterations: list[IterationReport]
updated: bool
search_and_apply_time_per_rule: dict[str, timedelta]
num_matches_per_rule: dict[str, int]
search_and_apply_time_per_ruleset: dict[str, timedelta]
merge_time_per_ruleset: dict[str, timedelta]
rebuild_time_per_ruleset: dict[str, timedelta]
def __new__(
cls,
iterations: list[IterationReport],
updated: bool,
search_and_apply_time_per_rule: dict[str, timedelta],
num_matches_per_rule: dict[str, int],
search_and_apply_time_per_ruleset: dict[str, timedelta],
merge_time_per_ruleset: dict[str, timedelta],
rebuild_time_per_ruleset: dict[str, timedelta],
) -> RunReport: ...
##
# Command Outputs
##
@final
class PrintFunctionSize:
size: int
def __new__(cls, size: int) -> PrintFunctionSize: ...
@final
class PrintAllFunctionsSize:
sizes: list[tuple[str, int]]
def __new__(cls, sizes: list[tuple[str, int]]) -> PrintAllFunctionsSize: ...
@final
class ExtractVariants:
termdag: TermDag
terms: list[_TermId]
def __new__(cls, termdag: TermDag, terms: list[_TermId]) -> ExtractVariants: ...
@final
class ExtractBest:
termdag: TermDag
cost: int
term: _TermId
def __new__(cls, termdag: TermDag, cost: int, term: _TermId) -> ExtractBest: ...
@final
class ProveExistsOutput:
proof: str
def __new__(cls, proof: str) -> ProveExistsOutput: ...
@final
class OverallStatistics:
report: RunReport
def __new__(cls, report: RunReport) -> OverallStatistics: ...
@final
class RunScheduleOutput:
report: RunReport
def __new__(cls, report: RunReport) -> RunScheduleOutput: ...
@final
class PrintFunctionOutput:
function: Function
termdag: TermDag
terms: list[tuple[_TermId, _TermId]]
mode: _PrintFunctionMode
def __new__(
cls, function: Function, termdag: TermDag, terms: list[tuple[_TermId, _TermId]], mode: _PrintFunctionMode
) -> PrintFunctionOutput: ...
@final
class UserDefinedOutput:
output: UserDefinedCommandOutput
def __new__(cls, output: UserDefinedCommandOutput) -> UserDefinedOutput: ...
_CommandOutput: TypeAlias = (
PrintFunctionSize
| PrintAllFunctionsSize
| ExtractVariants
| ExtractBest
| ProveExistsOutput
| OverallStatistics
| RunScheduleOutput
| PrintFunctionOutput
| UserDefinedOutput
)
##
# Print Function Modes
##
@final
class DefaultPrintFunctionMode: ...
@final
class CSVPrintFunctionMode: ...
_PrintFunctionMode: TypeAlias = DefaultPrintFunctionMode | CSVPrintFunctionMode
##
# Schedules
##
@final
class Saturate:
span: _Span
schedule: _Schedule
def __new__(cls, span: _Span, schedule: _Schedule) -> Saturate: ...
@final
class Repeat:
span: _Span
length: int
schedule: _Schedule
def __new__(cls, span: _Span, length: int, schedule: _Schedule) -> Repeat: ...
@final
class Run:
span: _Span
config: RunConfig
def __new__(cls, span: _Span, config: RunConfig) -> Run: ...
@final
class Sequence:
span: _Span
schedules: list[_Schedule]
def __new__(cls, span: _Span, schedules: list[_Schedule]) -> Sequence: ...
_Schedule: TypeAlias = Saturate | Repeat | Run | Sequence
##
# Subdatatypes
##
@final
class SubVariants:
variants: list[Variant]
def __new__(cls, variants: list[Variant]) -> SubVariants: ...
@final
class NewSort:
name: str
args: list[_Expr]
def __new__(cls, name: str, args: list[_Expr]) -> NewSort: ...
_Subdatatypes: TypeAlias = SubVariants | NewSort
##
# Commands
##
@final
class Datatype:
span: _Span
name: str
variants: list[Variant]
def __new__(cls, span: _Span, name: str, variants: list[Variant]) -> Datatype: ...
@final
class Datatypes:
span: _Span
datatypes: list[tuple[_Span, str, _Subdatatypes]]
def __new__(cls, span: _Span, datatypes: list[tuple[_Span, str, _Subdatatypes]]) -> Datatypes: ...
@final
class Sort:
span: _Span
name: str
presort_and_args: tuple[str, list[_Expr]] | None
def __new__(cls, span: _Span, name: str, presort_and_args: tuple[str, list[_Expr]] | None) -> Sort: ...
@final
class FunctionCommand:
span: _Span
name: str
schema: Schema
merge: _Expr | None
def __new__(cls, span: _Span, name: str, schema: Schema, merge: _Expr | None) -> FunctionCommand: ...
@final
class AddRuleset:
span: _Span
name: str
def __new__(cls, span: _Span, name: str) -> AddRuleset: ...
@final
class RuleCommand:
rule: Rule
def __new__(cls, rule: Rule) -> RuleCommand: ...
@final
class RewriteCommand:
# TODO: Rename to ruleset
name: str
rewrite: Rewrite
subsume: bool
def __new__(cls, name: str, rewrite: Rewrite, subsume: bool) -> RewriteCommand: ...
@final
class BiRewriteCommand:
# TODO: Rename to ruleset
name: str
rewrite: Rewrite
def __new__(cls, name: str, rewrite: Rewrite) -> BiRewriteCommand: ...
@final
class ActionCommand:
action: _Action
def __new__(cls, action: _Action) -> ActionCommand: ...
@final
class RunSchedule:
schedule: _Schedule
def __new__(cls, schedule: _Schedule) -> RunSchedule: ...
@final
class Extract:
span: _Span
expr: _Expr
variants: _Expr
def __new__(cls, span: _Span, expr: _Expr, variants: _Expr) -> Extract: ...
@final
class Check:
span: _Span
facts: list[_Fact]
def __new__(cls, span: _Span, facts: list[_Fact]) -> Check: ...
@final
class Prove:
span: _Span
facts: list[_Fact]
def __new__(cls, span: _Span, facts: list[_Fact]) -> Prove: ...
@final
class ProveExists:
span: _Span
expr: str
def __new__(cls, span: _Span, expr: str) -> ProveExists: ...
@final
class PrintFunction:
span: _Span
name: str
length: int | None
filename: str | None
mode: _PrintFunctionMode
def __new__(
cls, span: _Span, name: str, length: int | None, filename: str | None, mode: _PrintFunctionMode
) -> PrintFunction: ...
@final
class PrintSize:
span: _Span
name: str | None
def __new__(cls, span: _Span, name: str | None) -> PrintSize: ...
@final
class Output:
span: _Span
file: str
exprs: list[_Expr]
def __new__(cls, span: _Span, file: str, exprs: list[_Expr]) -> Output: ...
@final
class Input:
span: _Span
name: str
file: str
def __new__(cls, span: _Span, name: str, file: str) -> Input: ...
@final
class Push:
length: int
def __new__(cls, length: int) -> Push: ...
@final
class Pop:
span: _Span
length: int
def __new__(cls, span: _Span, length: int) -> Pop: ...
@final
class Fail:
span: _Span
command: _Command
def __new__(cls, span: _Span, command: _Command) -> Fail: ...
@final
class Include:
span: _Span
path: str
def __new__(cls, span: _Span, path: str) -> Include: ...
@final
class Relation:
span: _Span
name: str
inputs: list[str]
def __new__(cls, span: _Span, name: str, inputs: list[str]) -> Relation: ...
@final
class Constructor:
span: _Span
name: str
schema: Schema
cost: int | None
unextractable: bool
def __new__(cls, span: _Span, name: str, schema: Schema, cost: int | None, unextractable: bool) -> Constructor: ...
@final
class PrintOverallStatistics:
span: _Span
file: str | None
def __new__(cls, span: _Span, file: str | None) -> PrintOverallStatistics: ...
@final
class UserDefined:
span: _Span
name: str
args: list[_Expr]
def __new__(cls, span: _Span, name: str, args: list[_Expr]) -> UserDefined: ...
@final
class UnstableCombinedRuleset:
span: _Span
name: str
rulesets: list[str]
def __new__(cls, span: _Span, name: str, rulesets: list[str]) -> UnstableCombinedRuleset: ...
_Command: TypeAlias = (
Datatype
| Datatypes
| Sort
| FunctionCommand
| AddRuleset
| RuleCommand
| RewriteCommand
| BiRewriteCommand
| ActionCommand
| RunSchedule
| Extract
| Check
| Prove
| ProveExists
| PrintFunction
| PrintSize
| Output
| Input
| Push
| Pop
| Fail
| Include
| Relation
| PrintOverallStatistics
| UnstableCombinedRuleset
| Constructor
| UserDefined
)
##
# TermDag
##
@final
class TermDag:
def size(self) -> int: ...
def lookup(self, node: _Term) -> _TermId: ...
def get(self, id: _TermId) -> _Term: ...
def app(self, sym: str, children: list[_TermId]) -> _TermId: ...
def lit(self, lit: _Literal) -> _TermId: ...
def var(self, sym: str) -> _TermId: ...
def expr_to_term(self, expr: _Expr) -> _TermId: ...
def term_to_expr(self, term: _TermId, span: _Span) -> _Expr: ...
def to_string(self, term: _TermId) -> str: ...
##
# Extraction
##
class _Cost(Protocol):
def __lt__(self, other: _Cost) -> bool: ...
def __le__(self, other: _Cost) -> bool: ...
def __gt__(self, other: _Cost) -> bool: ...
def __ge__(self, other: _Cost) -> bool: ...
_COST = TypeVar("_COST", bound=_Cost)
_ENODE_COST = TypeVar("_ENODE_COST")
@final
class CostModel(Generic[_COST, _ENODE_COST]):
def __new__(
cls,
fold: Callable[[str, _ENODE_COST, list[_COST]], _COST],
enode_cost: Callable[[str, list[Value]], _ENODE_COST],
container_cost: Callable[[str, Value, list[_COST]], _COST],
base_value_cost: Callable[[str, Value], _COST],
) -> CostModel[_COST, _ENODE_COST]: ...
@final
class Extractor(Generic[_COST]):
def __new__(
cls,
rootsorts: list[str] | None,
egraph: EGraph,
cost_model: CostModel[_COST, Any],
*,
traceparent: str | None = None,
tracestate: str | None = None,
) -> Extractor[_COST]: ...
def extract_best(
self,
egraph: EGraph,
termdag: TermDag,
value: Value,
sort: str,
*,
traceparent: str | None = None,
tracestate: str | None = None,
) -> tuple[_COST, _TermId]: ...
def extract_variants(
self,
egraph: EGraph,
termdag: TermDag,
value: Value,
nvariants: int,
sort: str,
*,
traceparent: str | None = None,
tracestate: str | None = None,
) -> list[tuple[_COST, _TermId]]: ...
##
# Frozen
##
@final
class FrozenEGraph:
functions: dict[str, FrozenFunction]
@final
class FrozenFunction:
input_sorts: list[str]
output_sort: str
is_let_binding: bool
rows: list[FrozenRow]
@final
class FrozenRow:
subsumed: bool
inputs: list[Value]
output: Value