Skip to content

Commit 6b46a65

Browse files
Fix execution of docs
1 parent dbf79f8 commit 6b46a65

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

docs/reference/egglog-translation.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ The high level bindings available at the top module (`egglog`) expose most of th
88

99
Any EGraph can also be converted to egglog with the `egraph.as_egglog_string` property, as long as it was created with `Egraph(save_egglog_string=True)`.
1010

11-
## Unsupported features
12-
13-
The currently unsupported features are:
14-
15-
- `(output ...)`: No examples in the tests, so not sure how this works.
16-
1711
## Builtin Types
1812

1913
The builtin types of Unit, String, Int, Map, and Rational are all exposed as Python classes.
@@ -314,7 +308,7 @@ edge = relation("edge", i64, i64)
314308
# (rule ((edge x y))
315309
# ((path x y)) :ruleset path)
316310
x, y = vars_("x y", i64)
317-
path_ruleset = ruleset(rule(edge(x, y)).then(path(x, y)), name="path")
311+
path_ruleset = ruleset(rule(edge(x, y)).then(path(x, y)), name="path_ruleset")
318312
```
319313

320314
### Rewrites
@@ -358,8 +352,8 @@ egraph.run(5)
358352
Facts can be passed after the timeout to only run until those facts are reached:
359353

360354
```{code-cell} python
361-
# egg: (run 10000 :until (fib 10))
362-
egraph.run(10000, eq(fib(7)).to(i64(13)))
355+
# egg: (run 10000 :until (fib 7))
356+
egraph.run(10000, fib(7))
363357
```
364358

365359
Rulesets can be run as well, by calling the `run` method on them:
@@ -478,8 +472,6 @@ Multiple items can also be extracted, returning a list of the lowest cost expres
478472
a, b, c = vars_("a b c", Math)
479473
i, j = vars_("i j", i64)
480474
egraph.register(
481-
rewrite(a * b).to(b * a),
482-
rewrite(a + b).to(b + a),
483475
rewrite(a * (b * c)).to((a * b) * c),
484476
rewrite(a * (b + c)).to((a * b) + (a * c)),
485477
rewrite(Math(i) + Math(j)).to(Math(i + j)),

docs/reference/python-integration.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ However, there are times in Python when you need the return type of a method to
326326
For example, let's say you are implementing a `Bool` expression, but you want to be able to use it in `if` statements in Python. That means it needs to define a `__bool__` methods which returns a Python `bool`, based on evaluating the expression.
327327

328328
```{code-cell} python
329+
egraph = EGraph()
329330
class Boolean(Expr):
330331
@method(preserve=True)
331332
def __bool__(self) -> bool:
@@ -334,7 +335,7 @@ class Boolean(Expr):
334335
# Run until the e-graph saturates
335336
egraph.run(10)
336337
# Extract the Python object from the e-graph
337-
value = EGraph().extract(self)
338+
value = egraph.extract(self)
338339
if value == TRUE:
339340
return True
340341
elif value == FALSE:
@@ -344,8 +345,8 @@ class Boolean(Expr):
344345
def __or__(self, other: Boolean) -> Boolean:
345346
...
346347
347-
TRUE = egraph.constant("TRUE", Boolean)
348-
FALSE = egraph.constant("FALSE", Boolean)
348+
TRUE = constant("TRUE", Boolean)
349+
FALSE = constant("FALSE", Boolean)
349350
350351
351352
@egraph.register

0 commit comments

Comments
 (0)