Skip to content

Commit 12bb4cc

Browse files
Merge pull request #258 from egraphs-good/upgrade-egglog
Upgrade egglog version
2 parents 60d5435 + e58bd2f commit 12bb4cc

33 files changed

+1089
-1365
lines changed

Cargo.lock

Lines changed: 86 additions & 325 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "egglog_python"
33
version = "8.0.1"
44
edition = "2021"
55

6+
67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78
[lib]
89
name = "egglog"
@@ -11,27 +12,23 @@ crate-type = ["cdylib"]
1112
[dependencies]
1213
pyo3 = { version = "0.22.5", features = ["extension-module"] }
1314

14-
# https://github.com/egraphs-good/egglog/compare/ceed816e9369570ffed9feeba157b19471dda70d...main
15-
egglog = { git = "https://github.com/egraphs-good/egglog", rev = "b0db06832264c9b22694bd3de2bdacd55bbe9e32" }
16-
# egglog = { path = "../egg-smol" }
17-
# egglog = { git = "https://github.com/oflatt/egg-smol", branch = "oflatt-fast-terms" }
18-
# egglog = { git = "https://github.com/saulshanabrook/egg-smol", rev = "a555b2f5e82c684442775cc1a5da94b71930113c" }
15+
egglog = { git = "https://github.com/saulshanabrook/egg-smol", rev = "889ca7635368d7e382e16a93b2883aba82f1078f" }
16+
egglog-experimental = { git = "https://github.com/egraphs-good/egglog-experimental", rev = "8a1b3d6ad2723a8438f51f05027161e51f37917c" }
1917
egraph-serialize = { version = "0.2.0", features = ["serde", "graphviz"] }
20-
# egraph-serialize = { path = "../egraph-serialize", features = [
21-
# "serde",
22-
# "graphviz",
23-
# ] }
2418
serde_json = "1.0.132"
2519
pyo3-log = "0.11.0"
2620
log = "0.4.22"
2721
lalrpop-util = { version = "0.22", features = ["lexer"] }
28-
ordered-float = "3.7"
22+
ordered-float = "3.7.0"
2923
uuid = { version = "1.11.0", features = ["v4"] }
3024

31-
# Use unreleased version of egraph-serialize in egglog as well
32-
# [patch.crates-io]
33-
# egraph-serialize = { git = "https://github.com/egraphs-good/egraph-serialize", rev = "5838c036623e91540831745b1574539e01c8cb23" }
34-
# egraph-serialize = { path = "../egraph-serialize" }
25+
# Use unreleased version of egglog in experimental
26+
[patch.'https://github.com/egraphs-good/egglog']
27+
# https://github.com/rust-lang/cargo/issues/5478#issuecomment-522719793
28+
egglog = { git = "https://github.com/saulshanabrook/egg-smol.git", rev = "889ca7635368d7e382e16a93b2883aba82f1078f" }
29+
30+
# [replace]
31+
# 'https://github.com/egraphs-good/egglog.git#[email protected]' = { git = "https://github.com/egraphs-good/egglog.git", rev = "215714e1cbb13ae9e21bed2f2e1bf95804571512" }
3532

3633
# enable debug symbols for easier profiling
3734
# [profile.release]

docs/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ _This project uses semantic versioning_
1414
- Use `add_note` for exception to add more context, instead of raising a new exception, to make it easier to debug.
1515
- Add conversions from generic types to be supported at runtime and typing level (so can go from `(1, 2, 3)` to `TupleInt`)
1616
- Open files with webbrowser instead of internal graphviz util for better support
17+
- Add support for not visualizing when using `.saturate()` method [#254](https://github.com/egraphs-good/egglog-python/pull/254)
18+
- Upgrade [egglog](https://github.com/egraphs-good/egglog/compare/b0db06832264c9b22694bd3de2bdacd55bbe9e32...saulshanabrook:egg-smol:889ca7635368d7e382e16a93b2883aba82f1078f)
19+
- This includes a few big changes to the underlying bindings, which I won't go over in full detail here. See the [pyi diff](https://github.com/egraphs-good/egglog-python/pull/258/files#diff-f34a5dd5d6568cd258ed9f786e5abce03df5ee95d356ea9e1b1b39e3505e5d62) for all public changes.
20+
- Creates seperate parent classes for `BuiltinExpr` vs `Expr` (aka eqsort aka user defined expressions). This is to
21+
allow us statically to differentiate between the two, to be more precise about what behavior is allowed. For example,
22+
`union` can only take `Expr` and not `BuiltinExpr`.
23+
- Removes deprecated support for modules and building functions off of the e-egraph.
24+
- Updates function constructor to remove `default` and `on_merge`. You also can't set a `cost` when you use a `merge`
25+
function or return a primitive.
26+
- `eq` now only takes two args, instead of being able to compare any number of values.
1727

1828
## 8.0.1 (2024-10-24)
1929

docs/how-to-guides.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ file_format: mystnb
66

77
## Parsing and running program strings
88

9-
You can provide your program in a special DSL language. You can parse this with {meth}`egglog.bindings.parse_program` and then run the result with You can parse this with {meth}`egglog.bindings.EGraph.run_program`::
9+
You can provide your program in a special DSL language. You can parse this with {meth}`egglog.bindings.EGraph.parse_program` and then run the result with You can parse this with {meth}`egglog.bindings.EGraph.run_program`::
1010

1111
```{code-cell}
12-
from egglog.bindings import EGraph, parse_program
12+
from egglog.bindings import EGraph
1313
1414
egraph = EGraph()
15-
commands = parse_program("(check (= (+ 1 2) 3))")
15+
commands = egraph.parse_program("(check (= (+ 1 2) 3))")
1616
commands
1717
```
1818

docs/reference/bindings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ eqsat_basic = """(datatype Math
3636
(check (= expr1 expr2))"""
3737
3838
egraph = EGraph()
39-
commands = parse_program(eqsat_basic)
39+
commands = egraph.parse_program(eqsat_basic)
4040
egraph.run_program(*commands)
4141
```
4242

docs/reference/egglog-translation.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ Any EGraph can also be converted to egglog with the `egraph.as_egglog_string` pr
1212

1313
The currently unsupported features are:
1414

15-
- Proof mode: Not currently tested, but could add support if needed.
16-
- Naive mode: Not currently exposed, but could add support
1715
- `(output ...)`: No examples in the tests, so not sure how this works.
18-
- `(calc ...)`: Could be implemented, but haven't yet.
1916

2017
## Builtin Types
2118

@@ -124,6 +121,16 @@ def my_foo() -> i64:
124121

125122
The static types on the decorator preserve the type of the underlying function, so that they can all be checked statically.
126123

124+
### Functions vs Constructors
125+
126+
Egglog has changed how it handles functions, seperating them into two seperate commands:
127+
128+
- `function` which can include a `merge` expression.
129+
- `constructor` which can include a cost and requires the result to be an "eqsort" aka a non builtin type.
130+
131+
Since this was added after the Python API was first created, we added support to automatically choose between the two based on the return type of the function and whether a merge function is provided. If the return type is a builtin type, it will be a `function`, otherwise it will be a `constructor`, unless it has a merge function
132+
provided then it will always be a `function`.
133+
127134
### Datatype functions
128135

129136
In egglog, the `(datatype ...)` command can also be used to declare functions. All of the functions declared in this block return the type of the declared datatype. Similarly, in Python, any methods of an `Expr` will be registered automatically. These

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ strict_equality = true
227227
warn_unused_configs = true
228228
allow_redefinition = true
229229
exclude = ["__snapshots__", "_build", "^conftest.py$"]
230+
# mypy_path = "python"
231+
# explicit_package_bases = true
232+
# namespace_packages = true
230233

231234
[tool.maturin]
232235
python-source = "python"

0 commit comments

Comments
 (0)